summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/tsocket/tsocket_bsd.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/tsocket/tsocket_bsd.c b/lib/tsocket/tsocket_bsd.c
index 8f5f009d4c..a4cbda8b83 100644
--- a/lib/tsocket/tsocket_bsd.c
+++ b/lib/tsocket/tsocket_bsd.c
@@ -1538,6 +1538,19 @@ static void tstream_bsd_readv_handler(void *private_data)
state->count -= 1;
}
+ /*
+ * there're maybe some empty vectors at the end
+ * which we need to skip, otherwise we would get
+ * ret == 0 from the readv() call and return EPIPE
+ */
+ while (state->count > 0) {
+ if (state->vector[0].iov_len > 0) {
+ break;
+ }
+ state->vector += 1;
+ state->count -= 1;
+ }
+
if (state->count > 0) {
/* we have more to read */
return;
@@ -1685,6 +1698,19 @@ static void tstream_bsd_writev_handler(void *private_data)
state->count -= 1;
}
+ /*
+ * there're maybe some empty vectors at the end
+ * which we need to skip, otherwise we would get
+ * ret == 0 from the writev() call and return EPIPE
+ */
+ while (state->count > 0) {
+ if (state->vector[0].iov_len > 0) {
+ break;
+ }
+ state->vector += 1;
+ state->count -= 1;
+ }
+
if (state->count > 0) {
/* we have more to read */
return;