int ObTbnetCallback::shadow_process(easy_request_t* r) { int ret = EASY_OK; if (NULL == r || NULL == r->ipacket) { TBSYS_LOG(ERROR, "request is empty, r = %p, r->ipacket = %p", r, r->ipacket); ret = EASY_BREAK; } else { ObShadowServer *server = (ObShadowServer*)r->ms->c->handler->user_data; ObPacket *req = (ObPacket*) r->ipacket; req->set_request(r); ret = server->handlePacket(req); if (OB_SUCCESS == ret) { r->ms->c->pool->ref++; easy_atomic_inc(&r->ms->pool->ref); easy_pool_set_lock(r->ms->pool); ret = EASY_AGAIN; } else { ret = EASY_OK; TBSYS_LOG(WARN, "can not push packet(src is %s, pcode is %u) to packet queue", inet_ntoa_r(r->ms->c->addr), req->get_packet_code()); } } return ret; }
int ObProxyCallback::process(easy_request_t *r) { int ret = EASY_OK; if (NULL == r) { TBSYS_LOG(WARN, "request is NULL, r = %p", r); ret = EASY_BREAK; } else if (NULL == r->ipacket) { TBSYS_LOG(WARN, "request is NULL, r->ipacket = %p", r->ipacket); ret = EASY_BREAK; } else { ObProxyServer* server = (ObProxyServer*)r->ms->c->handler->user_data; ObPacket* packet = (ObPacket*)r->ipacket; packet->set_request(r); //handle_request will send response if (OB_REQUIRE_HEARTBEAT == packet->get_packet_code()) { server->handle_request(packet); ret = EASY_OK; } else { ret = server->handlePacket(packet); if (OB_SUCCESS == ret) { r->ms->c->pool->ref++; easy_atomic_inc(&r->ms->pool->ref); easy_pool_set_lock(r->ms->pool); ret = EASY_AGAIN; } else { ret = EASY_OK; TBSYS_LOG(WARN, "can not push packet(src is %s, pcode is %u) to packet queue", inet_ntoa_r(r->ms->c->addr), packet->get_packet_code()); } } } return ret; }
int ObUpdateCallback::process(easy_request_t* r) { int ret = EASY_OK; if (NULL == r) { TBSYS_LOG(ERROR, "request is empty, r = %p", r); ret = EASY_BREAK; } else if (NULL == r->ipacket) { TBSYS_LOG(ERROR, "request is empty, r->ipacket = %p", r->ipacket); ret = EASY_BREAK; } else { ObUpdateServer *server = reinterpret_cast<ObUpdateServer*>(r->ms->c->handler->user_data); ObPacket *req = reinterpret_cast<ObPacket*>(r->ipacket); req->set_request(r); r->ms->c->pool->ref ++; easy_atomic_inc(&r->ms->pool->ref); easy_pool_set_lock(r->ms->pool); ret = server->handlePacket(req); if (OB_SUCCESS == ret) { // enqueue success ret = EASY_AGAIN; } else if (OB_ENQUEUE_FAILED == ret) { TBSYS_LOG(WARN, "can not push packet(src is %s, pcode is %u) to packet queue", inet_ntoa_r(r->ms->c->addr), req->get_packet_code()); r->ms->c->pool->ref --; easy_atomic_dec(&r->ms->pool->ref); ret = EASY_OK; } else /* OB_ERROR */ { ret = EASY_AGAIN; } } return ret; }
int CMysqlCallback::process(easy_request_t* r) { cout<<"在CMysqlCallback的process函数中!"<<endl; int ret; easy_pool_set_lock(r->ms->pool); cout<<"----进入handle_packet_queue处理,然后返回CMysqlSPRPacket报文!----待补充"<<endl; CMysqlServer* server = reinterpret_cast<CMysqlServer*>(r->ms->c->handler->user_data); Args *ar=new Args(); ar->cserver=server; ar->r=r; // server->threadpool->Thread_Pool_add(&(server->do_com_query),ar); server->threadpool->add_task(&(server->do_com_query),ar); // -Yu cout<<"put the do_com_query into threadpool! "<<endl; r->ms->c->pool->ref++; easy_atomic_inc(&r->ms->pool->ref); ret=-11; cout<<"return!"<<endl; return ret; }