Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2011-08-30
06:30 • Closed ticket [3394732fff]: socket -server plus 3 other changes artifact: 5851e8d52f user: rmax
06:30 • Ticket [3394732fff]: 4 changes artifact: eb1f2942ad user: rmax
04:09 • Ticket [3394732fff]: 4 changes artifact: 5aad33e032 user: ferrieux
2011-08-21
06:20 • Add attachment servconfig.patch to ticket [3394732fff] artifact: ddab9b1262 user: ferrieux
06:20 • Ticket [3394732fff] socket -server status still Open with 4 other changes artifact: 4406887cb2 user: ferrieux
06:18 • Ticket [3394732fff]: 4 changes artifact: cd8d6111a5 user: ferrieux
2011-08-20
22:34 • Ticket [3394732fff]: 4 changes artifact: a193f760df user: rmax
16:57 • Ticket [3394732fff]: 4 changes artifact: 0e89901fe5 user: rmax
15:08 • Ticket [3394732fff]: 4 changes artifact: b7c72bbc55 user: dkf
15:07 • Ticket [3394732fff]: 4 changes artifact: 460ac22ed4 user: dkf
15:07 • Add attachment socketbug.txt to ticket [3394732fff] artifact: 17f0a30690 user: dkf
12:59 • Ticket [3394732fff] socket -server status still Open with 4 other changes artifact: 9c95466aed user: anonymous
02:16 • Ticket [3394732fff]: 5 changes artifact: a8caaa86f4 user: andreas_kupries
02:13 • Ticket [3394732fff]: 4 changes artifact: f615c5a408 user: dgp
02:09 • Ticket [3394732fff]: 4 changes artifact: 06ac329238 user: dgp
02:07 • Ticket [3394732fff]: 4 changes artifact: 0ee94ef8db user: andreas_kupries
2011-08-19
18:55 • New ticket [3394732fff]. artifact: 3891557a18 user: anonymous

socket -server

Closed / Fixed3394732fffffffffffffffffffffffffffffffffCreated 15 years agoUpdated 15 years ago
Descriptionplain2011-08-19 18:55:00
Ubuntu based OS, 32 bit, kernel 2.6.35-30, ActiveState 8.6b2 binary. 

Starting with the latest beta, my "socket -server" code stopped working in my code. It appears that setting the server socket encoding to any value, ie "-encoding binary" or even to the value it is currently set to stops the server from responding. 

Initially I thought it was the -blocking setting since it was the only setting I was changing from it's default value but after I started experimenting with the settings by  changing each one individually, the culprit turned out to be -encoding.
andreas_kupriesplain2011-08-20 02:07:54
[11:54]akuThe only big change I recall to 'socket -server' is IPv6 support getting added.
[11:54]akuAre you setting the encoding of the listening socket ? Or of the socket you get when the connection is accepted ?
dgpplain2011-08-20 02:09:51
http://pastebin.com/3mT6KPG6
dgpplain2011-08-20 02:13:57
I confirm reproduction of the pastebin
symptoms on the trunk tip.
andreas_kupriesplain2011-08-20 02:16:58
Strongly suspect the IPv6 changes.
plain2011-08-20 12:59:19
The previous pastebin expires in one day. This is a copy of it that does not expire, in case someone needss to see it:

http://pastebin.com/2xmykvVt
dkfplain2011-08-20 15:07:14
File Added - 421593: socketbug.txt
dkfplain2011-08-20 15:08:00
I've attached the contents of the paste as a file so that they don't get lost in the future.
rmaxplain2011-08-20 16:57:25
Some strace debugging revealed that after fconfigure -encoding, the first (or the only in case there is just one) file descriptor that underlays a [socket -server] gets skipped from the select() call that results from [update] or [vwait]. If there is more than one actual socket under the hood of the server channel (e.g. when the socket listens on both, IPv4 and IPv6), the second socket in the list (the IPv6 one in my case) still works after the [fconfigure].
rmaxplain2011-08-20 22:34:34
Ah - I recently removed the check for server sockets from TcpWatchProc() after I didn't find a way for it to ever get called for server sockets. But as a result of [chan configure -encoding] it does get called and removes the FileHandler for the first file descriptor in the socket. It is only the first, because connected sockets for which TcpWatchProc() is normally called, only ever have one fd and so it doesn't need to loop over them.

I could re-add the check to skip server sockets, but suggest to further investigate if changing the encoding really needs to call the watchproc. Also, it might be cleaner to not specify a watchproc in the Tcl_ChannelType struct for server sockets at all, so that TcpWatchProc() doesn't need to check for them. This would mean that separate Tcl_ChannelType structs would have to be maintained for client and server sockets, which might not be so bad, because there are more members in the struct that don't make much sense for server socckets.

In any case, we should add a test case for this, so that it can't re-appear.

As a quick fix the following line can be added at the start of TcpWatchProc():
if (statePtr->acceptProc != NULL) return;
ferrieuxplain2011-08-21 06:18:59
I'm all for minimal changes. If we feel later that the current sequence should be revised, that can be done in a separate patch (still your multiple-address patch doesn't really need it).
The attached patch does this, by restoring the test as you suggested, but also keeping the comment explaining the assumptions. This way a future reform won't miss it.
ferrieuxplain2011-08-21 06:20:41
File Added - 421629: servconfig.patch
ferrieuxplain2011-08-30 04:09:17
Reinhard, what's the status ? I was under the impression that you had this all done in your sandbox...
rmaxplain2011-08-30 06:30:04
Committed now. Sorry for the delay.
rmax Closed ticket [3394732fff]. [History diff]2011-08-30 06:30:05
Log in (anonymous is fine) to add a comment.

Attachments: