Skip to content

Commit

Permalink
Fixed race condition in Android/UDP transport, fixes zeroc-ice#527
Browse files Browse the repository at this point in the history
  • Loading branch information
bentoi committed Sep 13, 2019
1 parent 712dceb commit 877cb13
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public java.nio.channels.SelectableChannel fd()
@Override
public void setReadyCallback(ReadyCallback callback)
{
assert(_readyCallback == null && callback != null);
_readyCallback = callback;
_thread.start();
}

@Override
Expand Down Expand Up @@ -249,7 +251,6 @@ public void run()
runWriteThread();
}
};
_thread.start();
}
catch(Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ public java.nio.channels.SelectableChannel fd()
@Override
public void setReadyCallback(ReadyCallback callback)
{
assert(_readyCallback == null && callback != null);
_readyCallback = callback;

//
// Start the thread only once the ready callback is set or otherwise the thread
// might start receiving datagrams but wouldn't be able to notify the thread pool.
//
_thread.start();
}

@Override
Expand Down Expand Up @@ -255,7 +262,6 @@ public void run()
runReadThread();
}
};
_thread.start();
}
catch(Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public java.nio.channels.SelectableChannel fd()
@Override
public void setReadyCallback(ReadyCallback callback)
{
assert(_readyCallback == null && callback != null);
_readyCallback = callback;
_thread.start();
}

@Override
Expand Down Expand Up @@ -249,7 +251,6 @@ public void run()
runWriteThread();
}
};
_thread.start();
}
catch(Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ public java.nio.channels.SelectableChannel fd()
@Override
public void setReadyCallback(ReadyCallback callback)
{
assert(_readyCallback == null && callback != null);
_readyCallback = callback;

//
// Start the thread only once the ready callback is set or otherwise the thread
// might start receiving datagrams but wouldn't be able to notify the thread pool.
//
_thread.start();
}

@Override
Expand Down Expand Up @@ -255,7 +262,6 @@ public void run()
runReadThread();
}
};
_thread.start();
}
catch(Exception ex)
{
Expand Down

0 comments on commit 877cb13

Please sign in to comment.