Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Address a race condition in libevent select." #7940

Merged
merged 1 commit into from
Jul 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 5 additions & 24 deletions opal/mca/event/libevent2022/libevent/select.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>

#include "event-internal.h"
#include "evsignal-internal.h"
Expand Down Expand Up @@ -167,30 +166,12 @@ select_dispatch(struct event_base *base, struct timeval *tv)
check_selectop(sop);

if (res == -1) {
if (errno == EINTR) {
return (0);
if (errno != EINTR) {
event_warn("select");
return (-1);
}
/* There seems to be a very subtle race condition between the
* event_del and the select, where the fd is still active on the
* event_readset_in but no libevent structure make reference
* to it so it. Thus, any call to progress will no nothing more
* than print a warning and do nothing, leading to deadlocks.
* If we force remove the problematic fd, we get the warning only
* once, and things work as expected.
*/
event_warn("select");
for (j = 0; j < nfds; ++j) {
if (FD_ISSET(j, sop->event_readset_in) ||
FD_ISSET(j, sop->event_writeset_in)) {
res = fcntl(j, F_GETFL);
if( res == -1 ) {
event_warn("bad file descriptor %d/%d\n", j, nfds);
FD_CLR(j, sop->event_readset_in);
FD_CLR(j, sop->event_writeset_in);
}
}
}
return (-1);

return (0);
}

event_debug(("%s: select reports %d", __func__, res));
Expand Down