int32_t super_processpacket(msgdisp_t disp,rpacket_t rpk) { uint16_t cmd = rpk_peek_uint16(rpk); if(cmd >= CMD_C2GAME && cmd <= CMD_C2GAME_END) { if(cmd > CMD_C2BATTLE && cmd < CMD_C2BATTLE_END) { //将消息转发到battleservice uint8_t battleserid = reverse_read_uint8(rpk); battleservice_t battle = get_battle_by_index(battleserid); if(battle && 0 == send_msg(NULL,battle->msgdisp,(msg_t)rpk)) return 0;//不销毁rpk,由battleservice负责销毁*/ }else{ ident _ident= reverse_read_ident(rpk); player_t ply = (player_t)cast_2_refbase(_ident); if(ply && ply->_status == normal){ if(super_cmd_handlers[cmd]){ rpk_read_uint16(rpk);//丢弃cmd call_handler(super_cmd_handlers[cmd],rpk,ply); }else{ SYS_LOG(LOG_INFO,"unknow cmd:%d\n",cmd); } } if(ply) ref_decrease((struct refbase*)ply); } } return 1; }
void buffer_release(buffer_t *b) { if(*b) { ref_decrease(&(*b)->_refbase); *b = 0; } }
void delete_per_thread_que(void *arg) { #ifdef MQ_HEART_BEAT block_sigusr1(); #endif ptq_t ptq = (ptq_t)arg; if(ptq->mode == MSGQ_WRITE){ dlist_remove(&ptq->write_que.pnode); } //销毁local_que中所有消息 lnode *n; if(ptq->destroy_function){ while((n = LLIST_POP(lnode*,&ptq->local_que))!=NULL) ptq->destroy_function((void*)n); } condition_destroy(&ptq->cond); ref_decrease(&ptq->que->refbase); free(ptq); #ifdef MQ_HEART_BEAT unblock_sigusr1(); #endif printf("delete_per_thread_que\n"); }
void release_socket_wrapper(SOCK s) { struct socket_wrapper *sw = (struct socket_wrapper *)s; ref_decrease(&sw->ref); }
void release_conn(struct connection *con){ ref_decrease((struct refbase *)con); }