Skip to content

Commit fc63a59

Browse files
committed
Merge branch 'master' of https://github.com/nanomsg/nanomsg
Conflicts: src/utils/int.h
2 parents c5762c0 + 6e840d0 commit fc63a59

File tree

8 files changed

+35
-10
lines changed

8 files changed

+35
-10
lines changed

AUTHORS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Luca Barbato <[email protected]>
2424
Manuel Mendez <[email protected]>
2525
Martin Sustrik <[email protected]>
2626
Matt Howlett <[email protected]>
27+
Max Drechsler <[email protected]>
2728
Mikko Koppanen <[email protected]>
2829
Nick Desaulniers <[email protected]>
2930
Nicolas Hillegeer <[email protected]>
@@ -37,5 +38,6 @@ Sergey Avseyev <[email protected]>
3738
Sergey Kovalevich <[email protected]>
3839
Sergei Nikulov <[email protected]>
3940
Steve McKay <[email protected]>
41+
Tobias Peters <[email protected]>
4042
Victor Guerra <[email protected]>
4143
Zoltan Boszormenyi <[email protected]>

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
3636
add_definitions (-D_CRT_SECURE_NO_WARNINGS)
3737

3838
if (MINGW)
39-
add_definitions (-DNN_HAVE_MINGW -D_WIN32_WINNT=0x0600)
39+
add_definitions (-DNN_HAVE_MINGW -DNN_HAVE_STDINT -D_WIN32_WINNT=0x0600)
4040
endif ()
4141
else ()
4242
message (FATAL_ERROR "ERROR: CMake build system is intended only to generate MSVC solution files.\nUse autotools build system for any other purpose." )

configure.ac

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ AS_CASE([${host_os}],
226226
AC_DEFINE([NN_HAVE_SOLARIS])
227227
AC_CHECK_LIB([socket], [socket])
228228
AC_CHECK_LIB([nsl], [gethostbyname])
229+
],
230+
[*nto-qnx*], [
231+
AC_DEFINE([NN_HAVE_QNX])
232+
AC_CHECK_LIB([socket], [socket])
229233
]
230234
)
231235

@@ -245,6 +249,7 @@ AC_CHECK_HEADERS([arpa/inet.h])
245249
AC_CHECK_HEADERS([unistd.h])
246250
AC_CHECK_HEADERS([sys/socket.h])
247251
AC_CHECK_HEADERS([sys/ioctl.h])
252+
AC_CHECK_HEADERS([stdint.h], [AC_DEFINE([NN_HAVE_STDINT])])
248253

249254
AC_CHECK_FUNCS([eventfd], [AC_DEFINE([NN_HAVE_EVENTFD])])
250255
AC_CHECK_FUNCS([pipe], [AC_DEFINE([NN_HAVE_PIPE])])

