| 294 | return ret; |
| 295 | } |
| 296 | int response_sender(iovector* resp) |
| 297 | { |
| 298 | assert(w_lock); |
| 299 | Header h; |
| 300 | h.size = (uint32_t)resp->sum(); |
| 301 | h.function = header.function; |
| 302 | h.tag = header.tag; |
| 303 | h.reserved = 0; |
| 304 | resp->push_front(&h, sizeof(h)); |
| 305 | if (stream == nullptr) |
| 306 | LOG_ERRNO_RETURN(0, -1, "socket closed "); |
| 307 | |
| 308 | w_lock->lock(); |
| 309 | ssize_t ret = stream->writev(resp->iovec(), resp->iovcnt()); |
| 310 | w_lock->unlock(); |
| 311 | |
| 312 | if (ret < (ssize_t)(sizeof(h) + h.size)) { |
| 313 | stream->shutdown(ShutdownHow::ReadWrite); |
| 314 | LOG_ERRNO_RETURN(0, -1, "failed to send rpc response to stream ", stream); |
| 315 | } |
| 316 | return 0; |
| 317 | } |
| 318 | }; |
| 319 | condition_variable m_cond_served; |
| 320 | struct ThreadLink : public intrusive_list_node<ThreadLink> |