Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-33572

The SOCK_CLOEXEC detection doesn't work on GNU Hurd

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P5: Not important
    • None
    • 4.8.5
    • Network: Sockets
    • None
    • Operating System: Debian GNU/Hurd unstable/unreleased

    Description

      There is a problem with the SOCK_CLOEXEC detection on GNU Hurd.

      In the file "src/network/socket/qnet_unix_p.h" there is a function named qt_safe_socket:

      https://qt.gitorious.org/qt/qtbase/source/73b88fccedfe3912649d119bedf8490ab6c41812:src/network/socket/qnet_unix_p.h#L93

      There is an #ifdef'ed part that tries to open the socket using the SOCK_CLOEXEC flag first:

      #if defined(SOCK_CLOEXEC) && defined(SOCK_NONBLOCK)
      int newtype = type | SOCK_CLOEXEC;
      if (flags & O_NONBLOCK)
      newtype |= SOCK_NONBLOCK;
      fd = ::socket(domain, newtype, protocol);
      if (fd != -1 || errno != EINVAL)
      return fd;
      #endif

      The "errno != EINVAL" part seems to be there to support older versions of Linux (before 2.6.23).

      So this test ensurs that the function does not return when the kernel doesn't support SOCK_CLOEXEC.

      The GNU Hurd system handles this differently than Linux, it's using EPROTOTYPE instead of EINVAL in this situation. (GNU Hurd doesn't currently have SOCK_CLOEXEC support)

      After patching the test to "if (fd != -1 || !(errno == EINVAL || errno == EPROTOTYPE))" the test is working on GNU Hurd.

      I have discussed this issue on the Debian GNU/Hurd mailing list here:

      http://lists.debian.org/debian-hurd/2013/09/msg00102.html

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            shkearns Shane Kearns
            j_muehlenhoff Jens Mühlenhoff
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes