Fossil SCM

Initiate the TCP FIN on Windows before closing a socket.

drh 2017-12-28 21:06 trunk
Commit ef44abc6db1682451c11a140207723980643cbf38667f4d0971a8db1ac8558ec
--- src/http_socket.c
+++ src/http_socket.c
@@ -119,10 +119,11 @@
119119
** is a no-op.
120120
*/
121121
void socket_close(void){
122122
if( iSocket>=0 ){
123123
#if defined(_WIN32)
124
+ if( shutdown(iSocket,1)==0 ) shutdown(iSocket,0);
124125
closesocket(iSocket);
125126
#else
126127
close(iSocket);
127128
#endif
128129
iSocket = -1;
129130
--- src/http_socket.c
+++ src/http_socket.c
@@ -119,10 +119,11 @@
119 ** is a no-op.
120 */
121 void socket_close(void){
122 if( iSocket>=0 ){
123 #if defined(_WIN32)
 
124 closesocket(iSocket);
125 #else
126 close(iSocket);
127 #endif
128 iSocket = -1;
129
--- src/http_socket.c
+++ src/http_socket.c
@@ -119,10 +119,11 @@
119 ** is a no-op.
120 */
121 void socket_close(void){
122 if( iSocket>=0 ){
123 #if defined(_WIN32)
124 if( shutdown(iSocket,1)==0 ) shutdown(iSocket,0);
125 closesocket(iSocket);
126 #else
127 close(iSocket);
128 #endif
129 iSocket = -1;
130
--- src/winhttp.c
+++ src/winhttp.c
@@ -215,10 +215,12 @@
215215
216216
end_request:
217217
if( out ) fclose(out);
218218
if( aux ) fclose(aux);
219219
if( in ) fclose(in);
220
+ /* Initiate shutdown prior to closing the socket */
221
+ if( shutdown(p->s,1)==0 ) shutdown(p->s,0);
220222
closesocket(p->s);
221223
/* Make multiple attempts to delete the temporary files. Sometimes AV
222224
** software keeps the files open for a few seconds, preventing the file
223225
** from being deleted on the first try. */
224226
for(i=1; i<=10 && file_delete(zRequestFName); i++){ Sleep(1000*i); }
@@ -280,10 +282,12 @@
280282
}
281283
282284
end_request:
283285
if( out ) fclose(out);
284286
if( in ) fclose(in);
287
+ /* Initiate shutdown prior to closing the socket */
288
+ if( shutdown(p->s,1)==0 ) shutdown(p->s,0);
285289
closesocket(p->s);
286290
/* Make multiple attempts to delete the temporary files. Sometimes AV
287291
** software keeps the files open for a few seconds, preventing the file
288292
** from being deleted on the first try. */
289293
for(i=1; i<=10 && file_delete(zRequestFName); i++){ Sleep(1000*i); }
290294
--- src/winhttp.c
+++ src/winhttp.c
@@ -215,10 +215,12 @@
215
216 end_request:
217 if( out ) fclose(out);
218 if( aux ) fclose(aux);
219 if( in ) fclose(in);
 
 
220 closesocket(p->s);
221 /* Make multiple attempts to delete the temporary files. Sometimes AV
222 ** software keeps the files open for a few seconds, preventing the file
223 ** from being deleted on the first try. */
224 for(i=1; i<=10 && file_delete(zRequestFName); i++){ Sleep(1000*i); }
@@ -280,10 +282,12 @@
280 }
281
282 end_request:
283 if( out ) fclose(out);
284 if( in ) fclose(in);
 
 
285 closesocket(p->s);
286 /* Make multiple attempts to delete the temporary files. Sometimes AV
287 ** software keeps the files open for a few seconds, preventing the file
288 ** from being deleted on the first try. */
289 for(i=1; i<=10 && file_delete(zRequestFName); i++){ Sleep(1000*i); }
290
--- src/winhttp.c
+++ src/winhttp.c
@@ -215,10 +215,12 @@
215
216 end_request:
217 if( out ) fclose(out);
218 if( aux ) fclose(aux);
219 if( in ) fclose(in);
220 /* Initiate shutdown prior to closing the socket */
221 if( shutdown(p->s,1)==0 ) shutdown(p->s,0);
222 closesocket(p->s);
223 /* Make multiple attempts to delete the temporary files. Sometimes AV
224 ** software keeps the files open for a few seconds, preventing the file
225 ** from being deleted on the first try. */
226 for(i=1; i<=10 && file_delete(zRequestFName); i++){ Sleep(1000*i); }
@@ -280,10 +282,12 @@
282 }
283
284 end_request:
285 if( out ) fclose(out);
286 if( in ) fclose(in);
287 /* Initiate shutdown prior to closing the socket */
288 if( shutdown(p->s,1)==0 ) shutdown(p->s,0);
289 closesocket(p->s);
290 /* Make multiple attempts to delete the temporary files. Sometimes AV
291 ** software keeps the files open for a few seconds, preventing the file
292 ** from being deleted on the first try. */
293 for(i=1; i<=10 && file_delete(zRequestFName); i++){ Sleep(1000*i); }
294

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button