1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-06 01:33:12 +02:00

Fixed crash with scripts when WeeChat calls functions of many scripts at same time with callbacks (bug #23109)

This commit is contained in:
Sebastien Helleu
2008-04-30 13:21:21 +02:00
parent 760e216c5b
commit 886b81498f
13 changed files with 234 additions and 34 deletions
+2 -2
View File
@@ -2192,7 +2192,7 @@ weechat_perl_api_hook_signal_cb (void *data, char *signal, char *type_data,
{
struct t_script_callback *script_callback;
char *perl_argv[3];
static char value_str[64];
static char value_str[64], empty_value[1] = { '\0' };
int *rc, ret, free_needed;
script_callback = (struct t_script_callback *)data;
@@ -2201,7 +2201,7 @@ weechat_perl_api_hook_signal_cb (void *data, char *signal, char *type_data,
free_needed = 0;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
{
perl_argv[1] = (char *)signal_data;
perl_argv[1] = (signal_data) ? (char *)signal_data : empty_value;
}
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0)
{
+44 -9
View File
@@ -113,7 +113,8 @@ weechat_perl_exec (struct t_plugin_script *script,
void *ret_value;
int *ret_i, mem_err, length;
SV *ret_s;
struct t_plugin_script *old_perl_current_script;
/* this code is placed here to conform ISO C90 */
dSP;
@@ -133,6 +134,8 @@ weechat_perl_exec (struct t_plugin_script *script,
SAVETMPS;
PUSHMARK(sp);
old_perl_current_script = perl_current_script;
/* are we loading the script file ? */
if (strcmp (function, "weechat_perl_load_eval_file") != 0)
perl_current_script = script;
@@ -203,6 +206,15 @@ weechat_perl_exec (struct t_plugin_script *script,
weechat_prefix ("error"), "perl", function);
return NULL;
}
if (strcmp (function, "weechat_perl_load_eval_file") != 0)
{
perl_current_script = old_perl_current_script;
#ifdef MULTIPLICITY
if (perl_current_script)
PERL_SET_CONTEXT (perl_current_script->interpreter);
#endif
}
return ret_value;
}
@@ -381,6 +393,7 @@ weechat_perl_unload (struct t_plugin_script *script)
{
int *r;
char *perl_argv[1] = { NULL };
void *interpreter;
weechat_printf (NULL,
weechat_gettext ("%s: unloading script \"%s\""),
@@ -391,7 +404,7 @@ weechat_perl_unload (struct t_plugin_script *script)
#else
eval_pv (script->interpreter, TRUE);
#endif
if (script->shutdown_func && script->shutdown_func[0])
{
r = (int *) weechat_perl_exec (script,
@@ -402,15 +415,17 @@ weechat_perl_unload (struct t_plugin_script *script)
free (r);
}
#ifdef MULTIPLICITY
perl_destruct (script->interpreter);
perl_free (script->interpreter);
#else
if (script->interpreter)
free (script->interpreter);
#endif
interpreter = script->interpreter;
script_remove (weechat_perl_plugin, &perl_scripts, script);
#ifdef MULTIPLICITY
perl_destruct (interpreter);
perl_free (interpreter);
#else
if (interpreter)
free (interpreter);
#endif
}
/*
@@ -572,6 +587,25 @@ weechat_perl_debug_dump_cb (void *data, char *signal, char *type_data,
return WEECHAT_RC_OK;
}
/*
* weechat_perl_buffer_closed_cb: callback called when a buffer is closed
*/
int
weechat_perl_buffer_closed_cb (void *data, char *signal, char *type_data,
void *signal_data)
{
/* make C compiler happy */
(void) data;
(void) signal;
(void) type_data;
if (signal_data)
script_remove_buffer_callbacks (perl_scripts, signal_data);
return WEECHAT_RC_OK;
}
/*
* weechat_plugin_init: initialize Perl plugin
*/
@@ -605,6 +639,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
&weechat_perl_command_cb,
&weechat_perl_completion_cb,
&weechat_perl_debug_dump_cb,
&weechat_perl_buffer_closed_cb,
&weechat_perl_load_cb);
/* init ok */