> Date: Thu, 16 Aug 2007 10:20:11 -0700> From: [EMAIL PROTECTED]> To: [EMAIL 
> PROTECTED]> Subject: Re: [shttpd-general] Sending large amounts of data 
> without state> CC: [email protected]> > Hmm. I think that 
> WriteResponse() could be implemented with setjmp/longjmp.
 
Interesting. I am not sure exactly how that would work. Do you have any simple 
examples?
> We must make sure that data like shttpd_arg is dynamically allocated> and 
> available> after the jump. Currently, it is a stack variable.
 
What about everything else that is stored on the stack though, like local 
variables for loop indices? I can imagine how setjmp/longjmp could switch 
between two stacks but how would you set them up in the first place?
> > so having shttpd_printf(), and shttpd_copy() would be enough then !> 
> > (shttpd_copy == WriteResponse)> > Well, and callback code must be aware 
> > that shttpd_{printf,copy} may yield> control, and application state might 
> > be changed.> > So much hassle for just not using threads :-)
Yes, coroutines can be replaced by threads that switch cooperatively (instead 
of preemptively), and I actually tried this as a way to simulate fibers on a 
Pocket PC (which doesn't have fibers, though other Windows CE platforms may). 
True multithreading is even better for general purpose web servers of course 
(especially with parallel computers), but I think for embedding a web server 
within an application, threads can be much more complex to implement correctly 
than coroutines. In my application the URI handlers rarely do I/O apart from 
sockets so threads are less helpful for managing blocking I/O, and would add 
overhead and complexity.
 
Luke
 
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
shttpd-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/shttpd-general

Reply via email to