summaryrefslogtreecommitdiffstats
path: root/third_party/libevent
diff options
context:
space:
mode:
authordkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-24 20:43:29 +0000
committerdkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-24 20:43:29 +0000
commit5206a4d36498b8a4aa3b3ca33dc6f12dcb820fd3 (patch)
tree380e91f9f452690df53f11b4960e9e02476d446e /third_party/libevent
parent04bf33c244a1d3f9d5e904d06ce158e068102db0 (diff)
downloadchromium_src-5206a4d36498b8a4aa3b3ca33dc6f12dcb820fd3.zip
chromium_src-5206a4d36498b8a4aa3b3ca33dc6f12dcb820fd3.tar.gz
chromium_src-5206a4d36498b8a4aa3b3ca33dc6f12dcb820fd3.tar.bz2
Fixes for two benign race conditions and one bug detected
by kcc's thread sanitizer: 1) remove extra '&' char; this fix is already upstream in libevent 2) delete unused and deprecated event_sigcb interface 3) avoid setting use_monotonic repeatedly. (Should really be protected with a mutex, but a simple init check seems to quiet the race detector.) Review URL: http://codereview.chromium.org/95012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14467 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/libevent')
-rw-r--r--third_party/libevent/event.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/third_party/libevent/event.c b/third_party/libevent/event.c
index 3396b35..726ffad 100644
--- a/third_party/libevent/event.c
+++ b/third_party/libevent/event.c
@@ -108,10 +108,7 @@ const struct eventop *eventops[] = {
struct event_base *current_base = NULL;
extern struct event_base *evsignal_base;
static int use_monotonic;
-
-/* Handle signals - This is a deprecated interface */
-int (*event_sigcb)(void); /* Signal callback when gotsig is set */
-volatile sig_atomic_t event_gotsig; /* Set in signal handler */
+static int use_monotonic_initialized;
/* Prototypes */
static void event_queue_insert(struct event_base *, struct event *, int);
@@ -128,10 +125,14 @@ static void
detect_monotonic(void)
{
#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
+ if (use_monotonic_initialized)
+ return;
+
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
use_monotonic = 1;
+ use_monotonic_initialized = 1;
#endif
}
@@ -179,9 +180,6 @@ event_base_new(void)
if ((base = calloc(1, sizeof(struct event_base))) == NULL)
event_err(1, "%s: calloc", __func__);
- event_sigcb = NULL;
- event_gotsig = 0;
-
detect_monotonic();
gettime(base, &base->event_tv);
@@ -385,7 +383,7 @@ event_process_active(struct event_base *base)
ncalls--;
ev->ev_ncalls = ncalls;
(*ev->ev_callback)((int)ev->ev_fd, ev->ev_res, ev->ev_arg);
- if (event_gotsig || base->event_break)
+ if (base->event_break)
return;
}
}
@@ -472,7 +470,7 @@ event_base_loop(struct event_base *base, int flags)
struct timeval *tv_p;
int res, done;
- if (&base->sig.ev_signal_added)
+ if (base->sig.ev_signal_added)
evsignal_base = base;
done = 0;
while (!done) {
@@ -487,18 +485,6 @@ event_base_loop(struct event_base *base, int flags)
break;
}
- /* You cannot use this interface for multi-threaded apps */
- while (event_gotsig) {
- event_gotsig = 0;
- if (event_sigcb) {
- res = (*event_sigcb)();
- if (res == -1) {
- errno = EINTR;
- return (-1);
- }
- }
- }
-
timeout_correct(base, &tv);
tv_p = &tv;