Tcl Library Source Code

View Ticket
Login
Ticket UUID: fefcf3678801b2a5f56fbca6bc3ee3032d5a01d3
Title: remoteid-to-socket ambiguity in comm
Type: Bug Version: 4.6.2
Submitter: anonymous Created on: 2014-02-06 23:39:05
Subsystem: comm Assigned To: aku
Priority: 6 Severity: Important
Status: Open Last Modified: 2014-02-11 18:43:52
Resolution: None Closed By: nobody
    Closed on:
Description:
Problems arise when two different clients connect to comm using the same port number in comm, and both pretend to be "localhost".  This happens e.g. if one client is really local and the other uses ssh tunnel to localhost. When the latter client connects, one gets a message about "incoming race condition". (I'm not sure if this should really be called a race condition, actually). When one then tries to use comm::comm send to the latter client using the (now common!!) remoteid, of course the commands goes to the first client.

A specific example using three wish 8.6 executables on Mac OS. 

Wish1 in computer1, wish2 in computer1, and wish3 in computer2. Wish1 playes the role of a server, the other are clients. Wish1 listens in OS-assigned port 55401. Wish2 in OS-assigned port 55404. Wish2 connects to wish1 by giving a command. Then, in computer2, an ssh tunnel is created to the wish1 in the computer1, using

ssh -L 6000:localhost:55401 computer1

and wish3 is started, and configured to use the same port number 55404 as wish2. Then wish3 connects via the tunnel, using

% comm::comm send {6000 localhost} puts hello


After this has been done, the ::comm::comm array in wish1 contains following stuff

:comm::comm(::comm::comm,chan)                  = ::comm::comm
::comm::comm(::comm::comm,encoding)              = utf-8
::comm::comm(::comm::comm,events)                = 
::comm::comm(::comm::comm,fids,sock7fdf739fc190) = 55404
::comm::comm(::comm::comm,fids,sock7fdf740b5590) = 55404
::comm::comm(::comm::comm,interp)                = 
::comm::comm(::comm::comm,listen)                = 1
::comm::comm(::comm::comm,local)                 = 0
::comm::comm(::comm::comm,peers,55404)           = sock7fdf739fc190
::comm::comm(::comm::comm,pending,55404)         = 
::comm::comm(::comm::comm,port)                  = 55401
::comm::comm(::comm::comm,remoteid)              = 55404
::comm::comm(::comm::comm,serial)                = 0
::comm::comm(::comm::comm,silent)                = 0

This appears a legal way of using the system, and in fact, both wish2 and wish3 can still send commands  to wish1, and they work normally. But now wish1 would like to send a command to wish3, using only the info it has (not knowing the actual IP address of computer2, or like that). It cannot do that, because the "peers" entry in the comm array gives only the socket that leads to wish2. Note that the reverse mapping (socket-to-id) contains both relevant sockets, but cannot be inverted, because the right-hand-sides are equal.

What I have been doing for the time being, is actually grab the socket fids of the connections when they occur, and force the peer-to-socket map to point the correct fid when I give the command. But this is a rather desperate hack, I would think.

I'm no really sure if this could be called a bug at all, except about possibly about the "race conditions" message, maybe. 

---

If anyone is interested, the overall context where I hit this behaviour is described in the Appendix of the following report on my web page, 
http://www.sgo.fi/~jussi/e3d/wp12_report_draft.pdf