mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
spawn: retry when last stdwsi close may not be immediately followed by reapable process
This commit is contained in:
parent
425da070e3
commit
e9b3898c99
3 changed files with 31 additions and 4 deletions
|
@ -914,6 +914,7 @@ struct lws_spawn_piped {
|
|||
|
||||
siginfo_t si;
|
||||
#endif
|
||||
int reap_retry_budget;
|
||||
|
||||
uint8_t pipes_alive:2;
|
||||
uint8_t we_killed_him_timeout:1;
|
||||
|
|
|
@ -46,8 +46,20 @@ lws_spawn_sul_reap(struct lws_sorted_usec_list *sul)
|
|||
struct lws_spawn_piped *lsp = lws_container_of(sul,
|
||||
struct lws_spawn_piped, sul_reap);
|
||||
|
||||
lwsl_warn("%s: reaping spawn after last stdpipe closed\n", __func__);
|
||||
lws_spawn_reap(lsp);
|
||||
lwsl_notice("%s: reaping spawn after last stdpipe, tries left %d\n",
|
||||
__func__, lsp->reap_retry_budget);
|
||||
if (!lws_spawn_reap(lsp) && !lsp->pipes_alive) {
|
||||
if (--lsp->reap_retry_budget) {
|
||||
lws_sul_schedule(lsp->info.vh->context, lsp->info.tsi,
|
||||
&lsp->sul_reap, lws_spawn_sul_reap,
|
||||
250 * LWS_US_PER_MS);
|
||||
} else {
|
||||
lwsl_err("%s: Unable to reap lsp %p, killing\n",
|
||||
__func__, lsp);
|
||||
lsp->reap_retry_budget = 20;
|
||||
lws_spawn_piped_kill_child_process(lsp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static struct lws *
|
||||
|
@ -314,6 +326,7 @@ lws_spawn_piped(const struct lws_spawn_piped_info *i)
|
|||
|
||||
/* wholesale take a copy of info */
|
||||
lsp->info = *i;
|
||||
lsp->reap_retry_budget = 20;
|
||||
|
||||
/*
|
||||
* Prepare the stdin / out / err pipes
|
||||
|
|
|
@ -45,8 +45,20 @@ lws_spawn_sul_reap(struct lws_sorted_usec_list *sul)
|
|||
struct lws_spawn_piped *lsp = lws_container_of(sul,
|
||||
struct lws_spawn_piped, sul_reap);
|
||||
|
||||
lwsl_warn("%s: reaping spawn after last stdpipe closed\n", __func__);
|
||||
lws_spawn_reap(lsp);
|
||||
lwsl_notice("%s: reaping spawn after last stdpipe, tries left %d\n",
|
||||
__func__, lsp->reap_retry_budget);
|
||||
if (!lws_spawn_reap(lsp) && !lsp->pipes_alive) {
|
||||
if (--lsp->reap_retry_budget) {
|
||||
lws_sul_schedule(lsp->info.vh->context, lsp->info.tsi,
|
||||
&lsp->sul_reap, lws_spawn_sul_reap,
|
||||
250 * LWS_US_PER_MS);
|
||||
} else {
|
||||
lwsl_err("%s: Unable to reap lsp %p, killing\n",
|
||||
__func__, lsp);
|
||||
lsp->reap_retry_budget = 20;
|
||||
lws_spawn_piped_kill_child_process(lsp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static struct lws *
|
||||
|
@ -355,6 +367,7 @@ lws_spawn_piped(const struct lws_spawn_piped_info *i)
|
|||
/* wholesale take a copy of info */
|
||||
lsp->info = *i;
|
||||
lsp->context = context;
|
||||
lsp->reap_retry_budget = 20;
|
||||
|
||||
/*
|
||||
* Prepare the stdin / out / err pipes
|
||||
|
|
Loading…
Add table
Reference in a new issue