summaryrefslogtreecommitdiffstats
path: root/ctdb/lib/tevent/tevent_select.c
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronniesahlberg@gmail.com>2012-04-26 08:09:23 +1000
committerRonnie Sahlberg <ronniesahlberg@gmail.com>2012-04-26 08:09:23 +1000
commitdb411aaada39593c80f92e46be31d3473bf4639f (patch)
treef68222404db2155cc6d8d3f861ac486cb8a509ae /ctdb/lib/tevent/tevent_select.c
parent58e10b280d4a94a812bad07bbca049cddb2c1174 (diff)
parent195cf3c87e3c6c9f1784aa483110a64bc8760703 (diff)
downloadsamba-db411aaada39593c80f92e46be31d3473bf4639f.tar.gz
samba-db411aaada39593c80f92e46be31d3473bf4639f.tar.xz
samba-db411aaada39593c80f92e46be31d3473bf4639f.zip
Merge remote branch 'amitay/tevent-sync'
(This used to be ctdb commit 17ff3f240b0d72c72ed28d70fb9aeb3b20c80670)
Diffstat (limited to 'ctdb/lib/tevent/tevent_select.c')
-rw-r--r--ctdb/lib/tevent/tevent_select.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/ctdb/lib/tevent/tevent_select.c b/ctdb/lib/tevent/tevent_select.c
index 1671198a20..51c1dec4a6 100644
--- a/ctdb/lib/tevent/tevent_select.c
+++ b/ctdb/lib/tevent/tevent_select.c
@@ -111,6 +111,11 @@ static struct tevent_fd *select_event_add_fd(struct tevent_context *ev, TALLOC_C
struct select_event_context);
struct tevent_fd *fde;
+ if (fd < 0 || fd >= FD_SETSIZE) {
+ errno = EBADF;
+ return NULL;
+ }
+
fde = tevent_common_add_fd(ev, mem_ctx, fd, flags,
handler, private_data,
handler_name, location);
@@ -125,8 +130,6 @@ static struct tevent_fd *select_event_add_fd(struct tevent_context *ev, TALLOC_C
return fde;
}
-extern pid_t ctdbd_pid;
-
/*
event loop handling using select()
*/
@@ -146,6 +149,11 @@ static int select_event_loop_select(struct select_event_context *select_ev, stru
/* setup any fd events */
for (fde = select_ev->ev->fd_events; fde; fde = fde->next) {
+ if (fde->fd < 0 || fde->fd >= FD_SETSIZE) {
+ errno = EBADF;
+ return -1;
+ }
+
if (fde->flags & TEVENT_FD_READ) {
FD_SET(fde->fd, &r_fds);
}
@@ -159,9 +167,7 @@ static int select_event_loop_select(struct select_event_context *select_ev, stru
return 0;
}
- if (getpid() == ctdbd_pid) tevent_before_wait(select_ev->ev);
selrtn = select(select_ev->maxfd+1, &r_fds, &w_fds, NULL, tvalp);
- if (getpid() == ctdbd_pid) tevent_after_wait(select_ev->ev);
if (selrtn == -1 && errno == EINTR &&
select_ev->ev->signal_events) {