--------------------- PatchSet 5148 Date: 2002/09/27 07:44:03 Author: adri Branch: commloops Tag: (none) Log: Get rid of my really crappy implementation of handling socket closures in the SSL code. Now that I understand what the old code achieved, I'm going to think things through and implement a proper closing scheme. sslSetSelect() did two things - it first queued IO for FDs where appropriate, and if an FD was closed the other FD would be closed _if the output buffer had been flushed_. This needs to be thought about a little in the new scheme - only one read or write is pending at any time rather than the strange buffering/queueing mechanism present in the old SSL code. This means that after a successful write(), we can assume the buffer in question is now empty. Also note that on an EOF condition from _any_ read() or write(), comm_close() is called on the FD in question. The other end won't be closed yet - so: * If there's a pending write(), we should wait until its finished * If there's no pending write(), we can close it immediately Members: src/ssl.c:1.13.22.5->1.13.22.6 Index: squid/src/ssl.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/ssl.c,v retrieving revision 1.13.22.5 retrieving revision 1.13.22.6 diff -u -r1.13.22.5 -r1.13.22.6 --- squid/src/ssl.c 26 Sep 2002 13:44:40 -0000 1.13.22.5 +++ squid/src/ssl.c 27 Sep 2002 07:44:03 -0000 1.13.22.6 @@ -1,6 +1,6 @@ /* - * $Id: ssl.c,v 1.13.22.5 2002/09/26 13:44:40 adri Exp $ + * $Id: ssl.c,v 1.13.22.6 2002/09/27 07:44:03 adri Exp $ * * DEBUG: section 26 Secure Sockets Layer Proxy * AUTHOR: Duane Wessels @@ -156,7 +156,6 @@ comm_close(fd); } else if (len == 0) { comm_close(sslState->server.fd); - comm_close(sslState->client.fd); } else if (cbdataReferenceValid(sslState)) comm_write(sslState->client.fd, sslState->server.buf, len, sslWriteClientDone, sslState, NULL); cbdataInternalUnlock(sslState); /* ??? */ @@ -168,8 +167,6 @@ { SslStateData *sslState = data; assert(fd == sslState->client.fd); - debug(26, 3) ("sslReadClient: FD %d, read %d bytes at offset %d\n", - fd, (int)len, (int)sslState->client.len); debug(26, 3) ("sslReadClient: FD %d, read %d bytes\n", fd, (int) len); if (len > 0) { kb_incr(&statCounter.client_http.kbytes_in, len); @@ -191,8 +188,7 @@ if (!ignoreErrno(xerrno)) comm_close(fd); } else if (len == 0) { - comm_close(sslState->server.fd); - comm_close(sslState->client.fd); + comm_close(sslState->client.fd); } else if (cbdataReferenceValid(sslState)) comm_write(sslState->server.fd, sslState->client.buf, len, sslWriteServerDone, sslState, NULL); cbdataInternalUnlock(sslState); /* ??? */ @@ -220,12 +216,7 @@ } /* EOF */ if (len == 0) { - if (sslState->server.fd > -1) - comm_close(sslState->server.fd); - - if (sslState->client.fd > -1) - comm_close(sslState->client.fd); - + comm_close(sslState->server.fd); return; } cbdataInternalLock(sslState); /* ??? should be locked by the caller... */ @@ -251,7 +242,6 @@ SslStateData *sslState = data; assert(fd == sslState->client.fd); debug(26, 3) ("sslWriteClient: FD %d, %d bytes written\n", fd, (int)len); - /* Read data */ if (len > 0) { kb_incr(&statCounter.client_http.kbytes_out, len); assert(len <= sslState->server.len); @@ -268,12 +258,7 @@ } /* EOF */ if (len == 0) { - if (sslState->server.fd > -1) - comm_close(sslState->server.fd); - - if (sslState->client.fd > -1) - comm_close(sslState->client.fd); - + comm_close(sslState->client.fd); return; } cbdataInternalLock(sslState); /* ??? should be locked by the caller... */