You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2021/07/09 20:12:48 UTC

[thrift] branch master updated: THRIFT-5421 c_glib:Fix the problem of incorrect setting of errno in some files Client: c_glib Patch: lm2048

This is an automated email from the ASF dual-hosted git repository.

jensg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git


The following commit(s) were added to refs/heads/master by this push:
     new 8bd8230  THRIFT-5421 c_glib:Fix the problem of incorrect setting of errno in some files Client: c_glib Patch: lm2048
8bd8230 is described below

commit 8bd82305cf725a62fff5837e3ad4d18c6391b277
Author: lm2048 <li...@163.com>
AuthorDate: Wed May 26 00:16:53 2021 +0800

    THRIFT-5421 c_glib:Fix the problem of incorrect setting of errno in some files
    Client: c_glib
    Patch: lm2048
---
 lib/c_glib/src/thrift/c_glib/transport/thrift_socket.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/c_glib/src/thrift/c_glib/transport/thrift_socket.c b/lib/c_glib/src/thrift/c_glib/transport/thrift_socket.c
index cc746aa..8d3d09e 100644
--- a/lib/c_glib/src/thrift/c_glib/transport/thrift_socket.c
+++ b/lib/c_glib/src/thrift/c_glib/transport/thrift_socket.c
@@ -127,6 +127,7 @@ thrift_socket_open (ThriftTransport *transport, GError **error)
   struct hostent *hp = NULL;
   struct sockaddr_in pin;
   int err;
+  int errno_copy;
 #if defined(HAVE_GETHOSTBYNAME_R)
   struct hostent he;
   char buf[1024];
@@ -155,10 +156,11 @@ thrift_socket_open (ThriftTransport *transport, GError **error)
     /* open a connection */
     if (connect (tsocket->sd, (struct sockaddr *) &pin, sizeof(pin)) == -1)
     {
+        errno_copy = errno;
         thrift_socket_close(transport, NULL);
         g_set_error (error, THRIFT_TRANSPORT_ERROR, THRIFT_TRANSPORT_ERROR_CONNECT,
                    "failed to connect to path %s: - %s",
-                   tsocket->path, strerror(errno));
+                   tsocket->path, strerror(errno_copy));
       return FALSE;
     }
     return TRUE;
@@ -198,10 +200,11 @@ thrift_socket_open (ThriftTransport *transport, GError **error)
   /* open a connection */
   if (connect (tsocket->sd, (struct sockaddr *) &pin, sizeof(pin)) == -1)
   {
+      errno_copy = errno;
       thrift_socket_close(transport, NULL);
       g_set_error (error, THRIFT_TRANSPORT_ERROR, THRIFT_TRANSPORT_ERROR_CONNECT,
                  "failed to connect to host %s:%d - %s",
-                 tsocket->hostname, tsocket->port, strerror(errno));
+                 tsocket->hostname, tsocket->port, strerror(errno_copy));
     return FALSE;
   }