On Sun, 13.10.13 22:24, David Strauss (da...@davidstrauss.net) wrote: > source_io_register errors out with EEXIST, but that's supposed to be > harmless for epoll [1]: > > Q1: What happens if you add the same fd to an epoll_set twice? > A1: You will probably get EEXIST. However, it is possible that two > threads may add the same fd twice. This is a harmless condition. > > I assume we should ignore it in the event library?
The kernel will only attach one userdata pointer to each fd, hence we cannot really pretend that adding the same fd twice could ever work: because the callback/userdata attached to it will be dropped for one of them, and that's a problem. So, we really should return EEXIST if the fd is already added. The fact that if epollctl() is invoked for the same fd from two threads at the same time the EEXIST might not be generated isn't really a problem as libsystemd-event is explicitly *not* thread safe (though threads-aware) so that it is never OK to to use it from two threads at the same time. Users of the API always have to do their own locking around it. Lennart -- Lennart Poettering - Red Hat, Inc. _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel