1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

cgi: only run cleanup sul when processes pending

This commit is contained in:
Andy Green 2021-01-17 15:09:19 +00:00
parent 63d14e2cd9
commit 51c9e7c01e
2 changed files with 17 additions and 8 deletions

View file

@ -35,6 +35,9 @@
static const char *hex = "0123456789ABCDEF";
void
lws_cgi_sul_cb(lws_sorted_usec_list_t *sul);
static int
urlencode(const char *in, int inlen, char *out, int outlen)
{
@ -145,6 +148,11 @@ lws_cgi(struct lws *wsi, const char * const *exec_array,
cgi->cgi_list = pt->http.cgi_list;
pt->http.cgi_list = cgi;
/* if it's not already running, start the cleanup timer */
if (!pt->sul_cgi.list.owner)
lws_sul_schedule(pt->context, (int)(pt - pt->context->pt), &pt->sul_cgi,
lws_cgi_sul_cb, 3 * LWS_US_PER_SEC);
sum += lws_snprintf(sum, lws_ptr_diff_size_t(sumend, sum), "%s ", exec_array[0]);
if (0) {
@ -1095,4 +1103,7 @@ lws_cgi_remove_and_kill(struct lws *wsi)
/* we have a cgi going, we must kill it */
wsi->http.cgi->being_closed = 1;
lws_cgi_kill(wsi);
if (!pt->http.cgi_list)
lws_sul_cancel(&pt->sul_cgi);
}

View file

@ -105,7 +105,7 @@ rops_destroy_role_cgi(struct lws *wsi)
return 0;
}
static void
void
lws_cgi_sul_cb(lws_sorted_usec_list_t *sul)
{
struct lws_context_per_thread *pt = lws_container_of(sul,
@ -113,8 +113,9 @@ lws_cgi_sul_cb(lws_sorted_usec_list_t *sul)
lws_cgi_kill_terminated(pt);
lws_sul_schedule(pt->context, (int)(pt - pt->context->pt), &pt->sul_cgi,
lws_cgi_sul_cb, 3 * LWS_US_PER_SEC);
if (pt->http.cgi_list)
lws_sul_schedule(pt->context, (int)(pt - pt->context->pt),
&pt->sul_cgi, lws_cgi_sul_cb, 3 * LWS_US_PER_SEC);
}
static int
@ -122,11 +123,8 @@ rops_pt_init_destroy_cgi(struct lws_context *context,
const struct lws_context_creation_info *info,
struct lws_context_per_thread *pt, int destroy)
{
if (!destroy) {
lws_sul_schedule(context, (int)(pt - context->pt), &pt->sul_cgi,
lws_cgi_sul_cb, 3 * LWS_US_PER_SEC);
} else
lws_sul_cancel(&pt->sul_cgi);
lws_sul_cancel(&pt->sul_cgi);
return 0;
}