Skip to contentSkip to conversation

iov: Fix do_send_recv() for MinGW (also fixes a build breakage)

PATCH In review Stefan Weil 5 participants 5 messages Jul 11, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iov: Fix do_send_recv() for MinGW (also fixes a build breakage)

Commit 25e5e4c7 broke compilation for non POSIX hosts (e.g. MinGW) because it partially replaced "ret" by "count".

It also changed the handling of EINTR in a wrong way.

The patch restores the old code for these two changes.

---
 iov.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
iov.c +6 -5
index 7cc08f0..b333061 100644
@@ -114,9 +114,9 @@ do_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, bool do_send)
 #else
     /* else send piece-by-piece */
     /*XXX Note: windows has WSASend() and WSARecv() */
-    unsigned i;
-    size_t count = 0;
-    for (i = 0; i < iov_cnt; ++i) {
+    unsigned i = 0;
+    ssize_t ret = 0;
+    while (i < iov_cnt) {
         ssize_t r = do_send
             ? send(sockfd, iov[i].iov_base, iov[i].iov_len, 0)
             : recv(sockfd, iov[i].iov_base, iov[i].iov_len, 0);
@@ -130,12 +130,13 @@ do_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, bool do_send)
             /* else it is some "other" error,
              * only return if there was no data processed. */
             if (ret == 0) {
-                return -1;
+                ret = -1;
             }
             break;
         }
+        i++;
     }
-    return count;
+    return ret;
 #endif
 }
 
Signature · 1 line
1.7.10
#1 lore raw
Quoted 8 lines · Stefan Weil

Commit 25e5e4c7 broke compilation for non POSIX hosts (e.g. MinGW) because it partially replaced "ret" by "count".

It also changed the handling of EINTR in a wrong way.

The patch restores the old code for these two changes.

Granted, I never _ever_ tested or even compiled this
part. Should have been. Thank you Stefan!

/mjt

#2 lore raw

Am 11.07.2012 07:25, schrieb Michael Tokarev:

Quoted 6 lines · Stefan Weil
Quoted 5 lines

Commit 25e5e4c7 broke compilation for non POSIX hosts (e.g. MinGW) because it partially replaced "ret" by "count".

It also changed the handling of EINTR in a wrong way.

Quoted 8 lines
Quoted 3 lines

The patch restores the old code for these two changes.

Granted, I never _ever_ tested or even compiled this
part. Should have been. Thank you Stefan!

Then I guess you should not have sent a pull request. :-)

Kevin

#3 lore raw

Il 11/07/2012 14:39, Kevin Wolf ha scritto:

Quoted 9 lines

Am 11.07.2012 07:25, schrieb Michael Tokarev:

Quoted 8 lines · Stefan Weil
Quoted 7 lines

Commit 25e5e4c7 broke compilation for non POSIX hosts (e.g. MinGW) because it partially replaced "ret" by "count".

It also changed the handling of EINTR in a wrong way.

The patch restores the old code for these two changes.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Granted, I never _ever_ tested or even compiled this
part. Should have been. Thank you Stefan!

Then I guess you should not have sent a pull request. :-)

Not that Anthony would have tested mingw...

Paolo

#4 lore raw
Quoted 12 lines · Paolo Bonzini

Il 11/07/2012 14:39, Kevin Wolf ha scritto:

Quoted 11 lines

Am 11.07.2012 07:25, schrieb Michael Tokarev:

Quoted 10 lines · Stefan Weil
Quoted 8 lines

Commit 25e5e4c7 broke compilation for non POSIX hosts (e.g. MinGW) because it partially replaced "ret" by "count".

It also changed the handling of EINTR in a wrong way.

The patch restores the old code for these two changes.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Granted, I never _ever_ tested or even compiled this
part. Should have been. Thank you Stefan!

Then I guess you should not have sent a pull request. :-)

Not that Anthony would have tested mingw...

Nope. It's not efficient to rely on the maintainer to do your testing for you.
If you modify code in a non-trivial way, you should attempt to test it.

Anyway, I'll apply this patch ASAP.

Regards,

Anthony Liguori

Quoted 4 lines

Paolo