2 * threaded.c -- A simple multi-threaded FastCGI application.
6 static const char rcsid[] = "$Id: threaded.c,v 1.1 1999/07/26 04:28:07 roberts Exp $";
9 #if defined HAVE_UNISTD_H || defined __linux__
21 #define THREAD_COUNT 20
23 int count[THREAD_COUNT];
25 static void *doit(void *a)
29 FCGX_Stream *in, *out, *err;
33 FCGX_InitRequest(&request);
35 while (FCGX_Accept_r(&in, &out, &err, &envp, &request) >= 0)
38 "Content-type: text/html\r\n"
40 "<title>FastCGI Hello! (multi-threaded C, fcgiapp library)</title>"
41 "<h1>FastCGI Hello! (multi-threaded C, fcgiapp library)</h1>"
42 "Request counts for %d threads running on host <i>%s</i><P><CODE>",
43 THREAD_COUNT, FCGX_GetParam("SERVER_NAME", envp));
47 for (i = 0; i < THREAD_COUNT; i++)
48 FCGX_FPrintF(out, "%5d " , count[i]);
57 pthread_t id[THREAD_COUNT];
61 for (i = 0; i < THREAD_COUNT; i++)
64 for (i = 1; i < THREAD_COUNT; i++)
65 pthread_create(&id[i], NULL, doit, (void*)i);