TclHttpd: Working example of multi-threaded operation? 
Author Message
 TclHttpd: Working example of multi-threaded operation?

Hello,

does anyone use the multi-threaded feature of the TclHttpd server
and got the server running?

How do I install an URL handler to be run as a worker
thread correctly? Have I understood it correctly that
the URL handler must respond with Thread_Respond like in
the following example?

<----------------------------------------
Url_PrefixInstall $prefix [list InternalThreadedDomainHandler $prefix]
-thread 1

proc getTimedPage {} {
   set html    "<html><title>Timed Page</title><body>\n"
   append html "Time: [clock format [clock seconds]]"
   append html "</body>\n"
   return $html

Quote:
}

proc InternalThreadedDomainHandler {prefix sock suffix} {
   upvar #0 Httpd$sock data
   set html [getTimedPage]
   Thread_Respond $sock [list Httpd_ReturnData $sock text/html $html]
Quote:
}

---------------------------------------->

Working code highly appreciated!

Greetings,
-Andreas.



Mon, 28 Jan 2008 16:11:14 GMT  
 TclHttpd: Working example of multi-threaded operation?
We are heavily using threaded tclhttpd on all major platforms with no
problem. the only thing we changed is the tclhttpd.rc "Config threads
 5". and removal of "package require Tclx" as it causes problems for
threads.
all the rest is done by tclhttpd. of course if you need communication
between the threads things become more complex. we needed to keep
session data and the solution we found was to keep the data in
temporary files.
Quote:

> Hello,

> does anyone use the multi-threaded feature of the TclHttpd server
> and got the server running?

> How do I install an URL handler to be run as a worker
> thread correctly? Have I understood it correctly that
> the URL handler must respond with Thread_Respond like in
> the following example?

> <----------------------------------------
> Url_PrefixInstall $prefix [list InternalThreadedDomainHandler $prefix]
> -thread 1

> proc getTimedPage {} {
>    set html    "<html><title>Timed Page</title><body>\n"
>    append html "Time: [clock format [clock seconds]]"
>    append html "</body>\n"
>    return $html
> }

> proc InternalThreadedDomainHandler {prefix sock suffix} {
>    upvar #0 Httpd$sock data
>    set html [getTimedPage]
>    Thread_Respond $sock [list Httpd_ReturnData $sock text/html $html]
> }
> ---------------------------------------->

> Working code highly appreciated!

> Greetings,
> -Andreas.



Mon, 28 Jan 2008 23:29:04 GMT  
 TclHttpd: Working example of multi-threaded operation?
Hi,

Quote:

> We are heavily using threaded tclhttpd on all major platforms with no
> problem. the only thing we changed is the tclhttpd.rc "Config threads
>  5". and removal of "package require Tclx" as it causes problems for
> threads.

OK, I also have done these two things.

Quote:
> all the rest is done by tclhttpd.

 >of course if you need communication

Quote:
> between the threads things become more complex.

It seems to me that the communication between the
worker threads and the master thread is done in the
TclHttpd server itself, because I get the following error
message:

Error from thread tid0x803
thread "tid0x400" does not exist
     while executing
"Thread_SendAsync $data(master_thread) [list Thread_Unwind  [Thread_Id]
$sock [array get data] $cmd]"
     (procedure "Thread_Respond" line 12)
     invoked from within
"Thread_Respond $sock [list Url_Unwind $sock $errorInfo $errorCode]"
     (procedure "Thread_Invoke" line 16)
     invoked from within
"Thread_Invoke sock11 {uri /testme pathlist {} count 0 key
content-length state mime self {http sigoslx162.sigos.de 20000}
master_thread tid0x400 url /..."
Thread_Respond: data(master_thread)=tid0x400, current ID=tid0xc04, known
threads=tid0xc04 tid0x803

How did you register your URL handlers? Do you have example code
for me?

Greetings,
-Andreas.



Tue, 29 Jan 2008 01:00:13 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. TclHttpd: Multi-threaded operation mode does not work

2. Q: multi-thread or processing examples for OpenMCL?

3. Multi-threaded / multi-processor CL ?

4. Multi-threading on Multi-CPU machines

5. tclhttpd session examples/tutorials

6. tclhttpd and threads

7. tclhttpd.kit doesn't run the cgi examples

8. tclhttpd with threads

9. tclhttpd using new thread capabilities anyone ?

10. TclHttpd 3.3 and Threads ?

11. Example of writing an XML-RPC for TclHTTPd

12. Tclhttpd and Threads (Pls ignore previous one as it was from the wrong account)

 

 
Powered by phpBB® Forum Software