Skip to content

Commit

Permalink
cells: fix race condition between thread start and flag check
Browse files Browse the repository at this point in the history
Motivation:

If newly started thread runs before `running` flag is set, then tunnel
with shutdown instantly.

Thread-1: Create T2 -->  | T2.start()         | --> set running flag
Thread-2:                | check flag; exit   |

Modification:

set `running` before thread starts.

Result:
race is fixed

Issue: #5326
Acked-by: Paul Millar
Target: master, 10.2
Require-book: no
Require-notes: yes
(cherry picked from commit 2440b22)
Signed-off-by: Tigran Mkrtchyan <[email protected]>
  • Loading branch information
kofemann committed Jan 31, 2025
1 parent 4ea4d6f commit c30a336
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public LocationManagerConnector(String cellName, String args, SocketFactory sock
@Override
protected void started() {
_thread = getNucleus().newThread(this, "TunnelConnector-" + _domain);
_thread.start();
_isRunning = true;
_thread.start();
}

private StreamEngine connect()
Expand Down

0 comments on commit c30a336

Please sign in to comment.