git.samba.org
/
ira
/
wip.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e9010fa
)
tsocket: allow empty vectors at the end for tstream_writev()/readv()
author
Stefan Metzmacher
<metze@samba.org>
Fri, 22 May 2009 10:28:17 +0000
(12:28 +0200)
committer
Stefan Metzmacher
<metze@samba.org>
Fri, 22 May 2009 12:01:22 +0000
(14:01 +0200)
metze
lib/tsocket/tsocket_bsd.c
patch
|
blob
|
history
diff --git
a/lib/tsocket/tsocket_bsd.c
b/lib/tsocket/tsocket_bsd.c
index 8f5f009d4c136332bc75fc3b8b701943bdd677fd..a4cbda8b8378d8b28434c98e13a265a9b8a75df8 100644
(file)
--- 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;
}
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;
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;
}
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;
if (state->count > 0) {
/* we have more to read */
return;