Hello and a Threading/External Server/Win32 question

Shane Calimlim <[email protected]>
Newsgroups gmane.comp.web.fastcgi.devel,gmane.spam.detected
Message-ID <[email protected]>
Hi, first let me say that I'm new to the list, but I've been using (and
loving) FastCGI for years -- great work everyone involved.

I'm working on a FastCGI external server (using a port) with multiple
threads.  The problem I'm having is that even with multiple threads, only
one request is being handled at a time.  Multiple threads are handling them,
but FCGX_Accept_r() is locking until the previous request's FCGX_Finish_r()
is called.

I am also using the Qt framework; in the code snippets below qDebug() is
just a debugging printf().

Here is the code I'm using:

In main():

    if( FCGX_Init() != 0 )
    {
        qDebug( "FCGX_Init() error." );
        ::exit( 1 );
    }
    g_listenSocket = FCGX_OpenSocket( ":9000", 100 );
    if( g_listenSocket < 0 )
    {
        qDebug( "FCGX_OpenSocket() error." );
        ::exit( 1 );
    }

    //spawn threads and wait until they all terminate

In each thread:

    FCGX_Request request;
    if( FCGX_InitRequest( &request, g_listenSocket, 0 ) != 0 )
    {
        qDebug( "FCGX_InitRequest() error." );
        ::exit( 1 );
    }

    int status;
    for(;;)
    {
        status = FCGX_Accept_r( &request );
        if( status != 0 )
        {
            qDebug( "FCGX_Accept_r() error." );
            ::exit( 1 );
        }

        FCGX_FPrintF( request.out, "Content-Type: text/plain\r\n\r\n" );
        FCGX_FPrintF( request.out, "Hello World!\n" );
        for( int i = 1; i <= 10; ++i )
        {
            msleep( 1000 ); // this is a Qt function -- a 1 second sleep
            FCGX_FPrintF( request.out, "%d\n", i );
            FCGX_FFlush( request.out );
        }
        FCGX_Finish_r( &request );
    }

I've tried various combinations with Init/OpenSocket being in each thread,
but have had no luck with those.  I've also tried WSADuplicateSocket on
g_listenSocket, but Windows complains that it is not a socket.

Is this possible at all?  Is it possible on Windows?  The target platform is
Linux, but I develop on Windows, so having it work identically on my dev
machines would be very useful.

_______________________________________________
FastCGI-developers mailing list
FastCGI-developers-xGejAJT2w6xVgU18Zptdi0EOCMrvLtNR@public.gmane.org
http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.