Diff
Not logged in

Differences From:

File src/winhttp.c part of check-in [e2e016c31f] - Get the "server" command running under windows. by drh on 2008-05-17 17:43:22. [view]

To:

File src/winhttp.c part of check-in [24f336c9ae] - Make sure temporary files are well-named and are deleted after use in the win32 fossil server command. by drh on 2008-05-17 17:52:08. [view]

@@ -40,8 +40,13 @@
   SOCKADDR_IN addr;   /* Address from which data is coming */
 };
 
 /*
+** Prefix for a temporary file.
+*/
+static char *zTempPrefix;
+
+/*
 ** Look at the HTTP header contained in zHdr.  Find the content
 ** length and return it.  Return 0 if there is no Content-Length:
 ** header line.
 */
@@ -71,10 +76,10 @@
   char zReplyFName[100];
   char zCmd[2000];          /* Command-line to process the request */
   char zHdr[2000];          /* The HTTP request header */
 
-  sprintf(zRequestFName, "win32_http_in%d.txt", p->id);
-  sprintf(zReplyFName, "win32_http_out%d.txt", p->id);
+  sprintf(zRequestFName, "%s_in%d.txt", zTempPrefix, p->id);
+  sprintf(zReplyFName, "%s_out%d.txt", zTempPrefix, p->id);
   amt = 0;
   while( amt<sizeof(zHdr) ){
     got = recv(p->s, &zHdr[amt], sizeof(zHdr)-1-amt, 0);
     if( got==SOCKET_ERROR ) goto end_request;
@@ -118,13 +123,13 @@
     }
   }
 
 end_request:
-  unlink(zRequestFName);
-  unlink(zReplyFName);
   if( out ) fclose(out);
   if( in ) fclose(in);
   closesocket(p->s);
+  unlink(zRequestFName);
+  unlink(zReplyFName);
   free(p);
 }
 
 /*
@@ -139,9 +144,9 @@
 
   if( WSAStartup(MAKEWORD(1,1), &wd) ){
     fossil_fatal("unable to initialize winsock");
   }
-
+  zTempPrefix = mprintf("fossil_server_P%d_", iPort);
   s = socket(AF_INET, SOCK_STREAM, 0);
   if( s==INVALID_SOCKET ){
     fossil_fatal("unable to create a socket");
   }