cgi: log CGI timeout clearly with extra related info
This commit is contained in:
parent
6b3b32e98a
commit
5451457738
3 changed files with 23 additions and 3 deletions
|
@ -1765,6 +1765,8 @@ struct lws_cgi {
|
|||
unsigned char *headers_dumped;
|
||||
unsigned char *headers_end;
|
||||
|
||||
char summary[128];
|
||||
|
||||
lws_filepos_t content_length;
|
||||
lws_filepos_t content_length_seen;
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ lws_cgi(struct lws *wsi, const char * const *exec_array, int script_uri_path_len
|
|||
{
|
||||
struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi];
|
||||
char *env_array[30], cgi_path[400], e[1024], *p = e,
|
||||
*end = p + sizeof(e) - 1, tok[256], *t;
|
||||
*end = p + sizeof(e) - 1, tok[256], *t, *sum, *sumend;
|
||||
struct lws_cgi *cgi;
|
||||
int n, m = 0, i, uritok = -1;
|
||||
|
||||
|
@ -131,6 +131,8 @@ lws_cgi(struct lws *wsi, const char * const *exec_array, int script_uri_path_len
|
|||
|
||||
cgi = wsi->cgi;
|
||||
cgi->wsi = wsi; /* set cgi's owning wsi */
|
||||
sum = cgi->summary;
|
||||
sumend = sum + strlen(cgi->summary) - 1;
|
||||
|
||||
/* create pipes for [stdin|stdout] and [stderr] */
|
||||
|
||||
|
@ -189,6 +191,8 @@ lws_cgi(struct lws *wsi, const char * const *exec_array, int script_uri_path_len
|
|||
cgi->cgi_list = pt->cgi_list;
|
||||
pt->cgi_list = cgi;
|
||||
|
||||
sum += lws_snprintf(sum, sumend - sum, "%s ", exec_array[0]);
|
||||
|
||||
/* prepare his CGI env */
|
||||
|
||||
n = 0;
|
||||
|
@ -237,17 +241,25 @@ lws_cgi(struct lws *wsi, const char * const *exec_array, int script_uri_path_len
|
|||
|
||||
if (m >= 0) {
|
||||
env_array[n++] = p;
|
||||
if (m < 8)
|
||||
if (m < 8) {
|
||||
p += lws_snprintf(p, end - p,
|
||||
"REQUEST_METHOD=%s",
|
||||
meth_names[m]);
|
||||
else
|
||||
sum += lws_snprintf(sum, sumend - sum, "%s ", meth_names[m]);
|
||||
} else {
|
||||
p += lws_snprintf(p, end - p,
|
||||
"REQUEST_METHOD=%s",
|
||||
lws_hdr_simple_ptr(wsi, WSI_TOKEN_HTTP_COLON_METHOD));
|
||||
sum += lws_snprintf(sum, sumend - sum, "%s ",
|
||||
lws_hdr_simple_ptr(wsi, WSI_TOKEN_HTTP_COLON_METHOD));
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
||||
if (uritok >= 0)
|
||||
sum += lws_snprintf(sum, sumend - sum, "%s ",
|
||||
lws_hdr_simple_ptr(wsi, uritok));
|
||||
|
||||
env_array[n++] = p;
|
||||
p += lws_snprintf(p, end - p, "QUERY_STRING=");
|
||||
/* dump the individual URI Arg parameters */
|
||||
|
@ -273,6 +285,8 @@ lws_cgi(struct lws *wsi, const char * const *exec_array, int script_uri_path_len
|
|||
p--;
|
||||
*p++ = '\0';
|
||||
|
||||
sum += lws_snprintf(sum, sumend - sum, "%s", env_array[n - 1]);
|
||||
|
||||
if (script_uri_path_len >= 0) {
|
||||
env_array[n++] = p;
|
||||
p += lws_snprintf(p, end - p, "PATH_INFO=%s",
|
||||
|
|
|
@ -663,6 +663,10 @@ lws_service_timeout_check(struct lws *wsi, time_t sec)
|
|||
pt->ah_wait_list_length, n,
|
||||
(unsigned long long)sec,
|
||||
(unsigned long long)wsi->pending_timeout_limit);
|
||||
#if defined(LWS_WITH_CGI)
|
||||
if (wsi->cgi)
|
||||
lwsl_notice("CGI timeout: %s\n", wsi->cgi->summary);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Since he failed a timeout, he already had a chance to do
|
||||
|
|
Loading…
Add table
Reference in a new issue