Okay so here's the theory.

For the CGI process, SHTTPD creates two stdio pipes, and spawns two threads
- for stdin and stdout. Both threads keep a socketpair to SHTTPD core. When
stdin thread reads CGI's output, it pushes it to a socketpair, waking up the
core from select().

When CGI process exits, the thread pushes all read data to a socketpair,
closes its end of the pair, and exits.

        while (!stop && ReadFile(tp->hPipe, buf, sizeof(buf), &n, NULL)) {
                ntotal += n;
                for (sent = 0; !stop && sent < n; sent += k)
                        if ((k = send(tp->s, buf + sent, n - sent, 0)) <= 0)
                                stop++;
        }
        CloseHandle(tp->hPipe);
        closesocket(tp->s);
        free(tp);
        _endthread();


Recently I make SHTTPD socketpair non-blocking.. This may had caused while()
loop to exit prematurely, since send() may return -1.

Try to remove set_non_blocking_mode() calls from shttpd_socketpair and see
if it helps.
If it does not, then we need to have some sort of synchronization: stdin
thread must not exit until SHTTPD code have read all the data.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
shttpd-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/shttpd-general

Reply via email to