Get a socket from the underlying TServerSocket / TSSLServerSocket type, then set the keepalive options on the socket before returning it. Note: The THRIFT_SOCKET type on Linux is a standard socket file descriptor.
| 225 | // keepalive options on the socket before returning it. Note: The THRIFT_SOCKET |
| 226 | // type on Linux is a standard socket file descriptor. |
| 227 | std::shared_ptr<apache::thrift::transport::TSocket> createSocket(THRIFT_SOCKET socket) { |
| 228 | std::shared_ptr<apache::thrift::transport::TSocket> tsocket = |
| 229 | ThriftServerSocketType::createSocket(socket); |
| 230 | if (keepalive_enabled_) { |
| 231 | Status status = SetKeepAliveOptionsForSocket(socket, keepalive_probe_period_s_, |
| 232 | keepalive_retry_period_s_, keepalive_retry_count_); |
| 233 | if (!status.ok()) { |
| 234 | throw apache::thrift::transport::TTransportException( |
| 235 | apache::thrift::transport::TTransportException::INTERNAL_ERROR, |
| 236 | status.msg().msg()); |
| 237 | } |
| 238 | } |
| 239 | return tsocket; |
| 240 | } |
| 241 | |
| 242 | private: |
| 243 | bool keepalive_enabled_ = false; |
no test coverage detected