X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=jcc.c;h=5f1a43bbfdc98e1b25ab17f91899007f465cec41;hp=ec492ef650fe234af764f2028f21b4c1146c5192;hb=3cc55dad1b9d96de47176ea913ca32f6d6f70065;hpb=ee5abceae9f104f674abd44984eefb99375ef9f5 diff --git a/jcc.c b/jcc.c index ec492ef6..5f1a43bb 100644 --- a/jcc.c +++ b/jcc.c @@ -62,10 +62,8 @@ #else /* ifndef _WIN32 */ -# if !defined (__OS2__) # include # include -# endif /* ndef __OS2__ */ # include # include # include @@ -86,14 +84,6 @@ # include /* declarations for threads and stuff. */ # endif -# if defined(__EMX__) || defined(__OS2__) -# include /* OS/2/EMX needs a little help with select */ -# endif -# ifdef __OS2__ -#define INCL_DOS -# include -# endif - #ifdef HAVE_POLL #ifdef __GLIBC__ #include @@ -143,7 +133,7 @@ int urls_rejected = 0; /* total nr of urls rejected */ int g_terminate = 0; #endif -#if !defined(_WIN32) && !defined(__OS2__) +#if !defined(_WIN32) static void sig_handler(int the_signal); #endif static int client_protocol_is_unsupported(struct client_state *csp, char *req); @@ -177,10 +167,6 @@ static int32 server_thread(void *data); #define sleep(N) Sleep(((N) * 1000)) #endif -#ifdef __OS2__ -#define sleep(N) DosSleep(((N) * 100)) -#endif - #ifdef FUZZ int process_fuzzed_input(char *fuzz_input_type, char *fuzz_input_file); void show_fuzz_usage(const char *name); @@ -347,7 +333,7 @@ static const struct cruncher crunchers_light[] = { * * here? */ -#if !defined(_WIN32) && !defined(__OS2__) +#if !defined(_WIN32) /********************************************************************* * * Function : sig_handler @@ -2486,14 +2472,13 @@ static int cgi_page_requested(const char *host) * failures etc. * * If a connection to the server has already been - * opened it is reused unless the request is blocked. + * opened it is reused unless the request is blocked + * or the forwarder changed. * * If a connection to the server has not yet been - * opened (because the previous request was crunched) - * the connection is dropped so that the client retries - * on a fresh one. - * - * XXX: Forwarding settings are currently ignored. + * opened (because the previous request was crunched), + * or the forwarder changed, the connection is dropped + * so that the client retries on a fresh one. * * Parameters : * 1 : csp = Current client state (buffers, headers, etc...) @@ -2503,6 +2488,8 @@ static int cgi_page_requested(const char *host) *********************************************************************/ static void continue_https_chat(struct client_state *csp) { + const struct forward_spec *fwd; + if (JB_ERR_OK != process_encrypted_request(csp)) { return; @@ -2529,6 +2516,24 @@ static void continue_https_chat(struct client_state *csp) csp->flags &= ~CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE; return; } + assert(csp->server_connection.sfd != JB_INVALID_SOCKET); + + fwd = forward_url(csp, csp->http); + if (!connection_destination_matches(&csp->server_connection, csp->http, fwd)) + { + log_error(LOG_LEVEL_CONNECT, + "Dropping the client connection on socket %d with " + "server socket %d connected to %s. The forwarder has changed.", + csp->cfd, csp->server_connection.sfd, csp->server_connection.host); + csp->flags &= ~CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE; + return; + } + + log_error(LOG_LEVEL_CONNECT, + "Reusing server socket %d connected to %s. Requests already sent: %u.", + csp->server_connection.sfd, csp->server_connection.host, + csp->server_connection.requests_sent_total); + if (send_https_request(csp)) { /* @@ -2542,6 +2547,7 @@ static void continue_https_chat(struct client_state *csp) csp->cfd); return; } + csp->server_connection.requests_sent_total++; handle_established_connection(csp); freez(csp->receive_buffer); } @@ -2631,15 +2637,7 @@ static void handle_established_connection(struct client_state *csp) for (;;) { #ifndef HAVE_POLL -#ifdef __OS2__ - /* - * FD_ZERO here seems to point to an errant macro which crashes. - * So do this by hand for now... - */ - memset(&rfds,0x00,sizeof(fd_set)); -#else FD_ZERO(&rfds); -#endif #ifdef FEATURE_CONNECTION_KEEP_ALIVE if (!watch_client_socket) { @@ -3667,12 +3665,6 @@ static void chat(struct client_state *csp) /* decide how to route the HTTP request */ fwd = forward_url(csp, http); - if (NULL == fwd) - { - log_error(LOG_LEVEL_FATAL, "gateway spec is NULL!?!? This can't happen!"); - /* Never get here - LOG_LEVEL_FATAL causes program exit */ - return; - } #ifdef FEATURE_HTTPS_INSPECTION /* @@ -5012,7 +5004,7 @@ int main(int argc, char **argv) * are handled when and where they occur without relying * on a signal. */ -#if !defined(_WIN32) && !defined(__OS2__) +#if !defined(_WIN32) { int idx; const int catched_signals[] = { SIGTERM, SIGINT, SIGHUP }; @@ -5474,7 +5466,7 @@ static void listen_loop(void) for (;;) #endif { -#if !defined(FEATURE_PTHREAD) && !defined(_WIN32) && !defined(__BEOS__) && !defined(__OS2__) +#if !defined(FEATURE_PTHREAD) && !defined(_WIN32) && !defined(__BEOS__) while (waitpid(-1, NULL, WNOHANG) > 0) { /* zombie children */ @@ -5619,15 +5611,6 @@ static void listen_loop(void) csp); #endif -#if defined(__OS2__) && !defined(SELECTED_ONE_OPTION) -#define SELECTED_ONE_OPTION - child_id = _beginthread( - (void(* _Optlink)(void*))serve, - NULL, - 64 * 1024, - csp); -#endif - #if defined(__BEOS__) && !defined(SELECTED_ONE_OPTION) #define SELECTED_ONE_OPTION {