summaryrefslogtreecommitdiffstats
path: root/ctdb/lib/tevent/tevent_util.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_util.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_util.c')
-rw-r--r--ctdb/lib/tevent/tevent_util.c58
1 files changed, 12 insertions, 46 deletions
diff --git a/ctdb/lib/tevent/tevent_util.c b/ctdb/lib/tevent/tevent_util.c
index 54c1787400..16af8f3b90 100644
--- a/ctdb/lib/tevent/tevent_util.c
+++ b/ctdb/lib/tevent/tevent_util.c
@@ -89,53 +89,19 @@ int ev_set_blocking(int fd, bool set)
#undef FLAG_TO_SET
}
-static struct timeval tevent_before_wait_ts;
-static struct timeval tevent_after_wait_ts;
-
-/*
- * measure the time difference between multiple arrivals
- * to the point where we wait for new events to come in
- *
- * allows to measure how long it takes to work on a
- * event
- */
-void tevent_before_wait(struct event_context *ev) {
-
- struct timeval diff;
- struct timeval now = tevent_timeval_current();
-
- if (!tevent_timeval_is_zero(&tevent_after_wait_ts)) {
- diff = tevent_timeval_until(&tevent_after_wait_ts, &now);
- if (diff.tv_sec > 3) {
- tevent_debug(ev, TEVENT_DEBUG_ERROR, __location__
- " Handling event took %d seconds!",
- (int) diff.tv_sec);
- }
- }
-
- tevent_before_wait_ts = tevent_timeval_current();
-
-}
+bool ev_set_close_on_exec(int fd)
+{
+#ifdef FD_CLOEXEC
+ int val;
-/*
- * measure how long the select()/epoll() call took
- *
- * allows to measure how long we are waiting for new events
- */
-void tevent_after_wait(struct event_context *ev) {
-
- struct timeval diff;
- struct timeval now = tevent_timeval_current();
-
- if (!tevent_timeval_is_zero(&tevent_before_wait_ts)) {
- diff = tevent_timeval_until(&tevent_before_wait_ts, &now);
- if (diff.tv_sec > 3) {
- tevent_debug(ev, TEVENT_DEBUG_FATAL, __location__
- " No event for %d seconds!",
- (int) diff.tv_sec);
+ val = fcntl(fd, F_GETFD, 0);
+ if (val >= 0) {
+ val |= FD_CLOEXEC;
+ val = fcntl(fd, F_SETFD, val);
+ if (val != -1) {
+ return true;
}
}
-
- tevent_after_wait_ts = tevent_timeval_current();
-
+#endif
+ return false;
}