Re: Can't remove a call_out.
Stefan Gluszek <[email protected]>
| Newsgroups | gmane.comp.lang.pike.user |
|---|---|
| Message-ID | <CABER6e6ToeyTg-UVa9-panDpzSC=-4Wm2qBgQmjSw85118J=Rw@mail.gmail.com> |
Since I am not a Pike-y for now it was easier for me to simply work around the issue by using the call_out id in remove_call_out. Stefan On Fri, Oct 24, 2014 at 1:23 PM, Arne Goedeke <[email protected]> wrote: > I would propose the following patch. It tries to follow the same logic > that is_eq uses when comparing trampolines: > > diff --git a/src/svalue.c b/src/svalue.c > index 0f960b2..958c290 100644 > --- a/src/svalue.c > +++ b/src/svalue.c > @@ -448,6 +448,15 @@ PMOD_EXPORT unsigned INT32 hash_svalue(const struct > svalue *s) > return q; > } > } > + case T_FUNCTION: > + if ((SUBTYPEOF(*s) != FUNCTION_BUILTIN) && s->u.object && > s->u.object->prog == pike_trampoline_program) { > + struct pike_trampoline *tramp = get_storage(s->u.object, > pike_trampoline_program); > + if (tramp) { > + q = PTR_TO_INT(tramp->func) ^ PTR_TO_INT(tramp->frame); > + break; > + } > + } > + > /* FALL THROUGH */ > default: > #if SIZEOF_CHAR_P > 4 > > > > On Fri, 24 Oct 2014, Arne Goedeke wrote: > > Interestingly, having two local variables f1 and f2 in check_timeout >> both initialized to do_timeout do compare equal but dont have the same >> hash_value. That might be a reason why remove_call_out cannot find them. >> >> arne >> >> On 10/24/14 10:25, Stefan Gluszek wrote: >> >>> Seems like a bug, I can't remove a call_out by function name right after >>> scheduling it. >>> >>> void test() >>> { >>> bool testvar = false; >>> >>> void do_timeout() >>> { >>> testvar = true; >>> }; >>> >>> void check_timeout() >>> { >>> mixed a = call_out( do_timeout, 20); >>> werror("a: %O\n", a); >>> werror("check_timeout(): %O\n", remove_call_out( do_timeout )); >>> werror("check_timeout(): %O\n", remove_call_out( a )); >>> }; >>> >>> check_timeout(); >>> } >>> >>> int main(){ >>> call_out(test, 0); >>> return -1; >>> } >>> >>> I am able to remove it by the call out id returned from call_out. Also I >>> am >>> able to remove the call out if I remove the testvar variable or move it >>> into the global scope. >>> So this works: >>> >>> void test() >>> { >>> >>> void do_timeout() >>> { >>> werror("to\n"); >>> }; >>> >>> void check_timeout() >>> { >>> mixed a = call_out( do_timeout, 20); >>> werror("a: %O\n", a); >>> werror("check_timeout(): %O\n", remove_call_out( do_timeout )); >>> werror("check_timeout(): %O\n", remove_call_out( a )); >>> }; >>> >>> check_timeout(); >>> } >>> >>> int main(){ >>> call_out(test, 0); >>> return -1; >>> } >>> >>> >>> Stefan >>> >>> >> >>