Comment 1 for bug 1546683

Revision history for this message
Jeff Godin (jgodin) wrote :

In OpenSRF::Server::spawn_child:

# from perl docs:
# [fork()] returns the child pid to the parent process, 0 to the
# child process, or "undef" if the fork is unsuccessful.
$child->{pid} = fork();

if($child->{pid}) { # parent process
    #[...]
} else { # child process <-- OR unsuccessful fork() !
    #[...]
}

I'm thinking that if we fail to fork() when attempting to spawn a child, we should log the error and exit -- similar to how we log "server: child process died" when the eval block indicates trouble.

I'm not yet sure if we should retry the fork() or simply give up.

If we retry the fork, there should be at least a short delay as well as a max retry or timeout -- otherwise I think we'll tie up the Listener indefinitely.

If we give up on the fork() attempt, we should probably add some additional handling to OpenSRF::Server::write_child to handle the situation where we have no child to send to.

I'd also like to test to ensure that we're returning an error to the client as quickly as we can, and not relying on an implicit timeout.

There is some existing fork() retry logic in OpenSRF::Utils::safe_fork, but I'm not sure that it's directly applicable.