| 156 | } |
| 157 | |
| 158 | bool TNonblockingServerSocket::isOpen() const { |
| 159 | if (serverSocket_ == THRIFT_INVALID_SOCKET) |
| 160 | return false; |
| 161 | |
| 162 | if (!listening_) |
| 163 | return false; |
| 164 | |
| 165 | if (isUnixDomainSocket() && (path_[0] != '\0')) { |
| 166 | // On some platforms the domain socket file may not be instantly |
| 167 | // available yet, i.e. the Windows file system can be slow. Therefore |
| 168 | // we should check that the domain socket file actually exists. |
| 169 | #ifdef _MSC_VER |
| 170 | // Currently there is a bug in ClangCl on Windows so the stat() call |
| 171 | // does not work. Workaround is a Windows-specific call if file exists: |
| 172 | DWORD const f_attrib = GetFileAttributesA(path_.c_str()); |
| 173 | if (f_attrib == INVALID_FILE_ATTRIBUTES) { |
| 174 | #else |
| 175 | struct THRIFT_STAT path_info; |
| 176 | if (::THRIFT_STAT(path_.c_str(), &path_info) < 0) { |
| 177 | #endif |
| 178 | const std::string vError = "TNonblockingServerSocket::isOpen(): The domain socket path '" + path_ + "' does not exist (yet)."; |
| 179 | TOutput::instance().perror(vError.c_str(), THRIFT_GET_SOCKET_ERROR); |
| 180 | return false; |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | return true; |
| 185 | } |
| 186 | |
| 187 | void TNonblockingServerSocket::setSendTimeout(int sendTimeout) { |
| 188 | sendTimeout_ = sendTimeout; |
| 189 | } |
| 190 | |
| 191 | void TNonblockingServerSocket::setRecvTimeout(int recvTimeout) { |
| 192 | recvTimeout_ = recvTimeout; |
| 193 | } |
| 194 | |
| 195 | void TNonblockingServerSocket::setAcceptBacklog(int accBacklog) { |
| 196 | acceptBacklog_ = accBacklog; |
| 197 | } |
| 198 | |
| 199 | void TNonblockingServerSocket::setRetryLimit(int retryLimit) { |
| 200 | retryLimit_ = retryLimit; |
| 201 | } |
| 202 | |
| 203 | void TNonblockingServerSocket::setRetryDelay(int retryDelay) { |
| 204 | retryDelay_ = retryDelay; |
| 205 | } |
| 206 | |
| 207 | void TNonblockingServerSocket::setTcpSendBuffer(int tcpSendBuffer) { |
| 208 | tcpSendBuffer_ = tcpSendBuffer; |
| 209 | } |
| 210 | |
| 211 | void TNonblockingServerSocket::setTcpRecvBuffer(int tcpRecvBuffer) { |
| 212 | tcpRecvBuffer_ = tcpRecvBuffer; |
| 213 | } |
| 214 | |
| 215 | void TNonblockingServerSocket::_setup_sockopts() { |
nothing calls this directly
no test coverage detected