Ignore:
Timestamp:
Jul 11, 2023, 2:27:58 PM (12 months ago)
Author:
caparsons <caparson@…>
Branches:
master
Children:
bbecdd4
Parents:
4c8ce47
Message:

fixed spurious channel close waituntil error case. Was caused by a race condition causing an exception to be thrown while another was in flight

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/channel.hfa

    r4c8ce47 rb93bf85  
    444444}
    445445static inline bool unregister_select( chan_read(T) & this, select_node & node ) { return unregister_chan( this.chan, node ); }
    446 static inline void on_selected( chan_read(T) & this, select_node & node ) with(this) {
    447     if ( node.extra == 0p ) // check if woken up due to closed channel
    448         __closed_remove( chan, ret );
     446static inline bool on_selected( chan_read(T) & this, select_node & node ) with(this) {
     447    if ( unlikely(node.extra == 0p) ) {
     448        if ( !exception_in_flight() ) __closed_remove( chan, ret ); // check if woken up due to closed channel
     449        else return false;
     450    }
    449451    // This is only reachable if not closed or closed exception was handled
     452    return true;
    450453}
    451454
     
    536539static inline bool unregister_select( chan_write(T) & this, select_node & node ) { return unregister_chan( this.chan, node ); }
    537540
    538 static inline void on_selected( chan_write(T) & this, select_node & node ) with(this) {
    539     if ( node.extra == 0p ) // check if woken up due to closed channel
    540         __closed_insert( chan, elem );
    541 
     541static inline bool on_selected( chan_write(T) & this, select_node & node ) with(this) {
     542    if ( unlikely(node.extra == 0p) ) {
     543        if ( !exception_in_flight() ) __closed_insert( chan, elem ); // check if woken up due to closed channel
     544        else return false;
     545    }
    542546    // This is only reachable if not closed or closed exception was handled
     547    return true;
    543548}
    544549
Note: See TracChangeset for help on using the changeset viewer.