Esempio n. 1
0
void post_server_shutdown(int status)
{
    switch (status)
    {
	case 0:
	    topiclist_unload();
    	    realmlist_destroy();
	    teamlist_unload();
            clanlist_unload();
	    tournament_destroy();
	    anongame_infos_unload();
	    trans_unload();
	    aliasfile_unload();
	    command_groups_unload();
	    tracker_set_servers(NULL);
	    characterlist_destroy();
            ladder_destroyxptable();
        case STATUS_WAR3XPTABLES_FAILURE:

	case STATUS_LADDERLIST_FAILURE:
	    ladder_update_all_accounts();
    	    ladders_destroy();
	    output_dispose_filename();
	    accountlist_destroy();
    	    attrlayer_cleanup();
    	    watchlist_destroy();
	    news_unload();
    	    versioncheck_unload();
    	    autoupdate_unload();
    	    adbannerlist_destroy();
    	    ipbanlist_save(prefs_get_ipbanfile());
    	    ipbanlist_destroy();
    	    helpfile_unload();
    	    channellist_destroy();
	    server_clear_hostname();
    	    timerlist_destroy();
	    gamelist_destroy();
	    connlist_destroy();
	    fdwatch_close();
	case STATUS_FDWATCH_FAILURE:
	    anongame_matchlists_destroy();
	case STATUS_MATCHLISTS_FAILURE:
	    anongame_maplists_destroy();
	case STATUS_MAPLISTS_FAILURE:
	case STATUS_SUPPORT_FAILURE:
	    if (psock_deinit())
		eventlog(eventlog_level_error, __FUNCTION__, "got error from psock_deinit()");
	case STATUS_PSOCK_FAILURE:
	    storage_close();
	case STATUS_STORAGE_FAILURE:
	    oom_free();
	case STATUS_OOM_FAILURE:
	case -1:
	    break;
	default:
	    eventlog(eventlog_level_error,__FUNCTION__,"got bad status \"%d\" during shutdown",status);
    }
    return;
}    
Esempio n. 2
0
	extern int fdwatch_init(int maxcons)
	{
		unsigned i;
		int maxsys;

		maxsys = get_socket_limit();
		if (maxsys > 0) maxcons = (maxcons < maxsys) ? maxcons : maxsys;
		if (maxcons < 32) {
			eventlog(eventlog_level_fatal, __FUNCTION__, "too few sockets available ({})", maxcons);
			return -1;
		}
		fdw_maxcons = maxcons;

		fdw_fds = new t_fdwatch_fd[fdw_maxcons];
		/* add all slots to the freelist */
		for (i = 0; i < fdw_maxcons; i++)
			freelist.push_back(fdw_fds[i]);

#ifdef HAVE_EPOLL
		try {
			fdw = new FDWEpollBackend(fdw_maxcons);
			return 0;
		}
		catch (const FDWBackend::InitError&) {
		}
#endif
#ifdef HAVE_KQUEUE
		try {
			fdw = new FDWKqueueBackend(fdw_maxcons);
			return 0;
		}
		catch (const FDWBackend::InitError&) {
		}
#endif
#ifdef HAVE_POLL
		try {
			fdw = new FDWPollBackend(fdw_maxcons);
			return 0;
		}
		catch (const FDWBackend::InitError&) {
		}
#endif
#ifdef HAVE_SELECT
		try {
			fdw = new FDWSelectBackend(fdw_maxcons);
			return 0;
		}
		catch (const FDWBackend::InitError&) {
		}
#endif

		eventlog(eventlog_level_fatal, __FUNCTION__, "Found no working fdwatch layer");
		fdw = NULL;
		fdwatch_close();
		return -1;
	}