On Mon, Aug 18, 2014 at 8:33 PM, james <ja...@mansionfamily.plus.com> wrote:
> Why not call it yourself, when you cancel?

Mainly because of reason 1. If the open() system call has already
finished, then libeio is the only thing that knows what the file
descriptor is. The calling code has no way of knowing what the file
descriptor is, and thus no way to clean up the file descriptor.

Furthermore, even if reason 1 does not hold, I still cannot safely
call the callback myself, because of race conditions. The libeio
thread might not have seen my cancellation flag (e.g. due to compiler
optimizations, CPU instruction reordering, lack of memory barriers,
etc) and might be about to call my callback. This will result in my
callback being called twice. This can be solved my making callbacks
idempotent, but - in line with reason 2 - it increases the complexity
of the calling codebase by introducing new code paths.

-- 
Phusion | Web Application deployment, scaling, and monitoring solutions

Web: http://www.phusion.nl/
E-mail: i...@phusion.nl
Chamber of commerce no: 08173483 (The Netherlands)

_______________________________________________
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev

Reply via email to