Changeset 2587


Ignore:
Timestamp:
24/11/2009 22:32:13 (2 years ago)
Author:
chris
Message:

Add debugging for child processes terminating normally or abnormally,
as Brendon Baumgartner reported symptoms that sound like a bbstored
child process crashing, and nothing in the logs indicates what happened
to it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/lib/server/ServerStream.h

    r2415 r2587  
    303303                                if(ForkToHandleRequests && !IsSingleProcess()) 
    304304                                { 
    305                                         int status = 0; 
    306                                         int p = 0; 
    307                                         do 
    308                                         { 
    309                                                 if((p = ::waitpid(0 /* any child in process group */, &status, WNOHANG)) == -1 
    310                                                         && errno != ECHILD && errno != EINTR) 
    311                                                 { 
    312                                                         THROW_EXCEPTION(ServerException, ServerWaitOnChildError) 
    313                                                 } 
    314                                         } while(p > 0); 
     305                                        WaitForChildren(); 
    315306                                } 
    316307                                #endif // !WIN32 
     
    326317                DeleteSockets(); 
    327318        } 
     319 
     320        #ifndef WIN32 // no waitpid() on Windows 
     321        void WaitForChildren() 
     322        { 
     323                int p = 0; 
     324                do 
     325                { 
     326                        int status = 0; 
     327                        p = ::waitpid(0 /* any child in process group */, 
     328                                &status, WNOHANG); 
     329 
     330                        if(p == -1 && errno != ECHILD && errno != EINTR) 
     331                        { 
     332                                THROW_EXCEPTION(ServerException, 
     333                                        ServerWaitOnChildError) 
     334                        } 
     335                        else if(p == 0) 
     336                        { 
     337                                // no children exited, will return from 
     338                                // function 
     339                        } 
     340                        else if(WIFEXITED(status)) 
     341                        { 
     342                                BOX_INFO("child process " << p << " " 
     343                                        "terminated normally"); 
     344                        } 
     345                        else if(WIFSIGNALED(status)) 
     346                        { 
     347                                int sig = WTERMSIG(status); 
     348                                BOX_ERROR("child process " << p << " " 
     349                                        "terminated abnormally with " 
     350                                        "signal " << sig); 
     351                        } 
     352                        else 
     353                        { 
     354                                BOX_WARNING("something unknown happened " 
     355                                        "to child process " << p << ": " 
     356                                        "status = " << status); 
     357                        } 
     358                } 
     359                while(p > 0); 
     360        } 
     361        #endif 
    328362 
    329363        virtual void HandleConnection(StreamType &rStream) 
Note: See TracChangeset for help on using the changeset viewer.