From 1361f0e88138653d2437f45ddf940206ed0e93b7 Mon Sep 17 00:00:00 2001 From: Jakub Sławiński Date: Thu, 6 Apr 2006 23:34:51 +0200 Subject: v0.8.1 - Fixed: enableproxy option in server's config file - Added: clients idle time - Added: 'maxidle' option - Modified: task scheduling subsystem has been completely rewritten - Fixed: segmentation fault in http tunnels after multiple simultaneous POST connections from the same source - Fixed: unexpected connection close when http proxy was too slow - Fixed: SIGSEGV in http proxy mode under cygwin - Added: enabled the SO_KEEPALIVE option for all the sockets used by the apf - Added: 60 seconds timeout for SSL_connect --- src/http_proxy_server.c | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) (limited to 'src/http_proxy_server.c') diff --git a/src/http_proxy_server.c b/src/http_proxy_server.c index 6da2c30..2bb2082 100644 --- a/src/http_proxy_server.c +++ b/src/http_proxy_server.c @@ -94,6 +94,7 @@ http_proxy_server(void *vptr) int maxclients, tmp; int timeout = 5; socklen_t *addrlenp; + socklen_t addrlen; char type, nothttp, https; char *host, *serv, *name = ""; SSL_CTX* ctx; @@ -111,9 +112,6 @@ http_proxy_server(void *vptr) https = proxy_argptr->https; ctx = proxy_argptr->ctx; - broadcast_condition(); - end_critical_section(); - if (https) { name = "s"; } @@ -167,6 +165,11 @@ http_proxy_server(void *vptr) exit(1); } cliaddr = malloc(*addrlenp); + addrlen = (*addrlenp); + addrlenp = &addrlen; + + broadcast_condition(); + end_critical_section(); FD_ZERO(&allset); FD_SET(listenfd, &allset); @@ -260,6 +263,26 @@ http_proxy_server(void *vptr) table[i].received = 0; clear_sslFd(table[i].postFd, &allset); table[i].state |= C_POST_WAIT; + + if (!(table[i].state & C_GET_WAIT)) { + aflog(LOG_T_MAIN, LOG_I_DDEBUG, + "http%s proxy: send A to table[%d].getfd", name, i); + if (table[i].sent_ptr+1 >= 90000) { + http_write(https, table[i].getFd, (unsigned char*) "A", 1); + table[i].sent_ptr = 0; + clear_sslFd(table[i].getFd, &allset); + FD_CLR(table[i].sockfd, &allset); + table[i].state |= C_GET_WAIT; + } + else { + http_write(https, table[i].getFd, (unsigned char*) "A", 1); + table[i].sent_ptr += 1; + } + } + else { + table[i].state |= C_DELAYED_A; + } + if (table[i].tmpstate == 1) { aflog(LOG_T_MAIN, LOG_I_DEBUG, "http%s proxy: get old POST request...", name); @@ -414,6 +437,13 @@ http_proxy_server(void *vptr) table[i].sent_ptr = table[i].length; table[i].ptr = 0; table[i].length = 0; + if (table[i].state & C_DELAYED_A) { + aflog(LOG_T_MAIN, LOG_I_DDEBUG, + "http%s proxy: send A to table[%d].getfd", name, i); + http_write(https, table[i].getFd, (unsigned char*) "A", 1); + table[i].sent_ptr += 1; + table[i].state &= ~C_DELAYED_A; + } } else if (hdr.type == H_TYPE_POST) { aflog(LOG_T_MAIN, LOG_I_DEBUG, @@ -470,9 +500,11 @@ http_proxy_server(void *vptr) } else { aflog(LOG_T_MAIN, LOG_I_DEBUG, - "http%s proxy: closing this connection...", name); + "http%s proxy: closing this connection... (not POST type)", name); close_fd((&(connFd->fd))); - SSL_clear(SslFd_get_ssl(connFd)); + if (https) { + SSL_clear(SslFd_get_ssl(connFd)); + } continue; } } @@ -492,7 +524,7 @@ http_proxy_server(void *vptr) } else { aflog(LOG_T_MAIN, LOG_I_DEBUG, - "http%s proxy: closing this connection...", name); + "http%s proxy: closing this connection... (no free slots)", name); close_fd((&(connFd->fd))); continue; } -- cgit v1.1