All pastes #247911 Raw Edit

Untitled

public text v1 · immutable
#247911 ·published 2006-11-13 23:56 UTC
rendered paste body
/************************************************************************************************************************************
 * FUNCTION
 *      Save server data (query info)
 *
 * INPUTS
 *      ipl     = long representation of ip
 *      port    = query port
 *      engine  = engine id
 *      flag    = query flags (optional)
 *      sql     = sql connection to use (optional, better to use an allocated connection then grabbing from the pool)
 *
 * RETURNS
 *      >0      = server id
 *      -1      = unable to save server (exists already?)
 *      -2      = should never happen (since the id is new in the db)
 */
int threadhub::saveNewServer(unsigned ipl, unsigned short int port, int engine, int flag=GM_DEFAULT_QUERY_FLAGS, sql_p *sql=NULL) {
        int ret=-1;
        bool sql_allocated=false;
        if (sql==NULL) {
                sql = _sql_cs.allocItem();
                sql_allocated = true;
        }

        ret = sql->save_new_server(ipl,port,engine,flag);
        if ( ret>0 ) {
                if ( !this->allocateID(ret) ) {
                        //nasty
                        ret=-2;
                }
        }

        if (sql_allocated) _sql_cs.freeItem(sql);

        return ret;
}
/************************************************************************************************************************************/