This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: losing events with EPOLLONESHOT and cancellation


On 16/06/13 00:03, Eric Wong wrote:
Ãngel GonzÃlez<keisial@gmail.com>  wrote:
If you need to explicitely mark like that the points where you want
to accept
cancellation, I would probably find clearer a if (cancel_thread2)
pthread_exit();

(and instead of pthread_cancel(thread_2); you would set to true the volatile
cancel_thread2 variable). But that should be equivalent. If you prefer that way,
it's up to the programmer.
Good point, I'm doing that.  I'm not sure about volatile, though[1].
I'm just using the gcc/clang __sync_add_and_fetch(&do_quit, (0|1))
to check/increment: http://bogomips.org/cmogstored.git/patch/?id=f42f8d14

[1] based on my reading of volatile-considered-harmful.txt in Linux
     kernel docs, but I think that applies to userspace, too.
I'm quite sure the use of volatile is appropiate in this case, but __sync_add_and_fetch should be good as well (it actually does a barrier which volatile wouldn't, so it's perhaps a little less efficient, but I wouldn't worry about perfomance at that level).


Also note that you probably want to continue the for in the EINTR case, so you
don't need to copy the pthread_setcancelstate(), as continuing will hit them.
Since all the accept/epoll_wait calls are already in a loop, I only put
the quit check before entering the waiting syscalls to reduce code size.
I'm not sure what you mean with this, probably that you followed my suggestion.

Best regards


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]