X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=jcc.c;h=875c8a76575dbecf49a3737575f56bb2b3b325dc;hp=bb57dedb5fc9acfc0785c214f3717ac183d07c76;hb=9126f0c935e4bb64a87be7c3a1855b7768791142;hpb=ec6182134a54004b5d159eb58fafbea88ad4b5d7 diff --git a/jcc.c b/jcc.c index bb57dedb..875c8a76 100644 --- a/jcc.c +++ b/jcc.c @@ -90,11 +90,6 @@ #else #include #endif /* def __GLIBC__ */ -#else -# ifndef FD_ZERO -# include -# endif -#warning poll() appears to be unavailable. Your platform will become unsupported in the future. #endif /* HAVE_POLL */ #endif @@ -559,8 +554,6 @@ static int client_has_unsupported_expectations(const struct client_state *csp) *********************************************************************/ static jb_err get_request_destination_elsewhere(struct client_state *csp, struct list *headers) { - char *req; - if (!(csp->config->feature_flags & RUNTIME_FEATURE_ACCEPT_INTERCEPTED_REQUESTS)) { log_error(LOG_LEVEL_ERROR, "%s's request: \'%s\' is invalid." @@ -587,15 +580,12 @@ static jb_err get_request_destination_elsewhere(struct client_state *csp, struct { /* We can't work without destination. Go spread the news.*/ - req = list_to_text(headers); - chomp(req); /* XXX: Use correct size */ log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 400 0", csp->ip_addr_str, csp->http->cmd); log_error(LOG_LEVEL_ERROR, - "Privoxy was unable to get the destination for %s's request:\n%s\n%s", - csp->ip_addr_str, csp->http->cmd, req); - freez(req); + "Privoxy was unable to get the destination for %s's request: %s", + csp->ip_addr_str, csp->http->cmd); write_socket_delayed(csp->cfd, MISSING_DESTINATION_RESPONSE, strlen(MISSING_DESTINATION_RESPONSE), get_write_delay(csp)); @@ -2590,13 +2580,7 @@ static void handle_established_connection(struct client_state *csp) char *hdr; char *p; int n; -#ifdef HAVE_POLL struct pollfd poll_fds[2]; -#else - fd_set rfds; - jb_socket maxfd; - struct timeval timeout; -#endif int server_body; int ms_iis5_hack = 0; unsigned long long byte_count = 0; @@ -2635,11 +2619,6 @@ static void handle_established_connection(struct client_state *csp) http = csp->http; -#ifndef HAVE_POLL - maxfd = (csp->cfd > csp->server_connection.sfd) ? - csp->cfd : csp->server_connection.sfd; -#endif - /* pass data between the client and server * until one or the other shuts down the connection. */ @@ -2653,22 +2632,6 @@ static void handle_established_connection(struct client_state *csp) for (;;) { -#ifndef HAVE_POLL - FD_ZERO(&rfds); -#ifdef FEATURE_CONNECTION_KEEP_ALIVE - if (!watch_client_socket) - { - maxfd = csp->server_connection.sfd; - } - else -#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */ - { - FD_SET(csp->cfd, &rfds); - } - - FD_SET(csp->server_connection.sfd, &rfds); -#endif /* ndef HAVE_POLL */ - #ifdef FEATURE_CONNECTION_KEEP_ALIVE if ((csp->flags & CSP_FLAG_CHUNKED) && !(csp->flags & CSP_FLAG_CONTENT_LENGTH_SET) @@ -2712,7 +2675,6 @@ static void handle_established_connection(struct client_state *csp) } #endif /* FEATURE_CONNECTION_KEEP_ALIVE */ -#ifdef HAVE_POLL poll_fds[0].fd = csp->cfd; #ifdef FEATURE_CONNECTION_KEEP_ALIVE if (!watch_client_socket) @@ -2733,11 +2695,6 @@ static void handle_established_connection(struct client_state *csp) poll_fds[1].fd = csp->server_connection.sfd; poll_fds[1].events = POLLIN; n = poll(poll_fds, 2, csp->config->socket_timeout * 1000); -#else - timeout.tv_sec = csp->config->socket_timeout; - timeout.tv_usec = 0; - n = select((int)maxfd + 1, &rfds, NULL, NULL, &timeout); -#endif /* def HAVE_POLL */ /*server or client not responding in timeout */ if (n == 0) @@ -2756,11 +2713,7 @@ static void handle_established_connection(struct client_state *csp) } else if (n < 0) { -#ifdef HAVE_POLL log_error(LOG_LEVEL_ERROR, "poll() failed!: %E"); -#else - log_error(LOG_LEVEL_ERROR, "select() failed!: %E"); -#endif mark_server_socket_tainted(csp); #ifdef FEATURE_HTTPS_INSPECTION close_client_and_server_ssl_connections(csp); @@ -2777,7 +2730,6 @@ static void handle_established_connection(struct client_state *csp) * XXX: Make sure the client doesn't use pipelining * behind Privoxy's back. */ -#ifdef HAVE_POLL if ((poll_fds[0].revents & (POLLERR|POLLHUP|POLLNVAL)) != 0) { log_error(LOG_LEVEL_CONNECT, @@ -2789,9 +2741,6 @@ static void handle_established_connection(struct client_state *csp) } if (poll_fds[0].revents != 0) -#else - if (FD_ISSET(csp->cfd, &rfds)) -#endif /* def HAVE_POLL*/ { int max_bytes_to_read = (int)csp->receive_buffer_size; @@ -2802,7 +2751,7 @@ static void handle_established_connection(struct client_state *csp) { /* * If the next request is already waiting, we have - * to stop select()ing the client socket. Otherwise + * to stop poll()ing the client socket. Otherwise * we would always return right away and get nothing * else done. */ @@ -2841,6 +2790,37 @@ static void handle_established_connection(struct client_state *csp) #ifdef FEATURE_HTTPS_INSPECTION if (client_use_ssl(csp)) { + if (csp->http->status == 101) + { + len = ssl_recv_data(&(csp->ssl_client_attr), + (unsigned char *)csp->receive_buffer, + (size_t)max_bytes_to_read); + if (len == -1) + { + log_error(LOG_LEVEL_ERROR, "Failed to receive data " + "on client socket %d for an upgraded connection", + csp->cfd); + break; + } + if (len == 0) + { + log_error(LOG_LEVEL_CONNECT, "Done receiving data " + "on client socket %d for an upgraded connection", + csp->cfd); + break; + } + byte_count += (unsigned long long)len; + len = ssl_send_data(&(csp->ssl_server_attr), + (unsigned char *)csp->receive_buffer, (size_t)len); + if (len == -1) + { + log_error(LOG_LEVEL_ERROR, "Failed to send data " + "on server socket %d for an upgraded connection", + csp->server_connection.sfd); + break; + } + continue; + } log_error(LOG_LEVEL_CONNECT, "Breaking with TLS/SSL."); break; } @@ -2889,11 +2869,7 @@ static void handle_established_connection(struct client_state *csp) * If `hdr' is null, then it's the header otherwise it's the body. * FIXME: Does `hdr' really mean `host'? No. */ -#ifdef HAVE_POLL if (poll_fds[1].revents != 0) -#else - if (FD_ISSET(csp->server_connection.sfd, &rfds)) -#endif /* HAVE_POLL */ { #ifdef FEATURE_CONNECTION_KEEP_ALIVE /* @@ -5323,17 +5299,6 @@ static jb_socket bind_port_helper(const char *haddr, int hport, int backlog) return JB_INVALID_SOCKET; } -#ifndef HAVE_POLL -#ifndef _WIN32 - if (bfd >= FD_SETSIZE) - { - log_error(LOG_LEVEL_FATAL, - "Bind socket number too high to use select(): %d >= %d", - bfd, FD_SETSIZE); - } -#endif -#endif - if (haddr == NULL) { log_error(LOG_LEVEL_INFO, "Listening on port %d on all IP addresses",