× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Beppe,

But I don't understand how the server can know if
there is a worker available or they are all busy and a
new one should be started and then passed the request.

Good question.

Personally, I use a spawning server (or INETD) when I expect to handle requests that will take a long time. In a long-running request, the start-up time is not usually significant, so pre-starting the workers isn't much of an issue.

I use pre-started worker jobs only when I expect to handle requests that are relatively short, and therefore it's okay to queue up a few connection attempts.

I suppose the server could maintain an array of workers and keep track of the status of each one. Each time a worker accepts a new connection, it notifies the server by sending information via a socket or pipe. That give you a scenario very similar to the data queue you're using now... the problem with that scenario is it slows down the speed at which the server can accept new connections. Which is why I just use a spawning server in that scenario, if the accept speed is going to be slow ANYWAY, what's the advantage of having a pool of server jobs?

But, perhaps the data queue approach is the best way for you, at least for the time being.


One more question: the worker is in recvmsg. However
if no request arrives within say 30 minutes, it should
end. Shall I use alarm to set the timeout ?

alarm() or select(), just like any other socket.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.