--------------------- PatchSet 5204 Date: 2002/10/03 09:25:01 Author: adri Branch: commloops Tag: (none) Log: Convert over the httpsAccept() magic. Members: src/client_side.c:1.52.4.5->1.52.4.6 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.52.4.5 retrieving revision 1.52.4.6 diff -u -r1.52.4.5 -r1.52.4.6 --- squid/src/client_side.c 3 Oct 2002 08:51:04 -0000 1.52.4.5 +++ squid/src/client_side.c 3 Oct 2002 09:25:01 -0000 1.52.4.6 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.52.4.5 2002/10/03 08:51:04 adri Exp $ + * $Id: client_side.c,v 1.52.4.6 2002/10/03 09:25:01 adri Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -1707,6 +1707,13 @@ /* XXX we're not considering httpAcceptDefer yet! */ do { + if (flag != COMM_OK) { + errno = xerrno; + debug(50, 1) ("httpAccept: FD %d: accept failure: %s\n", + sock, xstrerror()); + return; + } + debug(33, 4) ("httpAccept: FD %d: accepted\n", newfd); connState = connStateCreate(peer, me, newfd); comm_add_close_handler(newfd, connStateFree, connState); @@ -1779,61 +1786,57 @@ /* handle a new HTTPS connection */ static void -httpsAccept(int sock, void *data) +httpsAccept(int sock, int newfd, struct sockaddr_in *me, struct sockaddr_in *peer, + comm_err_t flag, int xerrno, void *data) { int *N = &incoming_sockets_accepted; https_port_data *https_port = data; SSL_CTX *sslContext = https_port->sslContext; - int fd = -1; ConnStateData *connState = NULL; - struct sockaddr_in peer; - struct sockaddr_in me; - int max = INCOMING_HTTP_MAX; SSL *ssl; int ssl_error; #if USE_IDENT static aclCheck_t identChecklist; #endif - commSetSelect(sock, COMM_SELECT_READ, httpsAccept, https_port, 0); - while (max-- && !httpAcceptDefer(sock, NULL)) { - memset(&peer, '\0', sizeof(struct sockaddr_in)); - memset(&me, '\0', sizeof(struct sockaddr_in)); - if ((fd = comm_old_accept(sock, &peer, &me)) < 0) { - if (!ignoreErrno(errno)) + comm_accept(sock, httpsAccept, NULL); + do { + if (flag != COMM_OK) { + errno = xerrno; debug(50, 1) ("httpsAccept: FD %d: accept failure: %s\n", sock, xstrerror()); - break; - } + return; + } + if ((ssl = SSL_new(sslContext)) == NULL) { ssl_error = ERR_get_error(); debug(83, 1) ("httpsAccept: Error allocating handle: %s\n", ERR_error_string(ssl_error, NULL)); break; } - SSL_set_fd(ssl, fd); - fd_table[fd].ssl = ssl; - fd_table[fd].read_method = &ssl_read_method; - fd_table[fd].write_method = &ssl_write_method; - debug(50, 5) ("httpsAccept: FD %d accepted, starting SSL negotiation.\n", fd); + SSL_set_fd(ssl, newfd); + fd_table[newfd].ssl = ssl; + fd_table[newfd].read_method = &ssl_read_method; + fd_table[newfd].write_method = &ssl_write_method; + debug(50, 5) ("httpsAccept: FD %d accepted, starting SSL negotiation.\n", newfd); - connState = connStateCreate(peer, me, fd); + connState = connStateCreate(peer, me, newfd); /* XXX account connState->in.buf */ - comm_add_close_handler(fd, connStateFree, connState); + comm_add_close_handler(newfd, connStateFree, connState); if (Config.onoff.log_fqdn) - fqdncache_gethostbyaddr(peer.sin_addr, FQDN_LOOKUP_IF_MISS); - commSetTimeout(fd, Config.Timeout.request, requestTimeout, connState); + fqdncache_gethostbyaddr(peer->sin_addr, FQDN_LOOKUP_IF_MISS); + commSetTimeout(newfd, Config.Timeout.request, requestTimeout, connState); #if USE_IDENT - identChecklist.src_addr = peer.sin_addr; - identChecklist.my_addr = me.sin_addr; - identChecklist.my_port = ntohs(me.sin_port); + identChecklist.src_addr = peer->sin_addr; + identChecklist.my_addr = me->sin_addr; + identChecklist.my_port = ntohs(me->sin_port); if (aclCheckFast(Config.accessList.identLookup, &identChecklist)) - identStart(&me, &peer, clientIdentDone, connState); + identStart(me, peer, clientIdentDone, connState); #endif - commSetSelect(fd, COMM_SELECT_READ, clientNegotiateSSL, connState, 0); - commSetDefer(fd, clientReadDefer, connState); - clientdbEstablished(peer.sin_addr, 1); + commSetSelect(newfd, COMM_SELECT_READ, clientNegotiateSSL, connState, 0); + commSetDefer(newfd, clientReadDefer, connState); + clientdbEstablished(peer->sin_addr, 1); (*N)++; - } + } while (0); } #endif /* USE_SSL */ @@ -1940,8 +1943,8 @@ https_port->sslContext = sslCreateContext(s->cert, s->key, s->version, s->cipher, s->options); - comm_old_listen(fd); - commSetSelect(fd, COMM_SELECT_READ, httpsAccept, https_port, 0); + comm_listen(fd); + comm_accept(fd, httpsAccept, NULL); commSetDefer(fd, httpAcceptDefer, NULL); debug(1, 1) ("Accepting HTTPS connections at %s, port %d, FD %d.\n", inet_ntoa(s->s.sin_addr), (int) ntohs(s->s.sin_port), fd);