Skip to content

Commit f402c7b

Browse files
committed
Avoid cross-thread mutex conflicts
1 parent c20a369 commit f402c7b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

iocore/eventsystem/P_UnixEventProcessor.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ EventProcessor::schedule(Event *e, EventType etype)
115115

116116
if (e->continuation->mutex) {
117117
e->mutex = e->continuation->mutex;
118-
} else {
119-
e->mutex = e->continuation->mutex = e->ethread->mutex;
120118
}
121119
e->ethread->EventQueueExternal.enqueue(e);
122120
return e;

iocore/eventsystem/UnixEThread.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#include <sys/eventfd.h>
3535
#endif
3636

37+
#include <typeinfo>
38+
3739
struct AIOCallback;
3840

3941
#define NO_HEARTBEAT -1
@@ -108,7 +110,7 @@ void
108110
EThread::process_event(Event *e, int calling_code)
109111
{
110112
ink_assert((!e->in_the_prot_queue && !e->in_the_priority_queue));
111-
MUTEX_TRY_LOCK(lock, e->mutex, this);
113+
WEAK_MUTEX_TRY_LOCK(lock, e->mutex, this);
112114
if (!lock.is_locked()) {
113115
e->timeout_at = cur_time + DELAY_FOR_RETRY;
114116
EventQueueExternal.enqueue_local(e);
@@ -120,6 +122,11 @@ EThread::process_event(Event *e, int calling_code)
120122
Continuation *c_temp = e->continuation;
121123
// Make sure that the continuation is locked before calling the handler
122124

125+
// Give a heads up if we are processing through a continuation without a mutex
126+
if (!e->mutex && c_temp) {
127+
Warning("event processing for continuation %s without a mutex", typeid(*c_temp).name());
128+
}
129+
123130
// Restore the client IP debugging flags
124131
set_cont_flags(e->continuation->control_flags);
125132

0 commit comments

Comments
 (0)