All pastes #247901 Raw Edit

Someone

public text v1 · immutable
#247901 ·published 2006-11-13 23:42 UTC
rendered paste body
/************************************************************************************************************************************
 *Save server data (query info)
 *  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;
}