mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-04-27 06:20:10 +00:00
Add [httpd/N] context to HTTP server logging
This commit is contained in:
parent
0ac9d15b8f
commit
9f15c4770c
@ -1808,6 +1808,7 @@ void http_request_resume_response(struct http_request *r)
|
|||||||
static void http_server_poll(struct sched_ent *alarm)
|
static void http_server_poll(struct sched_ent *alarm)
|
||||||
{
|
{
|
||||||
struct http_request *r = (struct http_request *) alarm;
|
struct http_request *r = (struct http_request *) alarm;
|
||||||
|
strbuf_sprintf(&log_context, "httpd/%u", r->uuid);
|
||||||
if (alarm->poll.revents == 0) {
|
if (alarm->poll.revents == 0) {
|
||||||
// Called due to alarm: if paused then resume polling for output, otherwise the inactivity
|
// Called due to alarm: if paused then resume polling for output, otherwise the inactivity
|
||||||
// (idle) timeout has occurred, so terminate the response.
|
// (idle) timeout has occurred, so terminate the response.
|
||||||
|
@ -180,6 +180,10 @@ struct http_request {
|
|||||||
enum http_request_phase { RECEIVE, TRANSMIT, PAUSE, DONE } phase;
|
enum http_request_phase { RECEIVE, TRANSMIT, PAUSE, DONE } phase;
|
||||||
void (*finalise)(struct http_request *);
|
void (*finalise)(struct http_request *);
|
||||||
void (*free)(void*);
|
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
|
// These can be set up to point to config flags, to allow debug to be
|
||||||
// enabled indpendently for different instances HTTP server instances
|
// enabled indpendently for different instances HTTP server instances
|
||||||
// that use this code.
|
// that use this code.
|
||||||
|
4
httpd.c
4
httpd.c
@ -283,6 +283,8 @@ void httpd_server_poll(struct sched_ent *alarm)
|
|||||||
if (errno && errno != EAGAIN)
|
if (errno && errno != EAGAIN)
|
||||||
WARN_perror("accept");
|
WARN_perror("accept");
|
||||||
} else {
|
} else {
|
||||||
|
++http_request_uuid_counter;
|
||||||
|
strbuf_sprintf(&log_context, "httpd/%u", http_request_uuid_counter);
|
||||||
struct sockaddr_in *peerip=NULL;
|
struct sockaddr_in *peerip=NULL;
|
||||||
if (addr.sa_family == AF_INET) {
|
if (addr.sa_family == AF_INET) {
|
||||||
peerip = (struct sockaddr_in *)&addr; // network order
|
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_requests = request;
|
||||||
++current_httpd_request_count;
|
++current_httpd_request_count;
|
||||||
request->uuid = http_request_uuid_counter++;
|
|
||||||
request->payload_status = INVALID_RHIZOME_PAYLOAD_STATUS;
|
request->payload_status = INVALID_RHIZOME_PAYLOAD_STATUS;
|
||||||
request->bundle_status = INVALID_RHIZOME_BUNDLE_STATUS;
|
request->bundle_status = INVALID_RHIZOME_BUNDLE_STATUS;
|
||||||
if (peerip)
|
if (peerip)
|
||||||
request->http.client_sockaddr_in = *peerip;
|
request->http.client_sockaddr_in = *peerip;
|
||||||
|
request->http.uuid = http_request_uuid_counter;
|
||||||
request->http.handle_headers = httpd_dispatch;
|
request->http.handle_headers = httpd_dispatch;
|
||||||
request->http.debug_flag = &config.debug.httpd;
|
request->http.debug_flag = &config.debug.httpd;
|
||||||
request->http.disable_tx_flag = &config.debug.nohttptx;
|
request->http.disable_tx_flag = &config.debug.nohttptx;
|
||||||
|
6
httpd.h
6
httpd.h
@ -57,12 +57,6 @@ typedef struct httpd_request
|
|||||||
struct httpd_request *next;
|
struct httpd_request *next;
|
||||||
struct httpd_request *prev;
|
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.
|
/* For requests/responses that pertain to a single manifest.
|
||||||
*/
|
*/
|
||||||
rhizome_manifest *manifest;
|
rhizome_manifest *manifest;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user