Beispiel #1
0
static void
createServer(struct _TServer ** const srvPP,
             bool               const noAccept,
             TChanSwitch *      const chanSwitchP,
             bool               const userChanSwitch,
             unsigned short     const portNumber,             
             const char **      const errorP) {

    struct _TServer * srvP;

    MALLOCVAR(srvP);

    if (srvP == NULL) {
        xmlrpc_asprintf(errorP,
                        "Unable to allocate space for server descriptor");
    } else {
        setupTrace(srvP);

        srvP->terminationRequested = false;

        initChanSwitchStuff(srvP, noAccept, chanSwitchP, userChanSwitch,
                            portNumber, errorP);

        if (!*errorP) {
            srvP->builtinHandlerP = HandlerCreate();
            if (!srvP->builtinHandlerP)
                xmlrpc_asprintf(errorP, "Unable to allocate space for "
                                "builtin handler descriptor");
            else {
                srvP->defaultHandler   = HandlerDefaultBuiltin;
                srvP->defaultHandlerContext = srvP->builtinHandlerP;

                srvP->name             = strdup("unnamed");
                srvP->logfilename      = NULL;
                srvP->keepalivetimeout = 15;
                srvP->keepalivemaxconn = 30;
                srvP->timeout          = 15;
                srvP->advertise        = TRUE;
                srvP->useSigchld       = FALSE;
                srvP->uriHandlerStackSize = 0;
                srvP->maxConn          = 15;
                srvP->maxConnBacklog   = 15;
            
                initUnixStuff(srvP);

                ListInitAutoFree(&srvP->handlers);

                srvP->logfileisopen = FALSE;
                
                *errorP = NULL;

                if (*errorP)
                    HandlerDestroy(srvP->builtinHandlerP);
            }
        }        
        if (*errorP)
            free(srvP);
    }
    *srvPP = srvP;
}
static void
createServer(struct _TServer ** const srvPP,
             abyss_bool         const noAccept,
             TSocket *          const userSocketP,
             uint16_t           const portNumber,             
             const char **      const errorP) {

    struct _TServer * srvP;

    MALLOCVAR(srvP);

    if (srvP == NULL) {
        xmlrpc_asprintf(errorP,
                        "Unable to allocate space for server descriptor");
    } else {
        srvP->terminationRequested = false;

        initSocketStuff(srvP, noAccept, userSocketP, portNumber, errorP);

        if (!*errorP) {
            srvP->defaulthandler = ServerDefaultHandlerFunc;

            srvP->name             = strdup("unnamed");
            srvP->filespath        = strdup(DEFAULT_DOCS);
            srvP->logfilename      = NULL;
            srvP->keepalivetimeout = 15;
            srvP->keepalivemaxconn = 30;
            srvP->timeout          = 15;
            srvP->advertise        = TRUE;
            srvP->mimeTypeP        = NULL;
            srvP->useSigchld       = FALSE;
            
            initUnixStuff(srvP);

            ListInitAutoFree(&srvP->handlers);
            ListInitAutoFree(&srvP->defaultfilenames);

            srvP->logfileisopen = FALSE;

            *errorP = NULL;
        }        
        if (*errorP)
            free(srvP);
    }
    *srvPP = srvP;
}
Beispiel #3
0
int ServerCreate(TServer *srv,POOL *pool,char *name,uint16 port,char *filespath,
				  char *modulepath, char *logfilename)
{
	/* sanity */
	if (!srv) {
		return FALSE;
	}

	srv->name = (name ? strdup(name) : 0);
	srv->port=port;
	srv->defaulthandler=(void *)ServerDefaultHandlerFunc;
	srv->rootpath =  strdup( DEFAULT_ROOT );
	srv->filespath = (filespath ? strdup(filespath) : 0);
	srv->modulepath = ( modulepath ? strdup(modulepath) : 0 );
	srv->keepalivetimeout=15;
	srv->keepalivemaxconn=100000;
	srv->timeout=15;
	srv->stopped = 0;
	srv->pool = ap_make_sub_pool( pool );

        srv->uri_handlers = 0;
        srv->uri_wildcard_handlers = 0;
        srv->content_handlers = 0;
        srv->content_wildcard_handlers = 0;

	if( srv->max_conn == 0 )
		srv->max_conn = DEFAULT_MAX_CONN;

	srv->conn = (TConn *)malloc( sizeof(TConn)*srv->max_conn );
	memset(srv->conn, 0, sizeof(TConn) * srv->max_conn);

	srv->stat_data_time = 0;
	srv->stat_conns = 0;
	srv->stat_inbytes = 0;
	srv->stat_outbytes = 0;

#ifdef _UNIX
	srv->pidfile.fd=srv->uid=srv->gid=(-1);
#endif	/* _UNIX */

	ListInitAutoFree(&srv->defaultfilenames);

	if (logfilename) {
		if( srv->error_fname )
			free( srv->error_fname );
		srv->error_fname = strdup( logfilename );
	} else 
		srv->error_fname=NULL;

	srv->conf_fname = NULL;
	srv->diag_fname = NULL;
	srv->configDB_fname = NULL;

        /* enter into the global serv list */
        ListAdd( &srv_list,srv );

	return TRUE;
}
Beispiel #4
0
BIHandler *
HandlerCreate(void) {

    struct BIHandler *handlerP;

    MALLOCVAR(handlerP);

    if (handlerP) {
        handlerP->filesPath = strdup(DEFAULT_DOCS);
        ListInitAutoFree(&handlerP->defaultFileNames);
        handlerP->mimeTypeP = NULL;
    }
    return handlerP;
}
Beispiel #5
0
void ServerFree(TServer *srv)
{
	/* sanity */
	if (!srv) {
		return;
	}

	if (srv->name) {
		free(srv->name);
		srv->name = 0;
	}

	if (srv->filespath) {
		free(srv->filespath);
		srv->filespath = 0;
	}

	if (srv->rootpath) {
		free(srv->rootpath);
		srv->rootpath = 0;
	}

	if( srv->error_fname ) {
		free( srv->error_fname );
		srv->error_fname = NULL;
	}

	if( srv->modulepath ) {
		free( srv->modulepath );
		srv->modulepath = NULL;
	}
	if( srv->pool ) {
		ap_destroy_pool( srv->pool );
		srv->pool = NULL;
	}

	ListInitAutoFree(&srv->defaultfilenames);
	SocketClose(&srv->listensock);

        /* remove from global srv list */
        ListRemove( &srv_list,srv );
}