doc/nn_ipc.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ file references. Note that both relative (ipc://test.ipc) and absolute
2525
files must be set in such a way that the appropriate applications can actually
2626
use them.
2727

28-
On Windows, named pipes are used for IPC. IPC address is an arbitrary
29-
case-insensitive string containing any character except for backslash.
30-
Internally, address ipc://test means that named pipe \\.\pipe\test will be used.
28+
On Windows, IPC is not supported.
3129

3230
EXAMPLE
3331
-------

src/core/global.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ int nn_close (int s)
514514
/* Deallocate the socket object. */
515515
rc = nn_sock_term (self.socks [s]);
516516
if (nn_slow (rc == -EINTR)) {
517+
nn_glock_unlock ();
517518
errno = EINTR;
518519
return -1;
519520
}

src/core/poll.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include "../utils/win.h"
2828
#include "../utils/fast.h"
29+
#include "../utils/sleep.h"
2930
#include "../utils/err.h"
3031

3132
int nn_poll (struct nn_pollfd *fds, int nfds, int timeout)
@@ -66,12 +67,22 @@ int nn_poll (struct nn_pollfd *fds, int nfds, int timeout)
6667
/* Do the polling itself. */
6768
tv.tv_sec = timeout / 1000;
6869
tv.tv_usec = timeout % 1000 * 1000;
69-
rc = select (-1, &fdset, NULL, NULL, &tv);
70-
if (nn_slow (rc == 0))
70+
if (nn_fast (nfds)) {
71+
rc = select (-1, &fdset, NULL, NULL, &tv);
72+
if (nn_slow (rc == 0))
73+
return 0;
74+
if (nn_slow (rc == SOCKET_ERROR)) {
75+
errno = nn_err_wsa_to_posix (WSAGetLastError ());
76+
return -1;
77+
}
78+
}
79+
else {
80+
81+
// POSIX platforms will sleep until timeout is expired,
82+
// so let's do the same on Windows.
83+
if (timeout > 0)
84+
nn_sleep(timeout);
7185
return 0;
72-
if (nn_slow (rc == SOCKET_ERROR)) {
73-
errno = nn_err_wsa_to_posix (WSAGetLastError ());
74-
return -1;
7586
}
7687

7788
/* Move the results from fdset to the nanomsg pollset. */

src/utils/err.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
if (nn_slow (!(x))) {\
4848
fprintf (stderr, "Assertion failed: %s (%s:%d)\n", #x, \
4949
__FILE__, __LINE__);\
50+
fflush (stderr);\
5051
nn_err_abort ();\
5152
}\
5253
} while (0)
@@ -58,6 +59,7 @@
5859
"Assertion failed: %d == %s (%s:%d)\n", \
5960
(obj)->state, #state_name, \
6061
__FILE__, __LINE__);\
62+
fflush (stderr);\
6163
nn_err_abort ();\
6264
}\
6365
} while (0)
@@ -68,6 +70,7 @@
6870
if (nn_slow (!x)) {\
6971
fprintf (stderr, "Out of memory (%s:%d)\n",\
7072
__FILE__, __LINE__);\
73+
fflush (stderr);\
7174
nn_err_abort ();\
7275
}\
7376
} while (0)
@@ -78,6 +81,7 @@
7881
if (nn_slow (!(x))) {\
7982
fprintf (stderr, "%s [%d] (%s:%d)\n", nn_err_strerror (errno),\
8083
(int) errno, __FILE__, __LINE__);\
84+
fflush (stderr);\
8185
nn_err_abort ();\
8286
}\
8387
} while (0)
@@ -88,6 +92,7 @@
8892
if (nn_slow (!(cond))) {\
8993
fprintf (stderr, "%s [%d] (%s:%d)\n", nn_err_strerror (err),\
9094
(int) (err), __FILE__, __LINE__);\
95+
fflush (stderr);\
9196
nn_err_abort ();\
9297
}\
9398
} while (0)
@@ -100,6 +105,7 @@
100105
nn_win_error ((int) GetLastError (), errstr, 256);\
101106
fprintf (stderr, "%s [%d] (%s:%d)\n",\
102107
errstr, (int) GetLastError (), __FILE__, __LINE__);\
108+
fflush (stderr);\
103109
nn_err_abort ();\
104110
}\
105111
} while (0)
@@ -112,6 +118,7 @@
112118
nn_win_error (WSAGetLastError (), errstr, 256);\
113119
fprintf (stderr, "%s [%d] (%s:%d)\n",\
114120
errstr, (int) WSAGetLastError (), __FILE__, __LINE__);\
121+
fflush (stderr);\
115122
nn_err_abort ();\
116123
}\
117124
} while (0)
@@ -121,6 +128,7 @@
121128
do {\
122129
fprintf (stderr, "%s: state=%d source=%d action=%d (%s:%d)\n", \
123130
message, state, src, type, __FILE__, __LINE__);\
131+
fflush (stderr);\
124132
nn_err_abort ();\
125133
} while (0)
126134

src/utils/int.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#ifndef NN_INT_INCLUDED
2424
#define NN_INT_INCLUDED
2525

26-
#if defined NN_HAVE_WINDOWS && !defined NN_HAVE_MINGW
26+
#if defined NN_HAVE_WINDOWS && !defined NN_HAVE_STDINT
2727

2828
/* Old versions of MSVC don't ship with stdint.h header file.
2929
Thus, we have to define fix-sized integer type ourselves. */

0 commit comments

Comments
 (0)