Is there a safe way to cancel a timer ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm having some problems when trying to cancel a timer. In current implementation it seems that it's not possible to know if a call to gf_timer_call_cancel() has really cancelled the timer or not. It means that it's possible that the callback will be called anyway.

This is problematic if the callback of the timer uses anything that can be modified after cancelling the timer.

For example:

void timer_callback(void * data)
{
    free(data);
}

void test()
{
    data = malloc(size);
    timer = gf_timer_call_after(ctx, delta, timer_callback, data);

    ...

    gf_timer_call_cancel(ctx, timer);
    free(data);
}

Obviously this is a simplified view, but the problem is there.

Wouldn't be necessary that gf_timer_call_cancel() returns 1 if it really cancelled the callback (i.e. it won't be called) and 0 if it will be called or it's being executed ?

Thanks,

Xavi
_______________________________________________
Gluster-devel mailing list
Gluster-devel@xxxxxxxxxxx
http://supercolony.gluster.org/mailman/listinfo/gluster-devel




[Index of Archives]     [Gluster Users]     [Ceph Users]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux