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

getaddrinfo() should not be used for Unix sockets

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 0.14.0
    • C++ - Library
    • None

    Description

      TServerSocket::listen() should not call getaddrinfo() for Unix sockets. The results returned by getaddrinfo() are not used for Unix socket anyway.

      Depending on implementation getaddrinfo() may not support Unix sockets properly. In particular, the glibc implementation treats the Unix socket as a network socket and tries to do a bunch of network related stuff with it:

      2263       0.000074 write(1, "[18] ++ getaddrinfo()\n", 22) = 22 <0.000032>
      2263       0.000095 socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE) = 73 <0.000038>
      2263       0.000080 bind(73, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 0 <0.000034>
      2263       0.000085 getsockname(73, {sa_family=AF_NETLINK, pid=-1643670328, groups=00000000}, [12]) = 0 <0.000026>
      2263       0.000083 gettimeofday({18, 941549}, NULL) = 0 <0.000024>
      2263       0.000081 sendto(73, "\24\0\0\0\26\0\1\3\22\0\0\0\0\0\0\0\0\0\0\0", 20, 0, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 20 <0.000061>
      2263       0.000119 recvmsg(73, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"L\0\0\0\24\0\2\0\22\0\0\0\310\224\7\236\2\10\200\376\1\0\0\0\10\0\1\0\177\0\0\1"..., 4096}], msg_controllen=0, msg_flags=0}, 0) = 76 <0.000041>
      2263       0.000131 recvmsg(73, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"\24\0\0\0\3\0\2\0\22\0\0\0\310\224\7\236\0\0\0\0", 4096}], msg_controllen=0, msg_flags=0}, 0) = 20 <0.000029>
      2263       0.000100 close(73)           = 0 <0.000049>
      2263       0.000101 open("/etc/gai.conf", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) <0.000045>
      2263       0.000102 futex(0xf71e5b50, FUTEX_WAKE_PRIVATE, 2147483647) = 0 <0.000025>
      2263       0.000067 socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP) = -1 EAFNOSUPPORT (Address family not supported by protocol) <0.000167>
      2263       0.000213 socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 73 <0.000034>
      2263       0.000076 connect(73, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("0.0.0.0")}, 16) = 0 <0.000049>
      2263       0.000103 getsockname(73, {sa_family=AF_INET, sin_port=htons(55287), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0 <0.000026>
      2263       0.000085 close(73)           = 0 <0.000040>
      2263       0.000084 gettimeofday({18, 942811}, NULL) = 0 <0.000025>
      2263       0.000074 write(1, "[18] -- getaddrinfo() ret=0\n", 28) = 28 <0.000032>
      

      Attachments

        Issue Links

          Activity

            People

              dmaluka Dmitry Maluka
              dmaluka Dmitry Maluka
              Votes:
              0 Vote for this issue
              Watchers:
              1 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 - 10m
                  10m