| 372 | }; |
| 373 | |
| 374 | void TNonblockingServer::TConnection::init(TNonblockingIOThread* ioThread) { |
| 375 | ioThread_ = ioThread; |
| 376 | server_ = ioThread->getServer(); |
| 377 | appState_ = APP_INIT; |
| 378 | eventFlags_ = 0; |
| 379 | |
| 380 | readBufferPos_ = 0; |
| 381 | readWant_ = 0; |
| 382 | |
| 383 | writeBuffer_ = nullptr; |
| 384 | writeBufferSize_ = 0; |
| 385 | writeBufferPos_ = 0; |
| 386 | largestWriteBufferSize_ = 0; |
| 387 | |
| 388 | socketState_ = SOCKET_RECV_FRAMING; |
| 389 | callsForResize_ = 0; |
| 390 | |
| 391 | // get input/transports |
| 392 | factoryInputTransport_ = server_->getInputTransportFactory()->getTransport(inputTransport_); |
| 393 | factoryOutputTransport_ = server_->getOutputTransportFactory()->getTransport(outputTransport_); |
| 394 | |
| 395 | // Create protocol |
| 396 | if (server_->getHeaderTransport()) { |
| 397 | inputProtocol_ = server_->getInputProtocolFactory()->getProtocol(factoryInputTransport_, |
| 398 | factoryOutputTransport_); |
| 399 | outputProtocol_ = inputProtocol_; |
| 400 | } else { |
| 401 | inputProtocol_ = server_->getInputProtocolFactory()->getProtocol(factoryInputTransport_); |
| 402 | outputProtocol_ = server_->getOutputProtocolFactory()->getProtocol(factoryOutputTransport_); |
| 403 | } |
| 404 | |
| 405 | // Set up for any server event handler |
| 406 | serverEventHandler_ = server_->getEventHandler(); |
| 407 | if (serverEventHandler_) { |
| 408 | connectionContext_ = serverEventHandler_->createContext(inputProtocol_, outputProtocol_); |
| 409 | } else { |
| 410 | connectionContext_ = nullptr; |
| 411 | } |
| 412 | |
| 413 | // Get the processor |
| 414 | processor_ = server_->getProcessor(inputProtocol_, outputProtocol_, tSocket_); |
| 415 | } |
| 416 | |
| 417 | void TNonblockingServer::TConnection::setSocket(std::shared_ptr<TSocket> socket) { |
| 418 | tSocket_ = socket; |
no test coverage detected