// 用户发送登陆请求到登陆队列 int user_login( int client_index, const char *szUserName, const char *szPassWord, char *szDeviceID ) { int authid; int queue_tail; char tmpstr[2048]; authid = server_getautuid( client_index ); if( authid < 0 ) return -1; // 锁住写队列缓冲 mmux_lock( g_login_mmux ); queue_tail = g_nLoginQueueTail + 1; if( queue_tail >= MAX_LOGINQUEUENUM ) { queue_tail = 0; } if( g_nLoginQueueHead == queue_tail ) { write_netlog("login queue full"); mmux_unlock( g_login_mmux ); // 通知登录线程得赶紧干活, 都满了啊 mcond_broadcast( g_pthr_login ); return -1; } // 将需要处理的客户放置到登录队列 login_queue[g_nLoginQueueTail].client_index = client_index; login_queue[g_nLoginQueueTail].authid = authid; login_queue[g_nLoginQueueTail].command = USERCMDC_LOGIN; sprintf( login_queue[g_nLoginQueueTail].data, "&v1=%s&v2=%s&v3=%d&v4=%s&v5=%s", szUserName, HttpString( szPassWord, tmpstr ), client_getclientoptype( client_index ), client_getip( client_index ), szDeviceID ); g_nLoginQueueTail = queue_tail; mmux_unlock( g_login_mmux ); // 通知登录线程干活 mcond_broadcast( g_pthr_login ); return 0; }
// 用户锁定账号 int user_lock( int client_index, int authid, i64 player_userid, int lockmin ) { char *ptr; int queue_tail; if( client_index < 0 ) player_userid = actor_getoffline_userid( authid ); if( player_userid < 0 ) return -1; // 锁住写队列缓冲 mmux_lock( g_login_mmux ); queue_tail = g_nLoginQueueTail + 1; if( queue_tail >= MAX_LOGINQUEUENUM ) { queue_tail = 0; } if( g_nLoginQueueHead == queue_tail ) { write_netlog("login queue full"); mmux_unlock( g_login_mmux ); // 通知登录线程得赶紧干活, 都满了啊 mcond_broadcast( g_pthr_login ); return -1; } // 将需要处理的客户放置到登录队列 login_queue[g_nLoginQueueTail].client_index = client_index; login_queue[g_nLoginQueueTail].authid = authid; login_queue[g_nLoginQueueTail].command = USERCMDC_LOCKUSER; ptr = login_queue[g_nLoginQueueTail].data; char tmpBuf[MAX_PATH]; sprintf( login_queue[g_nLoginQueueTail].data, "&v1=%s&v2=%d", lltoa(player_userid,tmpBuf,10), lockmin ); g_nLoginQueueTail = queue_tail; mmux_unlock( g_login_mmux ); // 通知登录线程干活 mcond_broadcast( g_pthr_login ); return 0; }
int main(int argc, char *argv[]) { UNREFERENCED_PARAMETER( argc ); char szConfigFileName[ _MAX_PATH ]; strcpy(szConfigFileName, "CONFIG.DAT"); int hConfigFile = _open(szConfigFileName, O_RDONLY | O_BINARY); if (hConfigFile < 0) { return 1; } _read(hConfigFile, &syscfg, sizeof(configrec)); _close(hConfigFile); std::string arg = argv[1]; std::transform( arg.begin(), arg.end(), arg.begin(), (int(*)(int)) toupper ); if ( arg == "NETLOG" ) { strcpy(net_name, argv[6]); unsigned int sy = atoi(argv[2]); unsigned long sent = atol(argv[3]); unsigned long recd = atol(argv[4]); if (!write_netlog(sy, sent, recd, argv[5])) { return 1; } } if ( arg == "TRIM" ) { strcpy(net_data, argv[2]); trim_log(); } if ( arg == "PURGE" ) { strcpy(net_data, argv[2]); int i = atoi(argv[3]); purge_sent( i ); } if ( arg == "CHUNK" ) { strcpy(net_data, argv[2]); std::string fileName = argv[3]; std::stringstream ss; ss << net_data << "INBOUND\\" << fileName; std::string fullPathName = ss.str(); /* if (!chunk(fullPathName.c_str())) { _unlink(fullPathName.c_str()); } */ if (!chunk((char*)fullPathName.c_str())) { _unlink((char*)fullPathName.c_str()); } } return 0; }