|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Problem with thread::transfer and TclHttpdI was doing some experiments with changing how TclHttpd handles
connections. Namely, I want to "hand off" the newly opened socket to a new thread instead of handling a lot of the housekeeping in the main thread. Sort of an experiment I'm working on. However, if I try to use thread::transfer with the socket that is opened via the socket -server handler, I get this error: "channel is shared" This is the error you get if the channel is in use by a child interp, or, I gather, it has a fileevent or something like that on it. Looking through the tclhttpd code, I don't see anything like this (no fileevent, there ARE no child interps...) so I am at a loss to figure out why I can't transfer this socket. Any thoughts on the problem, or is there a good method for me to determine what the root cause of the problem is? I even looked into the tcl code, and the error comes down to checking the number of references on a channel, and if it's more than 1, not allowing the transfer. I did not really look far enough to find out where the references could be coming from. Rusty ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Tcl-Threads mailing list Tcl-Threads@... https://lists.sourceforge.net/lists/listinfo/tcl-threads |
|
|
Re: Problem with thread::transfer and TclHttpdRusty Brooks wrote:
> I was doing some experiments with changing how TclHttpd handles > connections. Namely, I want to "hand off" the newly opened socket to a > new thread instead of handling a lot of the housekeeping in the main > thread. Sort of an experiment I'm working on. > > However, if I try to use thread::transfer with the socket that is opened > via the socket -server handler, I get this error: > > "channel is shared" > > This is the error you get if the channel is in use by a child interp, > or, I gather, it has a fileevent or something like that on it. Looking > through the tclhttpd code, I don't see anything like this (no fileevent, > there ARE no child interps...) so I am at a loss to figure out why I > can't transfer this socket. > > Any thoughts on the problem, or is there a good method for me to > determine what the root cause of the problem is? Did you follow the thread::transfer docs which hint at a possible solution to this problem? """ Due to the internal Tcl core implementation and the restriction on transferring shared channels, one has to take extra measures when transferring socket channels created by accepting the connection out of the \fBsocket\fR commands callback procedures: .nf socket -server _Accept 2200 proc _Accept {s ipaddr port} { after idle [list Accept $s $ipaddr $port] } proc Accept {s ipaddr port} { set tid [thread::create] thread::transfer $tid $s } .fi """ -- Jeff Hobbs, The Tcl Guy, http://www.ActiveState.com/ ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Tcl-Threads mailing list Tcl-Threads@... https://lists.sourceforge.net/lists/listinfo/tcl-threads |
|
|
Re: Problem with thread::transfer and TclHttpdI'm using Threads 2.4, the man pages don't mention what you have below.
Also, it does not appear to work, in the case of 2.4 (I get the same error as before)s. I'm going to see if I can upgrade to 2.6 and see if that helps. Jeff Hobbs wrote: > Rusty Brooks wrote: >> I was doing some experiments with changing how TclHttpd handles >> connections. Namely, I want to "hand off" the newly opened socket to >> a new thread instead of handling a lot of the housekeeping in the >> main thread. Sort of an experiment I'm working on. >> >> However, if I try to use thread::transfer with the socket that is >> opened via the socket -server handler, I get this error: >> >> "channel is shared" >> >> This is the error you get if the channel is in use by a child interp, >> or, I gather, it has a fileevent or something like that on it. >> Looking through the tclhttpd code, I don't see anything like this (no >> fileevent, there ARE no child interps...) so I am at a loss to figure >> out why I can't transfer this socket. >> >> Any thoughts on the problem, or is there a good method for me to >> determine what the root cause of the problem is? > > Did you follow the thread::transfer docs which hint at a possible > solution to this problem? > > """ > Due to the internal Tcl core implementation and the restriction on > transferring shared channels, one has to take extra measures when > transferring socket channels created by accepting the connection > out of the \fBsocket\fR commands callback procedures: > .nf > socket -server _Accept 2200 > proc _Accept {s ipaddr port} { > after idle [list Accept $s $ipaddr $port] > } > proc Accept {s ipaddr port} { > set tid [thread::create] > thread::transfer $tid $s > } > .fi > """ > ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Tcl-Threads mailing list Tcl-Threads@... https://lists.sourceforge.net/lists/listinfo/tcl-threads |
|
|
Re: Problem with thread::transfer and TclHttpdI upgraded to 2.6.4, and now the after idle trick works for me. Thanks
for the tip. Rusty Rusty Brooks wrote: > I'm using Threads 2.4, the man pages don't mention what you have below. > Also, it does not appear to work, in the case of 2.4 (I get the same > error as before)s. I'm going to see if I can upgrade to 2.6 and see if > that helps. > > Jeff Hobbs wrote: > >> Rusty Brooks wrote: >> >>> I was doing some experiments with changing how TclHttpd handles >>> connections. Namely, I want to "hand off" the newly opened socket to >>> a new thread instead of handling a lot of the housekeeping in the >>> main thread. Sort of an experiment I'm working on. >>> >>> However, if I try to use thread::transfer with the socket that is >>> opened via the socket -server handler, I get this error: >>> >>> "channel is shared" >>> >>> This is the error you get if the channel is in use by a child interp, >>> or, I gather, it has a fileevent or something like that on it. >>> Looking through the tclhttpd code, I don't see anything like this (no >>> fileevent, there ARE no child interps...) so I am at a loss to figure >>> out why I can't transfer this socket. >>> >>> Any thoughts on the problem, or is there a good method for me to >>> determine what the root cause of the problem is? >>> >> Did you follow the thread::transfer docs which hint at a possible >> solution to this problem? >> >> """ >> Due to the internal Tcl core implementation and the restriction on >> transferring shared channels, one has to take extra measures when >> transferring socket channels created by accepting the connection >> out of the \fBsocket\fR commands callback procedures: >> .nf >> socket -server _Accept 2200 >> proc _Accept {s ipaddr port} { >> after idle [list Accept $s $ipaddr $port] >> } >> proc Accept {s ipaddr port} { >> set tid [thread::create] >> thread::transfer $tid $s >> } >> .fi >> """ >> >> > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Tcl-Threads mailing list > Tcl-Threads@... > https://lists.sourceforge.net/lists/listinfo/tcl-threads > ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Tcl-Threads mailing list Tcl-Threads@... https://lists.sourceforge.net/lists/listinfo/tcl-threads |
| Free Forum Powered by Nabble | Forum Help |