[ https://issues.apache.org/jira/browse/THRIFT-5399?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
liumin resolved THRIFT-5399. ---------------------------- Resolution: Fixed > Fix socket leak in abnormal situation > ------------------------------------- > > Key: THRIFT-5399 > URL: https://issues.apache.org/jira/browse/THRIFT-5399 > Project: Thrift > Issue Type: Bug > Components: C glib - Library > Affects Versions: 0.13.0, 0.14.0, 0.14.1 > Reporter: liumin > Priority: Minor > Fix For: 0.15.0 > > Time Spent: 1h 10m > Remaining Estimate: 0h > > In "thrift_server_socket_listen" function, after the socket is created, the > exception branch does not have a close socket. > > gboolean > thrift_server_socket_listen (ThriftServerTransport *transport, GError **error) > { > int enabled = 1; /* for setsockopt() */ > ThriftServerSocket *tsocket = THRIFT_SERVER_SOCKET (transport); > const int socket_domain = tsocket->path ? PF_UNIX : AF_INET; > /* create a socket */ > if ((tsocket->sd = socket (socket_domain, SOCK_STREAM, 0)) == -1) > { > g_set_error (error, THRIFT_SERVER_SOCKET_ERROR, > THRIFT_SERVER_SOCKET_ERROR_SOCKET, > "failed to create socket - %s", strerror (errno)); > return FALSE; > } > if (setsockopt(tsocket->sd, SOL_SOCKET, SO_REUSEADDR, &enabled, > sizeof(enabled)) == -1) > { > g_set_error (error, THRIFT_SERVER_SOCKET_ERROR, > THRIFT_SERVER_SOCKET_ERROR_SETSOCKOPT, > "unable to set SO_REUSEADDR - %s", strerror(errno)); > return FALSE; // -----------> socket leak. > } > ...... > > -- This message was sent by Atlassian Jira (v8.3.4#803005)