diff mbox series

[ovs-dev] windows: Fix return value in case of named pipe send failure

Message ID 20180430204400.18504-1-aserdean@ovn.org
State Accepted
Headers show
Series [ovs-dev] windows: Fix return value in case of named pipe send failure | expand

Commit Message

Alin-Gabriel Serdean April 30, 2018, 8:44 p.m. UTC
Named pipes should emulate UNIX socket behavior.

Until now the named pipes returned WSA (Windows implementation of BSD sockets
errors) return codes, for send errors.

In case of a disconnected named pipe (UNIX socket) send error, we should return
EPIPE.

Fixes: `check_logs` transient errors when checking for EPIPE.

Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
---
 lib/stream-windows.c | 6 +++---
 tests/test-vconn.c   | 4 ----
 2 files changed, 3 insertions(+), 7 deletions(-)

Comments

Alin Balutoiu May 8, 2018, 2:36 p.m. UTC | #1
Acked-by: Alin Balutoiu <abalutoiu@cloudbasesolutions.com>

> -----Original Message-----
> From: ovs-dev-bounces@openvswitch.org <ovs-dev-
> bounces@openvswitch.org> On Behalf Of Alin Gabriel Serdean
> Sent: Monday, April 30, 2018 11:44 PM
> To: dev@openvswitch.org
> Cc: Alin Gabriel Serdean <aserdean@ovn.org>
> Subject: [ovs-dev] [PATCH] windows: Fix return value in case of named pipe send
> failure
> 
> Named pipes should emulate UNIX socket behavior.
> 
> Until now the named pipes returned WSA (Windows implementation of BSD
> sockets
> errors) return codes, for send errors.
> 
> In case of a disconnected named pipe (UNIX socket) send error, we should
> return EPIPE.
> 
> Fixes: `check_logs` transient errors when checking for EPIPE.
> 
> Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
> ---
>  lib/stream-windows.c | 6 +++---
>  tests/test-vconn.c   | 4 ----
>  2 files changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/stream-windows.c b/lib/stream-windows.c index
> d908ee972..34bc610b6 100644
> --- a/lib/stream-windows.c
> +++ b/lib/stream-windows.c
> @@ -308,7 +308,7 @@ windows_send(struct stream *stream, const void
> *buffer, size_t n)
>                         || last_error == ERROR_NO_DATA
>                         || last_error == ERROR_BROKEN_PIPE) {
>                  /* If the pipe was disconnected, return connection reset. */
> -                return -WSAECONNRESET;
> +                return -EPIPE;
>              } else {
>                  VLOG_ERR_RL(&rl, "Could not send data on named pipe. Last "
>                              "error: %s", ovs_lasterror_to_string()); @@ -321,7 +321,7 @@
> windows_send(struct stream *stream, const void *buffer, size_t n)
> 
>      result = WriteFile(s->fd, buffer, n, &(DWORD)retval, ov);
>      last_error = GetLastError();
> -    if (!result && GetLastError() == ERROR_IO_PENDING) {
> +    if (!result && last_error == ERROR_IO_PENDING) {
>          /* Mark the send operation as pending. */
>          s->write_pending = true;
>          return -EAGAIN;
> @@ -330,7 +330,7 @@ windows_send(struct stream *stream, const void
> *buffer, size_t n)
>                             || last_error == ERROR_NO_DATA
>                             || last_error == ERROR_BROKEN_PIPE)) {
>          /* If the pipe was disconnected, return connection reset. */
> -        return -WSAECONNRESET;
> +        return -EPIPE;
>      } else if (!result) {
>          VLOG_ERR_RL(&rl, "Could not send data on synchronous named pipe. Last
> "
>                      "error: %s", ovs_lasterror_to_string()); diff --git a/tests/test-vconn.c
> b/tests/test-vconn.c index 0c17a8395..8b8d12e36 100644
> --- a/tests/test-vconn.c
> +++ b/tests/test-vconn.c
> @@ -163,11 +163,7 @@ test_refuse_connection(struct ovs_cmdl_context *ctx)
>                        error, ovs_strerror(error));
>          }
>      } else if (!strcmp(type, "unix")) { -#ifndef _WIN32
>          CHECK_ERRNO(error, EPIPE);
> -#else
> -        CHECK_ERRNO(error, WSAECONNRESET);
> -#endif
>      } else if (!strcmp(type, "ssl")) {
>          if (error != EPROTO && error != ECONNRESET) {
>              ovs_fatal(0, "unexpected vconn_connect() return value %d (%s)",
> --
> 2.16.1.windows.1
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
Ben Pfaff May 8, 2018, 3:27 p.m. UTC | #2
On Mon, Apr 30, 2018 at 11:44:00PM +0300, Alin Gabriel Serdean wrote:
> Named pipes should emulate UNIX socket behavior.
> 
> Until now the named pipes returned WSA (Windows implementation of BSD sockets
> errors) return codes, for send errors.
> 
> In case of a disconnected named pipe (UNIX socket) send error, we should return
> EPIPE.
> 
> Fixes: `check_logs` transient errors when checking for EPIPE.
> 
> Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>

Acked-by: Ben Pfaff <blp@ovn.org>
Alin-Gabriel Serdean May 8, 2018, 3:33 p.m. UTC | #3
> On 8 May 2018, at 18:27, Ben Pfaff <blp@ovn.org> wrote:
> 
> On Mon, Apr 30, 2018 at 11:44:00PM +0300, Alin Gabriel Serdean wrote:
>> Named pipes should emulate UNIX socket behavior.
>> 
>> Until now the named pipes returned WSA (Windows implementation of BSD sockets
>> errors) return codes, for send errors.
>> 
>> In case of a disconnected named pipe (UNIX socket) send error, we should return
>> EPIPE.
>> 
>> Fixes: `check_logs` transient errors when checking for EPIPE.
>> 
>> Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
> 
> Acked-by: Ben Pfaff <blp@ovn.org>
> ______________________________________________

Thanks Alin and Ben, I applied it on master.
diff mbox series

Patch

diff --git a/lib/stream-windows.c b/lib/stream-windows.c
index d908ee972..34bc610b6 100644
--- a/lib/stream-windows.c
+++ b/lib/stream-windows.c
@@ -308,7 +308,7 @@  windows_send(struct stream *stream, const void *buffer, size_t n)
                        || last_error == ERROR_NO_DATA
                        || last_error == ERROR_BROKEN_PIPE) {
                 /* If the pipe was disconnected, return connection reset. */
-                return -WSAECONNRESET;
+                return -EPIPE;
             } else {
                 VLOG_ERR_RL(&rl, "Could not send data on named pipe. Last "
                             "error: %s", ovs_lasterror_to_string());
@@ -321,7 +321,7 @@  windows_send(struct stream *stream, const void *buffer, size_t n)
 
     result = WriteFile(s->fd, buffer, n, &(DWORD)retval, ov);
     last_error = GetLastError();
-    if (!result && GetLastError() == ERROR_IO_PENDING) {
+    if (!result && last_error == ERROR_IO_PENDING) {
         /* Mark the send operation as pending. */
         s->write_pending = true;
         return -EAGAIN;
@@ -330,7 +330,7 @@  windows_send(struct stream *stream, const void *buffer, size_t n)
                            || last_error == ERROR_NO_DATA
                            || last_error == ERROR_BROKEN_PIPE)) {
         /* If the pipe was disconnected, return connection reset. */
-        return -WSAECONNRESET;
+        return -EPIPE;
     } else if (!result) {
         VLOG_ERR_RL(&rl, "Could not send data on synchronous named pipe. Last "
                     "error: %s", ovs_lasterror_to_string());
diff --git a/tests/test-vconn.c b/tests/test-vconn.c
index 0c17a8395..8b8d12e36 100644
--- a/tests/test-vconn.c
+++ b/tests/test-vconn.c
@@ -163,11 +163,7 @@  test_refuse_connection(struct ovs_cmdl_context *ctx)
                       error, ovs_strerror(error));
         }
     } else if (!strcmp(type, "unix")) {
-#ifndef _WIN32
         CHECK_ERRNO(error, EPIPE);
-#else
-        CHECK_ERRNO(error, WSAECONNRESET);
-#endif
     } else if (!strcmp(type, "ssl")) {
         if (error != EPROTO && error != ECONNRESET) {
             ovs_fatal(0, "unexpected vconn_connect() return value %d (%s)",