mirror of
https://github.com/weechat/weechat.git
synced 2026-06-26 21:06:38 +02:00
core: fix random timeouts when a lot of concurrent processes are launched with hook_process (issue #2033)
This commit is contained in:
@@ -15,6 +15,7 @@ For a list of important changes that require manual actions, please look at rele
|
||||
|
||||
Bug fixes::
|
||||
|
||||
* core: fix random timeouts when a lot of concurrent processes are launched with hook_process (issue #2033)
|
||||
* irc: revert compute of nick colors to case sensitive way, deprecate again infos "irc_nick_color" and "irc_nick_color_name" (issue #194, issue #2032)
|
||||
|
||||
Build::
|
||||
|
||||
@@ -270,7 +270,7 @@ hook_connect_free_data (struct t_hook *hook)
|
||||
if (HOOK_CONNECT(hook, child_pid) > 0)
|
||||
{
|
||||
kill (HOOK_CONNECT(hook, child_pid), SIGKILL);
|
||||
hook_schedule_clean_children ();
|
||||
hook_schedule_clean_process (HOOK_CONNECT(hook, child_pid));
|
||||
HOOK_CONNECT(hook, child_pid) = 0;
|
||||
}
|
||||
if (HOOK_CONNECT(hook, child_read) != -1)
|
||||
|
||||
@@ -862,7 +862,7 @@ hook_process_free_data (struct t_hook *hook)
|
||||
if (HOOK_PROCESS(hook, child_pid) > 0)
|
||||
{
|
||||
kill (HOOK_PROCESS(hook, child_pid), SIGKILL);
|
||||
hook_schedule_clean_children ();
|
||||
hook_schedule_clean_process (HOOK_PROCESS(hook, child_pid));
|
||||
HOOK_PROCESS(hook, child_pid) = 0;
|
||||
}
|
||||
if (HOOK_PROCESS(hook, child_read[HOOK_PROCESS_STDIN]) != -1)
|
||||
|
||||
+16
-8
@@ -28,6 +28,7 @@
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/wait.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "weechat.h"
|
||||
@@ -38,7 +39,6 @@
|
||||
#include "wee-log.h"
|
||||
#include "wee-signal.h"
|
||||
#include "wee-string.h"
|
||||
#include "wee-sys.h"
|
||||
#include "wee-util.h"
|
||||
#include "../gui/gui-chat.h"
|
||||
#include "../plugins/plugin.h"
|
||||
@@ -629,20 +629,19 @@ hook_set (struct t_hook *hook, const char *property, const char *value)
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback used to clean all children (forked processes) by acknowledging
|
||||
* their end.
|
||||
* Callback used to clean a process (forked processes) by acknowledging its end.
|
||||
*/
|
||||
|
||||
int
|
||||
hook_timer_clean_children_cb (const void *pointer, void *data,
|
||||
int remaining_calls)
|
||||
hook_timer_clean_process_cb (const void *pointer, void *data,
|
||||
int remaining_calls)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) remaining_calls;
|
||||
|
||||
sys_waitpid ();
|
||||
waitpid (*((pid_t *)data), NULL, WNOHANG);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
@@ -652,9 +651,18 @@ hook_timer_clean_children_cb (const void *pointer, void *data,
|
||||
*/
|
||||
|
||||
void
|
||||
hook_schedule_clean_children ()
|
||||
hook_schedule_clean_process (pid_t pid)
|
||||
{
|
||||
hook_timer (NULL, 100, 0, 1, &hook_timer_clean_children_cb, NULL, NULL);
|
||||
pid_t *temp_pid;
|
||||
|
||||
/* temp_pid will be freed when the timer is removed */
|
||||
temp_pid = malloc (sizeof (*temp_pid));
|
||||
if (temp_pid)
|
||||
{
|
||||
*temp_pid = pid;
|
||||
hook_timer (NULL, 100, 0, 1,
|
||||
&hook_timer_clean_process_cb, NULL, temp_pid);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+1
-1
@@ -146,7 +146,7 @@ extern void hook_callback_end (struct t_hook *hook,
|
||||
extern char *hook_get_description (struct t_hook *hook);
|
||||
extern void hook_set (struct t_hook *hook, const char *property,
|
||||
const char *value);
|
||||
extern void hook_schedule_clean_children ();
|
||||
extern void hook_schedule_clean_process (pid_t pid);
|
||||
extern void unhook (struct t_hook *hook);
|
||||
extern void unhook_all_plugin (struct t_weechat_plugin *plugin,
|
||||
const char *subplugin);
|
||||
|
||||
Reference in New Issue
Block a user