Hello everyone.
I am writing a little multithreaded FastCGI server, which i would like to describe
briefly, and get your constructive criticism.
Creates a modeless dialog with 2 buttons, OK(go) button, Stop button.
Then hides and shows an icon in the taskbar.
Creates a fixed number(configurable) of worker threads in Suspended state.
A FastCGI server should not be running on a single thread.
Creates a circular Queue. This is an array of requests(FCGX_Request)
coming from WebServer, with 2 pointers. One points to next available
slot, the other to next unprocessed slot(Request). The size of this
array is 5 slots(default) times number of worker threads.
Program sets Above-Normal priority to main thread. This thread is in a
PeekMessage loop, waiting for messages like user input(Stop/Go) events,
or Suspend inactive thread commands. If no message pending, sleeps for
(number of threads * 25) milliseconds.
Creates an Accept Request Thread(Dispatcher), also at Above-Normal priority.
This thread is in a loop waiting for requests(FCGX_Accept_r). When a
new request is received, if a thread is available(Suspended) it Resumes
that thread to handle this request. If all threads are busy it just lets
the new request in the circular queue. This allows to accept more requests
than worker threads.
When a worker thread is ready(Resumed) to handle a request, it calls Handlerequest
procedure in HandlReq.dll, passing that procedure a pointer to FCGX_Request.
This procedure must be ThreadSafe. In this Handlreq.dll all HTML output
should be created and sent to WebServer. This separates the FastCGI server
from the application DLL.
When a worker thread finishes handling a request, it looks in the queue
for another request(Synch by Mutex), if none available it goes back to
Suspended state by sending message to main thread to suspend itself.
I am testing this server with the Abyss WebServer, but under very light load.
Anything wrong with the overall design, performance, or any other issue?
I thank you very much for your comments, and opinions. I know there are many
competent programmers in this forum.
Thank you
I am writing a little multithreaded FastCGI server, which i would like to describe
briefly, and get your constructive criticism.
Creates a modeless dialog with 2 buttons, OK(go) button, Stop button.
Then hides and shows an icon in the taskbar.
Creates a fixed number(configurable) of worker threads in Suspended state.
A FastCGI server should not be running on a single thread.
Creates a circular Queue. This is an array of requests(FCGX_Request)
coming from WebServer, with 2 pointers. One points to next available
slot, the other to next unprocessed slot(Request). The size of this
array is 5 slots(default) times number of worker threads.
Program sets Above-Normal priority to main thread. This thread is in a
PeekMessage loop, waiting for messages like user input(Stop/Go) events,
or Suspend inactive thread commands. If no message pending, sleeps for
(number of threads * 25) milliseconds.
Creates an Accept Request Thread(Dispatcher), also at Above-Normal priority.
This thread is in a loop waiting for requests(FCGX_Accept_r). When a
new request is received, if a thread is available(Suspended) it Resumes
that thread to handle this request. If all threads are busy it just lets
the new request in the circular queue. This allows to accept more requests
than worker threads.
When a worker thread is ready(Resumed) to handle a request, it calls Handlerequest
procedure in HandlReq.dll, passing that procedure a pointer to FCGX_Request.
This procedure must be ThreadSafe. In this Handlreq.dll all HTML output
should be created and sent to WebServer. This separates the FastCGI server
from the application DLL.
When a worker thread finishes handling a request, it looks in the queue
for another request(Synch by Mutex), if none available it goes back to
Suspended state by sending message to main thread to suspend itself.
I am testing this server with the Abyss WebServer, but under very light load.
Anything wrong with the overall design, performance, or any other issue?
I thank you very much for your comments, and opinions. I know there are many
competent programmers in this forum.
Thank you
Comment