Samuel Thibault, on Sun 03 Jan 2016 02:57:31 +0100, wrote: > Luca Boccassi, on Sat 10 Oct 2015 13:07:26 +0100, wrote: > > <svante.sign...@gmail.com> wrote: > > > Two tests fails causing ssh to hang and crashes a translator in a > > > hurd terminal: test_pair_ipc and test_reqrep_ipc. Partial problems > > > with these tests are that option SO_ERROR is not yet supported for > > > gsetsockopt() on Hurd. > > > > The problem is that SO_ERROR is used by ZMQ to check the status of an > > asynchronous socket connect() [1]. > > To be more precise, SO_ERROR is completely supported for TCP/IP sockets. > It is not supported for local sockets only. But this shouldn't be a > problem for zeromq at all since local sockets always either connect > immediately without blocking, or get a refused connection.
Put another way, I believe the attached patch is right: if the implementation does not support SO_ERROR, then it means it does not support asynchronous connect and there is no error to read, so assume success. With that change, the testsuite passes completely without any issue. We can also make hurd's local sockets always return 0 from SO_ERROR since it doesn't have asynchronous connects. Samuel
Index: zeromq3-4.0.5+dfsg/configure.ac =================================================================== --- zeromq3-4.0.5+dfsg.orig/configure.ac +++ zeromq3-4.0.5+dfsg/configure.ac @@ -115,6 +115,7 @@ libzmq_dso_visibility="yes" libzmq_on_mingw32="no" libzmq_on_android="no" libzmq_on_linux="no" +libzmq_on_gnu="no" # Set some default features required by 0MQ code. CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE $CPPFLAGS" @@ -122,6 +123,20 @@ CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE $C # For host type checks AC_CANONICAL_HOST +#For a working getsockopt() optname=SO_ERROR +dnl AC_MSG_CHECKING([for getsockopt optname SO_ERROR)]) +dnl AC_TRY_COMPILE([ +dnl #include <sys/types.h> +dnl #include <sys/socket.h> +dnl ], [socklen_t t;], ac_cv_type_socklen_t=yes, ac_cv_type_socklen_t=no) +dnl if test "x$ac_cv_type_socklen_t" = "xyes"; then +dnl AC_MSG_RESULT([yes]) +dnl AC_DEFINE(HAVE_SOCKLEN_T,1, +dnl [Define if socklen_t is available]) +dnl else +dnl AC_MSG_RESULT([no]) +dnl fi + # OS-specific tests case "${host_os}" in *linux*) @@ -249,6 +264,17 @@ case "${host_os}" in AC_MSG_ERROR([Building static libraries is not supported under Cygwin]) fi ;; + gnu*) + # Define on GNU/Hurd to enable all library features. Define if using a gnu compiler + if test "x$GXX" = "xyes"; then + CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS" + fi + AC_DEFINE(ZMQ_HAVE_GNU, 1, [Have GNU/Hurd OS]) + libzmq_on_gnu="yes" + AC_CHECK_LIB(rt, sem_init) +dnl AC_CHECK_LIB(uuid, uuid_generate, , +dnl [AC_MSG_ERROR([cannot link with -luuid, install uuid-dev.])]) + ;; *) AC_MSG_ERROR([unsupported system: ${host_os}.]) ;; @@ -431,6 +457,7 @@ AM_CONDITIONAL(BUILD_PGM, test "x$libzmq AM_CONDITIONAL(ON_MINGW, test "x$libzmq_on_mingw32" = "xyes") AM_CONDITIONAL(ON_ANDROID, test "x$libzmq_on_android" = "xyes") AM_CONDITIONAL(ON_LINUX, test "x$libzmq_on_linux" = "xyes") +AM_CONDITIONAL(ON_GNU, test "x$libzmq_on_gnu" = "xyes") # Checks for library functions. AC_TYPE_SIGNAL Index: zeromq3-4.0.5+dfsg/src/poller.hpp =================================================================== --- zeromq3-4.0.5+dfsg.orig/src/poller.hpp +++ zeromq3-4.0.5+dfsg/src/poller.hpp @@ -73,6 +73,13 @@ #elif defined ZMQ_HAVE_CYGWIN #define ZMQ_USE_SELECT #include "select.hpp" +#elif defined ZMQ_HAVE_GNU +#define ZMQ_USE_SELECT +#include "select.hpp" +#if 0 +#define ZMQ_USE_POLL +#include "poll.hpp" +#endif #else #error Unsupported platform #endif Index: zeromq3-4.0.5+dfsg/src/ipc_connecter.cpp =================================================================== --- zeromq3-4.0.5+dfsg.orig/src/ipc_connecter.cpp +++ zeromq3-4.0.5+dfsg/src/ipc_connecter.cpp @@ -242,8 +242,11 @@ zmq::fd_t zmq::ipc_connecter_t::connect socklen_t len = sizeof (err); #endif int rc = getsockopt (s, SOL_SOCKET, SO_ERROR, (char*) &err, &len); - if (rc == -1) + if (rc == -1) { + if (errno == ENOPROTOOPT) + errno = 0; err = errno; + } if (err != 0) { // Assert if the error was caused by 0MQ bug. Index: zeromq3-4.0.5+dfsg/src/zmq.cpp =================================================================== --- zeromq3-4.0.5+dfsg.orig/src/zmq.cpp +++ zeromq3-4.0.5+dfsg/src/zmq.cpp @@ -28,7 +28,7 @@ defined ZMQ_HAVE_OPENBSD || defined ZMQ_HAVE_SOLARIS ||\ defined ZMQ_HAVE_OSX || defined ZMQ_HAVE_QNXNTO ||\ defined ZMQ_HAVE_HPUX || defined ZMQ_HAVE_AIX ||\ - defined ZMQ_HAVE_NETBSD + defined ZMQ_HAVE_NETBSD || defined ZMQ_HAVE_GNU #define ZMQ_POLL_BASED_ON_POLL #elif defined ZMQ_HAVE_WINDOWS || defined ZMQ_HAVE_OPENVMS ||\ defined ZMQ_HAVE_CYGWIN Index: zeromq3-4.0.5+dfsg/src/proxy.cpp =================================================================== --- zeromq3-4.0.5+dfsg.orig/src/proxy.cpp +++ zeromq3-4.0.5+dfsg/src/proxy.cpp @@ -30,7 +30,7 @@ defined ZMQ_HAVE_OPENBSD || defined ZMQ_HAVE_SOLARIS ||\ defined ZMQ_HAVE_OSX || defined ZMQ_HAVE_QNXNTO ||\ defined ZMQ_HAVE_HPUX || defined ZMQ_HAVE_AIX ||\ - defined ZMQ_HAVE_NETBSD + defined ZMQ_HAVE_NETBSD || defined ZMQ_HAVE_GNU #define ZMQ_POLL_BASED_ON_POLL #elif defined ZMQ_HAVE_WINDOWS || defined ZMQ_HAVE_OPENVMS ||\ defined ZMQ_HAVE_CYGWIN Index: zeromq3-4.0.5+dfsg/src/signaler.cpp =================================================================== --- zeromq3-4.0.5+dfsg.orig/src/signaler.cpp +++ zeromq3-4.0.5+dfsg/src/signaler.cpp @@ -27,7 +27,7 @@ defined ZMQ_HAVE_OPENBSD || defined ZMQ_HAVE_SOLARIS ||\ defined ZMQ_HAVE_OSX || defined ZMQ_HAVE_QNXNTO ||\ defined ZMQ_HAVE_HPUX || defined ZMQ_HAVE_AIX ||\ - defined ZMQ_HAVE_NETBSD + defined ZMQ_HAVE_NETBSD || defined ZMQ_HAVE_GNU #define ZMQ_SIGNALER_WAIT_BASED_ON_POLL #elif defined ZMQ_HAVE_WINDOWS || defined ZMQ_HAVE_OPENVMS ||\ defined ZMQ_HAVE_CYGWIN Index: zeromq3-4.0.5+dfsg/src/tcp_address.cpp =================================================================== --- zeromq3-4.0.5+dfsg.orig/src/tcp_address.cpp +++ zeromq3-4.0.5+dfsg/src/tcp_address.cpp @@ -146,7 +146,8 @@ int zmq::tcp_address_t::resolve_nic_name #elif ((defined ZMQ_HAVE_LINUX || defined ZMQ_HAVE_FREEBSD ||\ defined ZMQ_HAVE_OSX || defined ZMQ_HAVE_OPENBSD ||\ - defined ZMQ_HAVE_QNXNTO || defined ZMQ_HAVE_NETBSD)\ + defined ZMQ_HAVE_QNXNTO || defined ZMQ_HAVE_NETBSD ||\ + defined ZMQ_HAVE_GNU)\ && defined ZMQ_HAVE_IFADDRS) #include <ifaddrs.h>