summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2009-05-22 12:28:17 +0200
committerStefan Metzmacher <metze@samba.org>2009-05-22 14:01:22 +0200
commitedd9bd9b167cb04290b06eb9b209c21ad5a884a0 (patch)
tree375fe485ff4f697c2e7aea376f2ddc3567bf571c
parente9010fa366746ec1ae948dbcf3493d446e23b14c (diff)
downloadsamba-edd9bd9b167cb04290b06eb9b209c21ad5a884a0.tar.gz
samba-edd9bd9b167cb04290b06eb9b209c21ad5a884a0.tar.bz2
samba-edd9bd9b167cb04290b06eb9b209c21ad5a884a0.zip
tsocket: allow empty vectors at the end for tstream_writev()/readv()
metze
-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;