summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorlm2048 <liumin_email@163.com>2021-05-26 00:16:53 +0800
committerJens Geyer <Jens-G@users.noreply.github.com>2021-07-09 22:12:42 +0200
commit8bd82305cf725a62fff5837e3ad4d18c6391b277 (patch)
treec5c983b6285f5264006f174210f42b16b0d0633e /lib
parentc06ab4ccc97942f5956112713a0b3800a15cb6cc (diff)
downloadthrift-8bd82305cf725a62fff5837e3ad4d18c6391b277.tar.gz
THRIFT-5421 c_glib:Fix the problem of incorrect setting of errno in some files
Client: c_glib Patch: lm2048
Diffstat (limited to 'lib')
-rw-r--r--lib/c_glib/src/thrift/c_glib/transport/thrift_socket.c7
1 files 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 cc746aacd..8d3d09e89 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;
}