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
Race condition in utils/factory:ssh_connect #135
Comments
hrrrm, yes, that is a race. perhaps i should add a small (10ms) sleep. Tomer Filiba On Wed, Jun 25, 2014 at 12:53 PM, Vladimir Eremin notifications@github.com
|
It will be nice if you:
|
oh, you mean the race is due to multiple threads? than that's easy to solve. -tomer Tomer Filiba On Wed, Jun 25, 2014 at 1:26 PM, Vladimir Eremin notifications@github.com
|
Not multiple threads, but multiple processes. Your fix covers 50% cases. But for multiple independent processes it is not working and user should synchronise |
but there's nothing i could do there -- it's not like they can synchronize -tomer Tomer Filiba On Wed, Jun 25, 2014 at 2:25 PM, Vladimir Eremin notifications@github.com
|
So I offer you to just say it in documentations, e.g.:
|
but the thing is, you cannot synchronize it. any process could get in the Tomer Filiba On Wed, Jun 25, 2014 at 3:24 PM, Vladimir Eremin notifications@github.com
|
Why? I can synchronise it in my app like that (or any other way using file-based inter-process synchronisation).
|
look at this code: import socket since i called rpyc chooses a random port, no matter how, and passes it to ssh. in this i hope i'm getting the message clear this time: any process might grab -tomer Tomer Filiba On Wed, Jun 25, 2014 at 3:57 PM, Vladimir Eremin notifications@github.com
|
Actually, yes. But you’ve got an exception when you’ll try to connect to some service except rpyc. I’ve got a case when I connect to wrong server via rpyc. Synchronisation in business logic + exception handling solve 90% of problems. BTW, the safest mechanism is using of native protocol. On 25 Jun 2014, at 17:06, Tomer Filiba notifications@github.com wrote:
|
Starting ssh with |
Perfect!
|
I've found out that simultaneous
rpyc.classic.ssh_connect
calls from different instances could possibly lead to race condition in https://github.com/tomerfiliba/rpyc/blob/master/rpyc/utils/factory.py#L159 .Due to non-atomic operations of port discovery and port bind it could be possible to connect to another tunnel.
ssh
only warns you about port has been already used:Since
ssh
does not accept0
as a bind port, I have no idea how to fix it easy.The text was updated successfully, but these errors were encountered: