Add [httpd/N] context to HTTP server logging

This commit is contained in:
Andrew Bettison 2015-06-22 18:13:06 +09:30
parent 0ac9d15b8f
commit 9f15c4770c
4 changed files with 8 additions and 7 deletions

View File

@ -1808,6 +1808,7 @@ void http_request_resume_response(struct http_request *r)
static void http_server_poll(struct sched_ent *alarm)
{
struct http_request *r = (struct http_request *) alarm;
strbuf_sprintf(&log_context, "httpd/%u", r->uuid);
if (alarm->poll.revents == 0) {
// Called due to alarm: if paused then resume polling for output, otherwise the inactivity
// (idle) timeout has occurred, so terminate the response.

View File

@ -180,6 +180,10 @@ struct http_request {
enum http_request_phase { RECEIVE, TRANSMIT, PAUSE, DONE } phase;
void (*finalise)(struct http_request *);
void (*free)(void*);
// Identify request from others being run. Monotonic counter feeds it. Only
// used for debugging when we write post-<uuid>.log files for multi-part form
// requests.
unsigned int uuid;
// These can be set up to point to config flags, to allow debug to be
// enabled indpendently for different instances HTTP server instances
// that use this code.

View File

@ -283,6 +283,8 @@ void httpd_server_poll(struct sched_ent *alarm)
if (errno && errno != EAGAIN)
WARN_perror("accept");
} else {
++http_request_uuid_counter;
strbuf_sprintf(&log_context, "httpd/%u", http_request_uuid_counter);
struct sockaddr_in *peerip=NULL;
if (addr.sa_family == AF_INET) {
peerip = (struct sockaddr_in *)&addr; // network order
@ -311,11 +313,11 @@ void httpd_server_poll(struct sched_ent *alarm)
}
current_httpd_requests = request;
++current_httpd_request_count;
request->uuid = http_request_uuid_counter++;
request->payload_status = INVALID_RHIZOME_PAYLOAD_STATUS;
request->bundle_status = INVALID_RHIZOME_BUNDLE_STATUS;
if (peerip)
request->http.client_sockaddr_in = *peerip;
request->http.uuid = http_request_uuid_counter;
request->http.handle_headers = httpd_dispatch;
request->http.debug_flag = &config.debug.httpd;
request->http.disable_tx_flag = &config.debug.nohttptx;

View File

@ -57,12 +57,6 @@ typedef struct httpd_request
struct httpd_request *next;
struct httpd_request *prev;
/* Identify request from others being run. Monotonic counter feeds it. Only
* used for debugging when we write post-<uuid>.log files for multi-part form
* requests.
*/
unsigned int uuid;
/* For requests/responses that pertain to a single manifest.
*/
rhizome_manifest *manifest;