| 48 | TConnectedClient::~TConnectedClient() = default; |
| 49 | |
| 50 | void TConnectedClient::run() { |
| 51 | if (eventHandler_) { |
| 52 | opaqueContext_ = eventHandler_->createContext(inputProtocol_, outputProtocol_); |
| 53 | } |
| 54 | |
| 55 | for (bool done = false; !done;) { |
| 56 | if (eventHandler_) { |
| 57 | eventHandler_->processContext(opaqueContext_, client_); |
| 58 | } |
| 59 | |
| 60 | try { |
| 61 | if (!processor_->process(inputProtocol_, outputProtocol_, opaqueContext_)) { |
| 62 | break; |
| 63 | } |
| 64 | } catch (const TTransportException& ttx) { |
| 65 | switch (ttx.getType()) { |
| 66 | case TTransportException::END_OF_FILE: |
| 67 | case TTransportException::INTERRUPTED: |
| 68 | case TTransportException::TIMED_OUT: |
| 69 | // Client disconnected or was interrupted or did not respond within the receive timeout. |
| 70 | // No logging needed. Done. |
| 71 | done = true; |
| 72 | break; |
| 73 | |
| 74 | default: { |
| 75 | // All other transport exceptions are logged. |
| 76 | // State of connection is unknown. Done. |
| 77 | string errStr = string("TConnectedClient died: ") + ttx.what(); |
| 78 | TOutput::instance()(errStr.c_str()); |
| 79 | done = true; |
| 80 | break; |
| 81 | } |
| 82 | } |
| 83 | } catch (const TException& tex) { |
| 84 | string errStr = string("TConnectedClient processing exception: ") + tex.what(); |
| 85 | TOutput::instance()(errStr.c_str()); |
| 86 | // Disconnect from client, because we could not process the message. |
| 87 | done = true; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | cleanup(); |
| 92 | } |
| 93 | |
| 94 | void TConnectedClient::cleanup() { |
| 95 | if (eventHandler_) { |
nothing calls this directly
no test coverage detected