static int 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 { ObFileServer* server = (ObFileServer*)r->ms->c->handler->user_data; ObPacket* packet = (ObPacket*)r->ipacket; packet->set_request(r); r->ms->c->pool->ref++; easy_atomic_inc(&r->ms->pool->ref); easy_pool_set_lock(r->ms->pool); if (OB_REQUIRE_HEARTBEAT == packet->get_packet_code()) { server->handle_request(packet); } else { server->handlePacket(packet); } ret = EASY_AGAIN; } return ret; }
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; }