Пример #1
0
void
zz_xr_serverRunOnce (TServer * const serverP) {
/*----------------------------------------------------------------------------
   Accept a connection from the channel switch and do the HTTP
   transaction that comes over it.

   If no connection is presently waiting at the switch, wait for one.
   But return immediately if we receive a signal during the wait.
-----------------------------------------------------------------------------*/
    struct _TServer * const srvP = serverP->srvP;

    const char * error;
    TChannel *   channelP;
    void *       channelInfoP;

    extern void  ChanSwitchAccept ();
    extern void  ChannelFormatPeerInfo ();
    extern void  ServerSetKeepaliveMaxConn ();
    extern void  serverRunChannel ();
    extern void  xmlrpc_strfree ();


/*
    ServerSetKeepaliveMaxConn (serverP, 1);
    ChanSwitchAccept (srvP->chanSwitchP, &channelP, &channelInfoP, &error);
*/

    if (error) {
        TraceMsg ("Failed to accept the next connection from a client "
                  "at the channel level.  %s", error);
        xmlrpc_strfree (error);
    } else {

	/* Handle connection in the background.
    	 */
    	switch (fork ()) {
    	case 0:
            break; 				/* We are the child 	*/
    	default:
            return; 				/* We are the parent 	*/
    	}

        if (channelP) {
            const char * error;

            serverRunChannel (serverP, channelP, channelInfoP, &error);

            if (error) {
                const char * peerDesc;
                ChannelFormatPeerInfo (channelP, &peerDesc);
                TraceExit ("Got a connection from '%s', but failed to "
                           "run server on it.  %s", peerDesc, error);
                xmlrpc_strfree (peerDesc);
                xmlrpc_strfree (error);
            }
            ChannelDestroy (channelP);
            free (channelInfoP);
        }
    }

    exit (0);
}
Пример #2
0
void
ConnFormatClientAddr(TConn *       const connectionP,
                     const char ** const clientAddrPP) {

    ChannelFormatPeerInfo(connectionP->channelP, clientAddrPP);
}