| 142 | } |
| 143 | |
| 144 | int stream::get_rw_timeout(bool use_sockopt /* false */) const |
| 145 | { |
| 146 | if (stream_ == NULL) { |
| 147 | return -1; |
| 148 | } |
| 149 | |
| 150 | if (!use_sockopt) { |
| 151 | return stream_->rw_timeout; |
| 152 | } |
| 153 | |
| 154 | ACL_SOCKET fd = ACL_VSTREAM_SOCK(stream_); |
| 155 | |
| 156 | # if defined(_WIN32) || defined(_WIN64) |
| 157 | int timeout = 0, len = sizeof(timeout); |
| 158 | if (getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char*) &timeout, &len) < 0) { |
| 159 | logger_error("getsockopt SO_RCVTIMEO error=%s, fd=%d", |
| 160 | last_serror(), (int) fd); |
| 161 | return -1; |
| 162 | } |
| 163 | return timeout / 1000; |
| 164 | # else |
| 165 | struct timeval tm; |
| 166 | memset(&tm, 0, sizeof(tm)); |
| 167 | socklen_t len = sizeof(tm); |
| 168 | |
| 169 | if (getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tm, &len) < 0) { |
| 170 | logger_error("getsockopt SO_RCVTIMEO error=%s, fd=%d", |
| 171 | last_serror(), (int) fd); |
| 172 | return -1; |
| 173 | } |
| 174 | |
| 175 | return (int) tm.tv_sec; |
| 176 | # endif |
| 177 | } |
| 178 | |
| 179 | ACL_VSTREAM* stream::unbind() |
| 180 | { |
no test coverage detected