|
Thank you for the outline. I was reading in the IBM i: Sockets Programming guide where you can use multiple accept() APIs to handle incoming request. I think I am going to go with that approach. Do you know of any gotcha's with this method?
--
Chris Bipes
Director of Information Services
CrossCheck, Inc.
-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Tim Bronski
Sent: Thursday, March 09, 2017 2:24 AM
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Subject: Re: Pre-start Spawning jobs
Hi Chris, I can tell you the outline of what you need to do if that
helps. We have many server products that do this.
Yes you will spawn off the child processes before you get a connection.
We use a socket pair and sendmsg and recvmsg to communicate between the
parent and children. The socket pair are mapped to the child job's file
descriptors. We map to 0 and 1 and set this env var -
"QIBM_USE_DESCRIPTOR_STDIO=Y". We send connection information to the
children via sendmsg using a msghdr structure with the connection
socket. You will need to make sure you catch child-has-ended signals so
you can reset your counters otherwise you could end up with no child
processes if they abend! Make sure you use waitpid with WNOHANG after a
child dies or you'll end up with zombie processes. We poll for acks from
a child after we pass a connection to ensure we have active and ready
children. The ack comes back on the other half of the sock pair that's
set to non blocking. If we don't get an ack we verify the # of child
jobs and possibly start another one to deal with volume. We do have a
child number cap. If there are more than the initial number of child
jobs we have an algorithm based on the last started child time that
signals a child to end.
As an Amazon Associate we earn from qualifying purchases.
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.