| 181 | ::google::protobuf::Closure* done); |
| 182 | |
| 183 | void ProcessMongoRequest(InputMessageBase* msg_base) { |
| 184 | DestroyingPtr<MostCommonMessage> msg(static_cast<MostCommonMessage*>(msg_base)); |
| 185 | SocketUniquePtr socket_guard(msg->ReleaseSocket()); |
| 186 | Socket* socket = socket_guard.get(); |
| 187 | const Server* server = static_cast<const Server*>(msg_base->arg()); |
| 188 | ScopedNonServiceError non_service_error(server); |
| 189 | |
| 190 | char buf[sizeof(mongo_head_t)]; |
| 191 | const char *p = (const char *)msg->meta.fetch(buf, sizeof(buf)); |
| 192 | const mongo_head_t *header = (const mongo_head_t*)p; |
| 193 | |
| 194 | const google::protobuf::ServiceDescriptor* srv_des = MongoService::descriptor(); |
| 195 | if (1 != srv_des->method_count()) { |
| 196 | LOG(WARNING) << "method count:" << srv_des->method_count() |
| 197 | << " of MongoService should be equal to 1!"; |
| 198 | } |
| 199 | |
| 200 | const Server::MethodProperty *mp = |
| 201 | ServerPrivateAccessor(server) |
| 202 | .FindMethodPropertyByFullName(srv_des->method(0)->full_name()); |
| 203 | |
| 204 | MongoContextMessage *context_msg = |
| 205 | dynamic_cast<MongoContextMessage*>(socket->parsing_context()); |
| 206 | if (NULL == context_msg) { |
| 207 | LOG(WARNING) << "socket context wasn't set correctly"; |
| 208 | return; |
| 209 | } |
| 210 | |
| 211 | SendMongoResponse* mongo_done = new SendMongoResponse(server); |
| 212 | mongo_done->cntl.set_mongo_session_data(context_msg->context()); |
| 213 | |
| 214 | ControllerPrivateAccessor accessor(&(mongo_done->cntl)); |
| 215 | accessor.set_server(server) |
| 216 | .set_security_mode(server->options().security_mode()) |
| 217 | .set_peer_id(socket->id()) |
| 218 | .set_remote_side(socket->remote_side()) |
| 219 | .set_local_side(socket->local_side()) |
| 220 | .set_auth_context(socket->auth_context()) |
| 221 | .set_request_protocol(PROTOCOL_MONGO) |
| 222 | .set_begin_time_us(msg->received_us()) |
| 223 | .move_in_server_receiving_sock(socket_guard); |
| 224 | |
| 225 | // Tag the bthread with this server's key for |
| 226 | // thread_local_data(). |
| 227 | if (server->thread_local_options().thread_local_data_factory) { |
| 228 | bthread_assign_data((void*)&server->thread_local_options()); |
| 229 | } |
| 230 | do { |
| 231 | if (!server->IsRunning()) { |
| 232 | mongo_done->cntl.SetFailed(ELOGOFF, "Server is stopping"); |
| 233 | break; |
| 234 | } |
| 235 | |
| 236 | if (!ServerPrivateAccessor(server).AddConcurrency(&(mongo_done->cntl))) { |
| 237 | mongo_done->cntl.SetFailed( |
| 238 | ELIMIT, "Reached server's max_concurrency=%d", |
| 239 | server->options().max_concurrency); |
| 240 | break; |
nothing calls this directly
no test coverage detected