Skip to content

Commit bdbb853

Browse files
committed
opal/progress: protect against multiple threads in event base
libevent does not support multiple threads calling the event loop on the same event base. This causes external libevent's to print out re-entrant warning messages. This commit fixes the issue by protecting the call to the event loop with an atomic swap check. Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
1 parent e9f378e commit bdbb853

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

opal/runtime/opal_progress.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* University of Stuttgart. All rights reserved.
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
13-
* Copyright (c) 2006-2016 Los Alamos National Security, LLC. All rights
13+
* Copyright (c) 2006-2018 Los Alamos National Security, LLC. All rights
1414
* reserved.
1515
* Copyright (c) 2015-2016 Research Organization for Information Science
1616
* and Technology (RIST). All rights reserved.
@@ -171,9 +171,10 @@ opal_progress_finalize(void)
171171

172172
static int opal_progress_events(void)
173173
{
174+
static volatile int32_t lock = 0;
174175
int events = 0;
175176

176-
if( opal_progress_event_flag != 0 ) {
177+
if( opal_progress_event_flag != 0 && !OPAL_THREAD_SWAP_32(&lock, 1) ) {
177178
#if OPAL_HAVE_WORKING_EVENTOPS
178179
#if OPAL_PROGRESS_USE_TIMERS
179180
#if OPAL_PROGRESS_ONLY_USEC_NATIVE
@@ -201,6 +202,7 @@ static int opal_progress_events(void)
201202
#endif /* OPAL_PROGRESS_USE_TIMERS */
202203

203204
#endif /* OPAL_HAVE_WORKING_EVENTOPS */
205+
lock = 0;
204206
}
205207

206208
return events;

0 commit comments

Comments
 (0)