Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.1/server: Fix PMIx_Server_Finalize hang #1250

Merged
merged 1 commit into from
May 15, 2019

Commits on May 14, 2019

  1. server: Fix PMIx_Server_Finalize hang

    The hang was quite rare and appears as the result of the race condition
    between PMIx progress thread and main thread calling
    PMIx_Server_finalize.
    
    The following sequence is possible:
    
    | main thread   | Progress thread   |
    |               | while(ev_active){ |
    | ev_active=0   |                   |
    | ev_break_loop |                   |
    |               | ev_loop()         |
    
    According to libevent manual, in this situation, libevent will
    ignore ev_break_loop as it wasn't in the loop at the time
    ev_break_loop() was called (see (b) in the libevent excerpt below)
    So the progress thread will enter the loop and hang.
    
    To fix this use event_base_loopexit that have desired behavior
    (See section (a) of the excerpt below)
    
    **excerpt from the libevent manual**:
    ```
    ...
    Note also that event_base_loopexit(base,NULL) and event_base_loopbreak(base)
    act differently when no event loop is running:
    
    (a) loopexit schedules the next instance of the event loop to stop right
    after the next round of callbacks are run (as if it had been invoked with
    EVLOOP_ONCE)
    
    (b) whereas loopbreak only stops a currently running loop, and has no
    effect if the event loop isn’t running.
    ...
    ```
    
    Signed-off-by: Artem Polyakov <artpol84@gmail.com>
    (cherry picked from commit f652ae1)
    
    Conflicts:
    	src/runtime/pmix_progress_threads.c
    artpol84 authored and karasevb committed May 14, 2019
    Configuration menu
    Copy the full SHA
    1c73049 View commit details
    Browse the repository at this point in the history