summaryrefslogtreecommitdiff
path: root/ev.c
diff options
context:
space:
mode:
authorroot <root>2008-02-19 19:21:20 +0000
committerroot <root>2008-02-19 19:21:20 +0000
commit66eb4da78397464ebd2b0f59123db669899872dd (patch)
treee0403eab984cbbe063bcd205ea086e0a4565ebba /ev.c
parentd18db5d76a04a516a7ae0694522d3f6a46772f3b (diff)
fix a race between ev_async and ev_signal
Diffstat (limited to 'ev.c')
-rw-r--r--ev.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/ev.c b/ev.c
index 2b3d476..458294f 100644
--- a/ev.c
+++ b/ev.c
@@ -817,17 +817,15 @@ evpipe_init (EV_P)
}
void inline_size
-evpipe_write (EV_P_ int sig, int async)
+evpipe_write (EV_P_ EV_ATOMIC_T *flag)
{
- int sent = gotasync || gotsig;
-
- if (sig) gotsig = 1;
- if (async) gotasync = 1;
-
- if (!sent)
+ if (!*flag)
{
int old_errno = errno; /* save errno becaue write might clobber it */
+
+ *flag = 1;
write (evpipe [1], &old_errno, 1);
+
errno = old_errno;
}
}
@@ -880,7 +878,7 @@ sighandler (int signum)
#endif
signals [signum - 1].gotsig = 1;
- evpipe_write (EV_A_ 1, 0);
+ evpipe_write (EV_A_ &gotsig);
}
void noinline
@@ -2470,7 +2468,7 @@ void
ev_async_send (EV_P_ ev_async *w)
{
w->sent = 1;
- evpipe_write (EV_A_ 0, 1);
+ evpipe_write (EV_A_ &gotasync);
}
#endif