Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-5399

Fix socket leak in abnormal situation

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 0.13.0, 0.14.0, 0.14.1
    • Fix Version/s: 0.15.0
    • Component/s: C glib - Library
    • Labels:
      None

      Description

      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. }

       ......

       

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                lm2048 liumin
                Reporter:
                lm2048 liumin
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 10m
                  1h 10m