From: Christopher Dykes Date: Mon, 31 Oct 2016 18:59:37 +0000 (-0700) Subject: In the portability implementation of sendmsg return a partial message send if it... X-Git-Tag: v2016.11.07.00~27 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=210b566437cfaf9b5ddeaebe8efddcf456285638;hp=7aa24338827eace3302af2b3fa2d34d262cc99e6;p=folly.git In the portability implementation of sendmsg return a partial message send if it would block Summary: If multiple iovs are passed to sendmsg, sendmsg is supposed to return the number of bytes sent if it would block, but only if the number of bytes sent is greater than 0. Reviewed By: yfeldblum Differential Revision: D4099691 fbshipit-source-id: e58fa71604966129b1fbd418c24b1bf012060428 --- diff --git a/folly/portability/Sockets.cpp b/folly/portability/Sockets.cpp index 14f31fd0..5af38750 100755 --- a/folly/portability/Sockets.cpp +++ b/folly/portability/Sockets.cpp @@ -338,6 +338,10 @@ ssize_t sendmsg(int s, const struct msghdr* message, int fl) { message->msg_flags); } if (r == -1 || r != message->msg_iov[i].iov_len) { + errno = translate_wsa_error(WSAGetLastError()); + if (WSAGetLastError() == WSAEWOULDBLOCK && bytesSent > 0) { + return bytesSent; + } return -1; } bytesSent += r;