Hello community, here is the log from the commit of package nanomsg for openSUSE:Factory checked in at 2018-06-22 13:30:42 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/nanomsg (Old) and /work/SRC/openSUSE:Factory/.nanomsg.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "nanomsg" Fri Jun 22 13:30:42 2018 rev:5 rq:615268 version:1.1.4 Changes: -------- --- /work/SRC/openSUSE:Factory/nanomsg/nanomsg.changes 2018-06-04 13:23:51.849689386 +0200 +++ /work/SRC/openSUSE:Factory/.nanomsg.new/nanomsg.changes 2018-06-22 13:30:48.596793426 +0200 @@ -1,0 +2,15 @@ +Fri Jun 8 13:06:39 UTC 2018 - mar...@gmx.de + +- Update to versoin 1.1.4 + * This release is primarily a bug-fix release for Windows + platforms, but it also adds support for building on Android. + * The main change in this release is a fix for the IPC transport + on Windows, which was subject to crashing if the remote peer + breaks messages into smaller pieces. + As some other SP implementations do this to avoid data copies, + this fix is very important. + * A fix for leaking handles on Windows is included. + * Support for compilation on Android using the NDK and the + bundled cmake and toolchain file from Android is now present. + +------------------------------------------------------------------- Old: ---- nanomsg-1.1.3.tar.gz New: ---- nanomsg-1.1.4.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ nanomsg.spec ++++++ --- /var/tmp/diff_new_pack.vOkwXN/_old 2018-06-22 13:30:49.328766371 +0200 +++ /var/tmp/diff_new_pack.vOkwXN/_new 2018-06-22 13:30:49.352765484 +0200 @@ -18,7 +18,7 @@ %define sover 5 Name: nanomsg -Version: 1.1.3 +Version: 1.1.4 Release: 0 Summary: Socket library providing several common communication patterns License: MIT @@ -52,7 +52,7 @@ %prep %setup -q -%patch -P 1 -p1 +%patch1 -p1 %build %cmake @@ -65,13 +65,11 @@ %postun -n libnanomsg%{sover} -p /sbin/ldconfig %files -n libnanomsg%{sover} -%defattr(-,root,root) %license COPYING %doc RELEASING AUTHORS README.md %{_libdir}/libnanomsg.so.* %files devel -%defattr(-,root,root) %{_includedir}/nanomsg %{_libdir}/libnanomsg.so %{_bindir}/nanocat ++++++ nanomsg-1.1.3.tar.gz -> nanomsg-1.1.4.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.1.3/.version new/nanomsg-1.1.4/.version --- old/nanomsg-1.1.3/.version 2018-05-24 01:30:43.000000000 +0200 +++ new/nanomsg-1.1.4/.version 2018-06-08 02:46:50.000000000 +0200 @@ -1 +1 @@ -1.1.3 +1.1.4 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.1.3/CMakeLists.txt new/nanomsg-1.1.4/CMakeLists.txt --- old/nanomsg-1.1.3/CMakeLists.txt 2018-05-24 01:30:43.000000000 +0200 +++ new/nanomsg-1.1.4/CMakeLists.txt 2018-06-08 02:46:50.000000000 +0200 @@ -142,6 +142,9 @@ if (CMAKE_SYSTEM_VERSION MATCHES "Microsoft") add_definitions (-DNN_HAVE_WSL) endif() +elseif (CMAKE_SYSTEM_NAME MATCHES "Android") + add_definitions (-DNN_HAVE_ANDROID) + add_definitions (-DNN_HAVE_LINUX) elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin") add_definitions (-DNN_HAVE_OSX) elseif (CMAKE_SYSTEM_NAME MATCHES "Windows") @@ -248,7 +251,10 @@ nn_check_sym (backtrace_symbols_fd execinfo.h NN_HAVE_BACKTRACE) nn_check_struct_member(msghdr msg_control sys/socket.h NN_HAVE_MSG_CONTROL) if (NN_HAVE_SEMAPHORE_RT OR NN_HAVE_SEMAPHORE_PTHREAD) - add_definitions (-DNN_HAVE_SEMAPHORE) + if (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") + # macOS doesn't have unnamed semaphores + add_definitions (-DNN_HAVE_SEMAPHORE) + endif() endif () endif () diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.1.3/src/aio/usock_win.inc new/nanomsg-1.1.4/src/aio/usock_win.inc --- old/nanomsg-1.1.3/src/aio/usock_win.inc 2018-05-24 01:30:43.000000000 +0200 +++ new/nanomsg-1.1.4/src/aio/usock_win.inc 2018-06-08 02:46:50.000000000 +0200 @@ -1,6 +1,8 @@ /* Copyright (c) 2013 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. All rights reserved. + Copyright 2018 Staysail Systems, Inc. <i...@staysail.tech> + Copyright 2018 Capitar IT Group BV <i...@capitar.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -311,7 +313,7 @@ listener->asock = self; /* Asynchronous accept. */ - nn_worker_op_start (&listener->in, 0); + nn_worker_op_start (&listener->in); } void nn_usock_activate (struct nn_usock *self) @@ -371,7 +373,7 @@ } /* Asynchronous connect. */ - nn_worker_op_start (&self->out, 0); + nn_worker_op_start (&self->out); } void nn_usock_send (struct nn_usock *self, const struct nn_iovec *iov, @@ -418,7 +420,7 @@ } brc = WriteFile (self->p, self->pipesendbuf, (DWORD) len, NULL, &self->out.olpd); if (nn_fast (brc || GetLastError() == ERROR_IO_PENDING)) { - nn_worker_op_start (&self->out, 0); + nn_worker_op_start (&self->out); return; } error = GetLastError(); @@ -430,12 +432,12 @@ rc = WSASend (self->s, wbuf, iovcnt, NULL, 0, &self->out.olpd, NULL); if (nn_fast (rc == 0)) { - nn_worker_op_start (&self->out, 0); + nn_worker_op_start (&self->out); return; } error = WSAGetLastError(); if (nn_fast (error == WSA_IO_PENDING)) { - nn_worker_op_start (&self->out, 0); + nn_worker_op_start (&self->out); return; } wsa_assert (error == WSAECONNABORTED || error == WSAECONNRESET || @@ -445,59 +447,86 @@ nn_fsm_action (&self->fsm, NN_USOCK_ACTION_ERROR); } -void nn_usock_recv (struct nn_usock *self, void *buf, size_t len, int *fd) +void nn_usock_recv_start_wsock (void *arg) { - int rc; - BOOL brc; + struct nn_usock *self = arg; WSABUF wbuf; - DWORD wflags; + DWORD flags; DWORD error; - /* Passing file descriptors is not implemented on Windows platform. */ - if (fd) - *fd = -1; - - /* Make sure that the socket is actually alive. */ - nn_assert_state (self, NN_USOCK_STATE_ACTIVE); - /* Start the receive operation. */ - wbuf.len = (ULONG) len; - wbuf.buf = (char FAR*) buf; - wflags = MSG_WAITALL; + wbuf.len = (ULONG) self->in.resid; + wbuf.buf = (char FAR*) self->in.buf; + flags = MSG_WAITALL; memset (&self->in.olpd, 0, sizeof (self->in.olpd)); - if (self->domain == AF_UNIX) { - - /* Ensure the total buffer size does not exceed size limitation - of WriteFile. */ - nn_assert (len <= MAXDWORD); - brc = ReadFile (self->p, buf, (DWORD) len, NULL, &self->in.olpd); - error = brc ? ERROR_SUCCESS : GetLastError (); - } - else { - rc = WSARecv (self->s, &wbuf, 1, NULL, &wflags, &self->in.olpd, NULL); - error = (rc == 0) ? ERROR_SUCCESS : WSAGetLastError (); + if (WSARecv (self->s, &wbuf, 1, NULL, &flags, &self->in.olpd, NULL) == 0) { + error = ERROR_SUCCESS; + } else { + error = WSAGetLastError (); } - if (nn_fast (error == ERROR_SUCCESS)) { - nn_worker_op_start (&self->in, 1); + switch (error) { + case ERROR_SUCCESS: + case WSA_IO_PENDING: + nn_worker_op_start (&self->in); return; - } - if (nn_fast (error == WSA_IO_PENDING)) { - nn_worker_op_start (&self->in, 1); + default: + nn_fsm_action (&self->fsm, NN_USOCK_ACTION_ERROR); return; } +} + +void nn_usock_recv_start_pipe (void *arg) +{ + struct nn_usock *self = arg; + void *buf = self->in.buf; + DWORD len = (DWORD) self->in.resid; + DWORD error; + + /* Start the receive operation. */ + memset (&self->in.olpd, 0, sizeof (self->in.olpd)); + + if (ReadFile (self->p, buf, len, NULL, &self->in.olpd)) { + error = ERROR_SUCCESS; + } else { + error = GetLastError (); + } - if (error == WSAECONNABORTED || error == WSAECONNRESET || - error == WSAENETDOWN || error == WSAENETRESET || - error == WSAETIMEDOUT || error == WSAEWOULDBLOCK || - error == ERROR_PIPE_NOT_CONNECTED || error == ERROR_BROKEN_PIPE) { + switch (error) { + case ERROR_SUCCESS: + case ERROR_IO_PENDING: + nn_worker_op_start (&self->in); + return; + + default: nn_fsm_action (&self->fsm, NN_USOCK_ACTION_ERROR); return; } +} + +void nn_usock_recv (struct nn_usock *self, void *buf, size_t len, int *fd) +{ + /* Passing file descriptors is not implemented on Windows platform. */ + if (fd) + *fd = -1; + + /* Make sure that the socket is actually alive. */ + nn_assert_state (self, NN_USOCK_STATE_ACTIVE); + + self->in.resid = len; + self->in.buf = buf; + self->in.arg = self; + self->in.zero_is_error = 1; + if (self->domain == AF_UNIX) { + self->in.start = nn_usock_recv_start_pipe; + } + else { + self->in.start = nn_usock_recv_start_wsock; + } - wsa_assert (0); + self->in.start (self->in.arg); } static void nn_usock_create_io_completion (struct nn_usock *self) @@ -628,7 +657,7 @@ listener->asock = self; /* Asynchronous accept. */ - nn_worker_op_start (&listener->in, 0); + nn_worker_op_start (&listener->in); } static void nn_usock_close (struct nn_usock *self) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.1.3/src/aio/worker_win.h new/nanomsg-1.1.4/src/aio/worker_win.h --- old/nanomsg-1.1.3/src/aio/worker_win.h 2018-05-24 01:30:43.000000000 +0200 +++ new/nanomsg-1.1.4/src/aio/worker_win.h 2018-06-08 02:46:50.000000000 +0200 @@ -1,5 +1,7 @@ /* Copyright (c) 2013 Martin Sustrik All rights reserved. + Copyright 2018 Staysail Systems, Inc. <i...@staysail.tech> + Copyright 2018 Capitar IT Group BV <i...@capitar.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -42,16 +44,21 @@ /* This structure is to be used by the user, not nn_worker_op itself. Actual usage is specific to the asynchronous operation in question. */ OVERLAPPED olpd; + + /* We might have transferred less than requested. This keeps track. */ + size_t resid; + char *buf; + void *arg; + void (*start)(struct nn_usock *); + int zero_is_error; }; void nn_worker_op_init (struct nn_worker_op *self, int src, struct nn_fsm *owner); void nn_worker_op_term (struct nn_worker_op *self); -/* Call this function when asynchronous operation is started. - If 'zeroiserror' is set to 1, zero bytes transferred will be treated - as an error. */ -void nn_worker_op_start (struct nn_worker_op *self, int zeroiserror); +/* Call this function when asynchronous operation is started. */ +void nn_worker_op_start (struct nn_worker_op *self); int nn_worker_op_isidle (struct nn_worker_op *self); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.1.3/src/aio/worker_win.inc new/nanomsg-1.1.4/src/aio/worker_win.inc --- old/nanomsg-1.1.3/src/aio/worker_win.inc 2018-05-24 01:30:43.000000000 +0200 +++ new/nanomsg-1.1.4/src/aio/worker_win.inc 2018-06-08 02:46:50.000000000 +0200 @@ -1,6 +1,8 @@ /* Copyright (c) 2013 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. All rights reserved. + Copyright 2018 Staysail Systems, Inc. <i...@staysail.tech> + Copyright 2018 Capitar IT Group BV <i...@capitar.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -32,7 +34,6 @@ #define NN_WORKER_OP_STATE_IDLE 1 #define NN_WORKER_OP_STATE_ACTIVE 2 -#define NN_WORKER_OP_STATE_ACTIVE_ZEROISERROR 3 /* The value of this variable is irrelevant. It's used only as a placeholder for the address that is used as the 'stop' event ID. */ @@ -58,6 +59,10 @@ self->src = src; self->owner = owner; self->state = NN_WORKER_OP_STATE_IDLE; + self->start = NULL; + self->buf = NULL; + self->resid = 0; + self->zero_is_error = 0; } void nn_worker_op_term (struct nn_worker_op *self) @@ -65,11 +70,9 @@ nn_assert_state (self, NN_WORKER_OP_STATE_IDLE); } -void nn_worker_op_start (struct nn_worker_op *self, int zeroiserror) +void nn_worker_op_start (struct nn_worker_op *self) { - nn_assert_state (self, NN_WORKER_OP_STATE_IDLE); - self->state = zeroiserror ? NN_WORKER_OP_STATE_ACTIVE_ZEROISERROR : - NN_WORKER_OP_STATE_ACTIVE; + self->state = NN_WORKER_OP_STATE_ACTIVE; } int nn_worker_op_isidle (struct nn_worker_op *self) @@ -174,6 +177,7 @@ /* Process I/O completion events. */ if (nn_fast (entries [i].lpOverlapped != NULL)) { + DWORD nxfer; op = nn_cont (entries [i].lpOverlapped, struct nn_worker_op, olpd); @@ -183,9 +187,31 @@ rc = entries [i].Internal & 0xc0000000; switch (rc) { case 0x00000000: + nxfer = entries[i].dwNumberOfBytesTransferred; + + if ((nxfer == 0) && (op->zero_is_error != 0)) { + rc = NN_WORKER_OP_ERROR; + break; + } + if (op->start != NULL) { + if (nxfer > op->resid) { + rc = NN_WORKER_OP_ERROR; + break; + } + op->resid -= nxfer; + op->buf += nxfer; + + /* If we still have more to transfer, keep going. */ + if (op->resid != 0) { + op->start (op->arg); + continue; + } + } rc = NN_WORKER_OP_DONE; break; + case 0xc0000000: + nxfer = 0; rc = NN_WORKER_OP_ERROR; break; default: @@ -195,11 +221,9 @@ /* Raise the completion event. */ nn_ctx_enter (op->owner->ctx); nn_assert (op->state != NN_WORKER_OP_STATE_IDLE); - if (rc != NN_WORKER_OP_ERROR && - op->state == NN_WORKER_OP_STATE_ACTIVE_ZEROISERROR && - entries [i].dwNumberOfBytesTransferred == 0) - rc = NN_WORKER_OP_ERROR; + op->state = NN_WORKER_OP_STATE_IDLE; + nn_fsm_feed (op->owner, op->src, rc, op); nn_ctx_leave (op->owner->ctx); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.1.3/src/core/sock.c new/nanomsg-1.1.4/src/core/sock.c --- old/nanomsg-1.1.3/src/core/sock.c 2018-05-24 01:30:43.000000000 +0200 +++ new/nanomsg-1.1.4/src/core/sock.c 2018-06-08 02:46:50.000000000 +0200 @@ -235,6 +235,7 @@ nn_fsm_stopped_noevent (&self->fsm); nn_fsm_term (&self->fsm); nn_sem_term (&self->termsem); + nn_sem_term (&self->relesem); nn_list_term (&self->sdeps); nn_list_term (&self->eps); nn_ctx_term (&self->ctx); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.1.3/src/utils/efd_win.inc new/nanomsg-1.1.4/src/utils/efd_win.inc --- old/nanomsg-1.1.3/src/utils/efd_win.inc 2018-05-24 01:30:43.000000000 +0200 +++ new/nanomsg-1.1.4/src/utils/efd_win.inc 2018-06-08 02:46:50.000000000 +0200 @@ -42,7 +42,6 @@ int one; BOOL nodelay; u_long nonblock; - int i; /* Unfortunately, on Windows the only way to send signal to a file descriptor (SOCKET) is to create a full-blown TCP connecting on top of diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.1.3/src/utils/sem.c new/nanomsg-1.1.4/src/utils/sem.c --- old/nanomsg-1.1.3/src/utils/sem.c 2018-05-24 01:30:43.000000000 +0200 +++ new/nanomsg-1.1.4/src/utils/sem.c 2018-06-08 02:46:50.000000000 +0200 @@ -24,74 +24,8 @@ #include "err.h" #include "fast.h" -#if defined NN_HAVE_OSX -void nn_sem_init (struct nn_sem *self) -{ - int rc; - - rc = pthread_mutex_init (&self->mutex, NULL); - errnum_assert (rc == 0, rc); - rc = pthread_cond_init (&self->cond, NULL); - errnum_assert (rc == 0, rc); - self->signaled = 0; -} - -void nn_sem_term (struct nn_sem *self) -{ - int rc; - - rc = pthread_cond_destroy (&self->cond); - errnum_assert (rc == 0, rc); - rc = pthread_mutex_destroy (&self->mutex); - errnum_assert (rc == 0, rc); -} - -void nn_sem_post (struct nn_sem *self) -{ - int rc; - - rc = pthread_mutex_lock (&self->mutex); - errnum_assert (rc == 0, rc); - nn_assert (self->signaled == 0); - self->signaled = 1; - rc = pthread_cond_signal (&self->cond); - errnum_assert (rc == 0, rc); - rc = pthread_mutex_unlock (&self->mutex); - errnum_assert (rc == 0, rc); -} - -int nn_sem_wait (struct nn_sem *self) -{ - int rc; - - /* With OSX, semaphores are global named objects. They are not useful for - our use case. To get a similar object we exploit the implementation - detail of pthread_cond_wait() in Darwin kernel: It exits if signal is - caught. Note that this behaviour is not mandated by POSIX - and may break with future versions of Darwin. */ - rc = pthread_mutex_lock (&self->mutex); - errnum_assert (rc == 0, rc); - if (nn_fast (self->signaled)) { - rc = pthread_mutex_unlock (&self->mutex); - errnum_assert (rc == 0, rc); - return 0; - } - rc = pthread_cond_wait (&self->cond, &self->mutex); - errnum_assert (rc == 0, rc); - if (nn_slow (!self->signaled)) { - rc = pthread_mutex_unlock (&self->mutex); - errnum_assert (rc == 0, rc); - return -EINTR; - } - self->signaled = 0; - rc = pthread_mutex_unlock (&self->mutex); - errnum_assert (rc == 0, rc); - - return 0; -} - -#elif defined NN_HAVE_WINDOWS +#if defined NN_HAVE_WINDOWS void nn_sem_init (struct nn_sem *self) { @@ -164,6 +98,74 @@ } #else -#error + +/* Simulate semaphores with condition variables. */ + +void nn_sem_init (struct nn_sem *self) +{ + int rc; + + rc = pthread_mutex_init (&self->mutex, NULL); + errnum_assert (rc == 0, rc); + rc = pthread_cond_init (&self->cond, NULL); + errnum_assert (rc == 0, rc); + self->signaled = 0; +} + +void nn_sem_term (struct nn_sem *self) +{ + int rc; + + rc = pthread_cond_destroy (&self->cond); + errnum_assert (rc == 0, rc); + rc = pthread_mutex_destroy (&self->mutex); + errnum_assert (rc == 0, rc); +} + +void nn_sem_post (struct nn_sem *self) +{ + int rc; + + rc = pthread_mutex_lock (&self->mutex); + errnum_assert (rc == 0, rc); + nn_assert (self->signaled == 0); + self->signaled = 1; + rc = pthread_cond_signal (&self->cond); + errnum_assert (rc == 0, rc); + rc = pthread_mutex_unlock (&self->mutex); + errnum_assert (rc == 0, rc); +} + +int nn_sem_wait (struct nn_sem *self) +{ + int rc; + + /* With OSX, semaphores are global named objects. They are not useful for + our use case. To get a similar object we exploit the implementation + detail of pthread_cond_wait() in Darwin kernel: It exits if signal is + caught. Note that this behaviour is not mandated by POSIX + and may break with future versions of Darwin. */ + rc = pthread_mutex_lock (&self->mutex); + errnum_assert (rc == 0, rc); + if (nn_fast (self->signaled)) { + rc = pthread_mutex_unlock (&self->mutex); + errnum_assert (rc == 0, rc); + return 0; + } + rc = pthread_cond_wait (&self->cond, &self->mutex); + errnum_assert (rc == 0, rc); + if (nn_slow (!self->signaled)) { + rc = pthread_mutex_unlock (&self->mutex); + errnum_assert (rc == 0, rc); + return -EINTR; + } + self->signaled = 0; + rc = pthread_mutex_unlock (&self->mutex); + errnum_assert (rc == 0, rc); + + return 0; +} + + #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanomsg-1.1.3/src/utils/sem.h new/nanomsg-1.1.4/src/utils/sem.h --- old/nanomsg-1.1.3/src/utils/sem.h 2018-05-24 01:30:43.000000000 +0200 +++ new/nanomsg-1.1.4/src/utils/sem.h 2018-06-08 02:46:50.000000000 +0200 @@ -39,17 +39,7 @@ /* Waits till sem object becomes unlocked and locks it. */ int nn_sem_wait (struct nn_sem *self); -#if defined NN_HAVE_OSX - -#include <pthread.h> - -struct nn_sem { - pthread_mutex_t mutex; - pthread_cond_t cond; - int signaled; -}; - -#elif defined NN_HAVE_WINDOWS +#if defined NN_HAVE_WINDOWS #include "win.h" @@ -65,6 +55,16 @@ sem_t sem; }; +#else /* Simulate semaphore with condition variable. */ + +#include <pthread.h> + +struct nn_sem { + pthread_mutex_t mutex; + pthread_cond_t cond; + int signaled; +}; + #endif #endif