X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=jcc.c;h=8f35b329a436990f6e38d614350d35070ce66c27;hb=c97198dd7c09832c3ece8564850023e95dcc8739;hp=0aea96449534ab6602f4fdea24856295a1abccb3;hpb=e1ea3c13118134b0404a4f54a47e813794531b8d;p=privoxy.git diff --git a/jcc.c b/jcc.c index 0aea9644..8f35b329 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.380 2012/07/23 12:39:42 fabiankeil Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.384 2012/07/27 17:31:10 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jcc.c,v $ @@ -661,6 +661,34 @@ static const char *crunch_reason(const struct http_response *rsp) } +/********************************************************************* + * + * Function : log_applied_actions + * + * Description : Logs the applied actions if LOG_LEVEL_ACTIONS is + * enabled. + * + * Parameters : + * 1 : actions = Current action spec to log + * + * Returns : Nothing. + * + *********************************************************************/ +static void log_applied_actions(const struct current_action_spec *actions) +{ + /* + * The conversion to text requires lots of memory allocations so + * we only do the conversion if the user is actually interested. + */ + if (debug_level_is_enabled(LOG_LEVEL_ACTIONS)) + { + char *actions_as_text = actions_to_line_of_text(actions); + log_error(LOG_LEVEL_ACTIONS, "%s", actions_as_text); + freez(actions_as_text); + } +} + + /********************************************************************* * * Function : send_crunch_response @@ -705,6 +733,7 @@ static void send_crunch_response(const struct client_state *csp, struct http_res status_code[3] = '\0'; /* Log that the request was crunched and why. */ + log_applied_actions(csp->action); log_error(LOG_LEVEL_CRUNCH, "%s: %s", crunch_reason(rsp), http->url); log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" %s %u", csp->ip_addr_str, http->ocmd, status_code, rsp->content_length); @@ -1602,6 +1631,7 @@ static void chat(struct client_state *csp) return; } + log_applied_actions(csp->action); log_error(LOG_LEVEL_GPC, "%s%s", http->hostport, http->path); if (fwd->forward_host) @@ -2630,6 +2660,10 @@ static void serve(struct client_state *csp) if (csp->cfd != JB_INVALID_SOCKET) { + log_error(LOG_LEVEL_CONNECT, "Closing client socket %d. " + "Keep-alive: %u, Socket alive: %u. Data available: %u.", + csp->cfd, 0 != (csp->flags & CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE), + socket_is_still_alive(csp->cfd), data_is_available(csp->cfd, 0)); close_socket(csp->cfd); } @@ -3032,12 +3066,7 @@ int main(int argc, char **argv) basedir = strdup_or_die(cwd); /* XXX: why + 5? */ abs_file_size = strlen(cwd) + strlen(configfile) + 5; - abs_file = malloc(abs_file_size); - if (NULL == abs_file) - { - perror("malloc failed"); - exit(1); - } + abs_file = malloc_or_die(abs_file_size); strlcpy(abs_file, basedir, abs_file_size); strlcat(abs_file, "/", abs_file_size); strlcat(abs_file, configfile, abs_file_size); @@ -3198,9 +3227,12 @@ int main(int argc, char **argv) { log_error(LOG_LEVEL_FATAL, "Cannot setgid(): Insufficient permissions."); } - if ((NULL != grp) && setgroups(1, &grp->gr_gid)) + if (NULL != grp) { - log_error(LOG_LEVEL_FATAL, "setgroups() failed: %E"); + if (setgroups(1, &grp->gr_gid)) + { + log_error(LOG_LEVEL_FATAL, "setgroups() failed: %E"); + } } else if (initgroups(pw->pw_name, pw->pw_gid)) {