Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
fa1f676c
Commit
fa1f676c
authored
Jan 05, 2015
by
Telford Berkey
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master'
parents
f78f4e3f
4e9e719f
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
595 additions
and
20 deletions
+595
-20
.gitignore
.gitignore
+3
-0
Makefile.am
Makefile.am
+15
-1
README.cygwin.md
README.cygwin.md
+15
-0
Makefile.cygwin
builds/cygwin/Makefile.cygwin
+47
-0
configure.ac
configure.ac
+4
-0
Makefile.am
doc/Makefile.am
+5
-1
zmq.txt
doc/zmq.txt
+16
-5
zmq_atomic_counter_dec.txt
doc/zmq_atomic_counter_dec.txt
+62
-0
zmq_atomic_counter_destroy.txt
doc/zmq_atomic_counter_destroy.txt
+62
-0
zmq_atomic_counter_inc.txt
doc/zmq_atomic_counter_inc.txt
+61
-0
zmq_atomic_counter_new.txt
doc/zmq_atomic_counter_new.txt
+62
-0
zmq_atomic_counter_set.txt
doc/zmq_atomic_counter_set.txt
+61
-0
zmq_atomic_counter_value.txt
doc/zmq_atomic_counter_value.txt
+60
-0
zmq.h
include/zmq.h
+12
-10
stream_engine.cpp
src/stream_engine.cpp
+12
-0
zmq_utils.cpp
src/zmq_utils.cpp
+50
-0
test_atomics.cpp
tests/test_atomics.cpp
+38
-0
test_disconnect_inproc.cpp
tests/test_disconnect_inproc.cpp
+4
-2
testutil.hpp
tests/testutil.hpp
+6
-1
No files found.
.gitignore
View file @
fa1f676c
...
@@ -98,6 +98,9 @@ test_capabilities
...
@@ -98,6 +98,9 @@ test_capabilities
test_hwm_pubsub
test_hwm_pubsub
test_router_mandatory_hwm
test_router_mandatory_hwm
test_xpub_nodrop
test_xpub_nodrop
test_xpub_manual
test_xpub_welcome_msg
test_atomics
tests/test*.log
tests/test*.log
tests/test*.trs
tests/test*.trs
src/platform.hpp*
src/platform.hpp*
...
...
Makefile.am
View file @
fa1f676c
...
@@ -208,6 +208,13 @@ src_libzmq_la_LDFLAGS = \
...
@@ -208,6 +208,13 @@ src_libzmq_la_LDFLAGS = \
-version-info
@LTVER@
\
-version-info
@LTVER@
\
@LIBZMQ_EXTRA_LDFLAGS@
@LIBZMQ_EXTRA_LDFLAGS@
else
else
if
ON_CYGWIN
src_libzmq_la_LDFLAGS
=
\
-no-undefined
\
-avoid-version
\
-version-info
@LTVER@
\
@LIBZMQ_EXTRA_LDFLAGS@
else
if
ON_ANDROID
if
ON_ANDROID
src_libzmq_la_LDFLAGS
=
\
src_libzmq_la_LDFLAGS
=
\
-avoid-version
\
-avoid-version
\
...
@@ -227,6 +234,7 @@ src_libzmq_la_LDFLAGS = \
...
@@ -227,6 +234,7 @@ src_libzmq_la_LDFLAGS = \
endif
endif
endif
endif
endif
endif
endif
src_libzmq_la_CPPFLAGS
=
src_libzmq_la_CPPFLAGS
=
src_libzmq_la_CXXFLAGS
=
@LIBZMQ_EXTRA_CXXFLAGS@
src_libzmq_la_CXXFLAGS
=
@LIBZMQ_EXTRA_CXXFLAGS@
...
@@ -330,7 +338,8 @@ test_apps = \
...
@@ -330,7 +338,8 @@ test_apps = \
tests/test_capabilities
\
tests/test_capabilities
\
tests/test_xpub_nodrop
\
tests/test_xpub_nodrop
\
tests/test_xpub_manual
\
tests/test_xpub_manual
\
tests/test_xpub_welcome_msg
tests/test_xpub_welcome_msg
\
tests/test_atomics
tests_test_system_SOURCES
=
tests/test_system.cpp
tests_test_system_SOURCES
=
tests/test_system.cpp
tests_test_system_LDADD
=
src/libzmq.la
tests_test_system_LDADD
=
src/libzmq.la
...
@@ -502,7 +511,11 @@ tests_test_xpub_manual_LDADD = src/libzmq.la
...
@@ -502,7 +511,11 @@ tests_test_xpub_manual_LDADD = src/libzmq.la
tests_test_xpub_welcome_msg_SOURCES
=
tests/test_xpub_welcome_msg.cpp
tests_test_xpub_welcome_msg_SOURCES
=
tests/test_xpub_welcome_msg.cpp
tests_test_xpub_welcome_msg_LDADD
=
src/libzmq.la
tests_test_xpub_welcome_msg_LDADD
=
src/libzmq.la
tests_test_atomics_SOURCES
=
tests/test_atomics.cpp
tests_test_atomics_LDADD
=
src/libzmq.la
if
!ON_MINGW
if
!ON_MINGW
if
!ON_CYGWIN
test_apps
+=
\
test_apps
+=
\
tests/test_shutdown_stress
\
tests/test_shutdown_stress
\
tests/test_pair_ipc
\
tests/test_pair_ipc
\
...
@@ -535,6 +548,7 @@ test_apps += tests/test_fork
...
@@ -535,6 +548,7 @@ test_apps += tests/test_fork
tests_test_fork_SOURCES
=
tests/test_fork.cpp
tests_test_fork_SOURCES
=
tests/test_fork.cpp
tests_test_fork_LDADD
=
src/libzmq.la
tests_test_fork_LDADD
=
src/libzmq.la
endif
endif
endif
endif
endif
...
...
README.cygwin.md
0 → 100755
View file @
fa1f676c
libzmq-cygwin
=============
Definitive build fixes for cygwin (See https://github.com/zeromq/pyzmq/issues/113 for partial solution)
What's changed:
./Makefile.am Add cygwin-specific target mostly the same as mingw
./configure.ac Add cygwin-specific target mostly the same as mingw
./tests/testutil.hpp Lengthen socket timeout to 121 seconds
What's new:
./README.cygwin.md This file
./builds/cygwin Folder for cygwin-specific build files
./builds/cygwin/Makefile.cygwin Makefile for cygwin targets
builds/cygwin/Makefile.cygwin
0 → 100755
View file @
fa1f676c
CC
=
gcc
CFLAGS
=
-Wall
-Os
-g
-DDLL_EXPORT
-DFD_SETSIZE
=
4096
-DZMQ_USE_SELECT
-I
.
LIBS
=
-lws2_32
OBJS
=
ctx.o reaper.o dist.o err.o
\
clock.o metadata.o random.o
\
object.o own.o
\
io_object.o io_thread.o
\
lb.o fq.o
\
address.o tcp_address.o ipc_address.o
\
ipc_connecter.o ipc_listener.o
\
tcp_connecter.o tcp_listener.o
\
mailbox.o msg.o mtrie.o
\
pipe.o precompiled.o proxy.o
\
signaler.o stream_engine.o
\
thread.o trie.o
\
ip.o tcp.o
\
pgm_socket.o pgm_receiver.o pgm_sender.o
\
raw_decoder.o raw_encoder.o
\
v1_decoder.o v1_encoder.o v2_decoder.o v2_encoder.o
\
socket_base.o session_base.o options.o
\
req.o rep.o push.o pull.o pub.o sub.o pair.o
\
dealer.o router.o xpub.o xsub.o stream.o
\
poller_base.o
select
.o poll.o epoll.o kqueue.o devpoll.o
\
curve_client.o curve_server.o
\
mechanism.o null_mechanism.o plain_client.o plain_server.o
\
zmq.o zmq_utils.o
%.o
:
../../src/%.cpp
$(CC)
-c
-o
$@
$<
$(CFLAGS)
%.o
:
../../perf/%.cpp
$(CC)
-c
-o
$@
$<
$(CFLAGS)
all
:
libzmq.dll
perf
:
inproc_lat.exe inproc_thr.exe local_lat.exe local_thr.exe remote_lat.exe remote_thr.exe
libzmq.dll
:
$(OBJS)
g++
-shared
-o
$@
$^
-Wl
,--out-implib,-Wl,--export-all-symbols
-Wl
,--enable-auto-import
-Wl
,--whole-archive
$@
.a
-Wl
,--no-whole-archive
$(LIBS)
%.exe
:
%.o libzmq.dll
g++
-o
$@
$^
clean
:
del
*
.o
*
.a
*
.dll
*
.exe
configure.ac
View file @
fa1f676c
...
@@ -134,6 +134,7 @@ libzmq_dso_visibility="yes"
...
@@ -134,6 +134,7 @@ libzmq_dso_visibility="yes"
# Platform specific checks
# Platform specific checks
libzmq_on_mingw32="no"
libzmq_on_mingw32="no"
libzmq_on_cygwin="no"
libzmq_on_android="no"
libzmq_on_android="no"
libzmq_on_linux="no"
libzmq_on_linux="no"
...
@@ -269,6 +270,8 @@ case "${host_os}" in
...
@@ -269,6 +270,8 @@ case "${host_os}" in
# Define on Cygwin to enable all library features
# Define on Cygwin to enable all library features
CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS"
CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS"
AC_DEFINE(ZMQ_HAVE_CYGWIN, 1, [Have Cygwin])
AC_DEFINE(ZMQ_HAVE_CYGWIN, 1, [Have Cygwin])
libzmq_on_cygwin="yes"
libzmq_dso_visibility="no"
if test "x$enable_static" = "xyes"; then
if test "x$enable_static" = "xyes"; then
AC_MSG_ERROR([Building static libraries is not supported under Cygwin])
AC_MSG_ERROR([Building static libraries is not supported under Cygwin])
fi
fi
...
@@ -472,6 +475,7 @@ AC_LANG_POP([C++])
...
@@ -472,6 +475,7 @@ AC_LANG_POP([C++])
AM_CONDITIONAL(BUILD_TIPC, test "x$libzmq_tipc_support" = "xyes")
AM_CONDITIONAL(BUILD_TIPC, test "x$libzmq_tipc_support" = "xyes")
AM_CONDITIONAL(ON_MINGW, test "x$libzmq_on_mingw32" = "xyes")
AM_CONDITIONAL(ON_MINGW, test "x$libzmq_on_mingw32" = "xyes")
AM_CONDITIONAL(ON_CYGWIN, test "x$libzmq_on_cygwin" = "xyes")
AM_CONDITIONAL(ON_ANDROID, test "x$libzmq_on_android" = "xyes")
AM_CONDITIONAL(ON_ANDROID, test "x$libzmq_on_android" = "xyes")
AM_CONDITIONAL(ON_LINUX, test "x$libzmq_on_linux" = "xyes")
AM_CONDITIONAL(ON_LINUX, test "x$libzmq_on_linux" = "xyes")
...
...
doc/Makefile.am
View file @
fa1f676c
...
@@ -13,7 +13,11 @@ MAN3 = zmq_bind.3 zmq_unbind.3 zmq_connect.3 zmq_disconnect.3 zmq_close.3 \
...
@@ -13,7 +13,11 @@ MAN3 = zmq_bind.3 zmq_unbind.3 zmq_connect.3 zmq_disconnect.3 zmq_close.3 \
zmq_errno.3 zmq_strerror.3 zmq_version.3
\
zmq_errno.3 zmq_strerror.3 zmq_version.3
\
zmq_sendmsg.3 zmq_recvmsg.3
\
zmq_sendmsg.3 zmq_recvmsg.3
\
zmq_proxy.3 zmq_proxy_steerable.3
\
zmq_proxy.3 zmq_proxy_steerable.3
\
zmq_z85_encode.3 zmq_z85_decode.3 zmq_curve_keypair.3 zmq_has.3
zmq_z85_encode.3 zmq_z85_decode.3 zmq_curve_keypair.3
\
zmq_has.3
\
zmq_atomic_counter_new.3 zmq_atomic_counter_set.3
\
zmq_atomic_counter_inc.3 zmq_atomic_counter_dec.3
\
zmq_atomic_counter_value.3 zmq_atomic_counter_destroy.3
MAN7
=
zmq.7 zmq_tcp.7 zmq_pgm.7 zmq_inproc.7 zmq_ipc.7
\
MAN7
=
zmq.7 zmq_tcp.7 zmq_pgm.7 zmq_inproc.7 zmq_ipc.7
\
zmq_null.7 zmq_plain.7 zmq_curve.7 zmq_tipc.7
zmq_null.7 zmq_plain.7 zmq_curve.7 zmq_tipc.7
...
...
doc/zmq.txt
View file @
fa1f676c
...
@@ -132,7 +132,7 @@ Sending and receiving messages::
...
@@ -132,7 +132,7 @@ Sending and receiving messages::
linkzmq:zmq_recv[3]
linkzmq:zmq_recv[3]
linkzmq:zmq_send_const[3]
linkzmq:zmq_send_const[3]
Monitoring socket events:
Monitoring socket events:
:
linkzmq:zmq_socket_monitor[3]
linkzmq:zmq_socket_monitor[3]
.Input/output multiplexing
.Input/output multiplexing
...
@@ -187,13 +187,11 @@ Plain-text authentication using username and password::
...
@@ -187,13 +187,11 @@ Plain-text authentication using username and password::
Elliptic curve authentication and encryption::
Elliptic curve authentication and encryption::
linkzmq:zmq_curve[7]
linkzmq:zmq_curve[7]
Generate a CURVE keypair in armored text format:
Generate a CURVE keypair in armored text format:
:
linkzmq:zmq_curve_keypair[3]
linkzmq:zmq_curve_keypair[3]
Convert
an armored key into a 32-byte binary key
:
Convert
ing keys to/from armoured text strings:
:
linkzmq:zmq_z85_decode[3]
linkzmq:zmq_z85_decode[3]
Convert a 32-byte binary CURVE key to an armored text string:
linkzmq:zmq_z85_encode[3]
linkzmq:zmq_z85_encode[3]
...
@@ -213,6 +211,19 @@ The _zmq_strerror()_ function is provided to translate 0MQ-specific error codes
...
@@ -213,6 +211,19 @@ The _zmq_strerror()_ function is provided to translate 0MQ-specific error codes
into error message strings; for details refer to linkzmq:zmq_strerror[3].
into error message strings; for details refer to linkzmq:zmq_strerror[3].
UTILITY
-------
The following utility functions are provided:
Working with atomic counters::
linkzmq:zmq_atomic_counter_new[3]
linkzmq:zmq_atomic_counter_set[3]
linkzmq:zmq_atomic_counter_inc[3]
linkzmq:zmq_atomic_counter_dec[3]
linkzmq:zmq_atomic_counter_value[3]
linkzmq:zmq_atomic_counter_destroy[3]
MISCELLANEOUS
MISCELLANEOUS
-------------
-------------
The following miscellaneous functions are provided:
The following miscellaneous functions are provided:
...
...
doc/zmq_atomic_counter_dec.txt
0 → 100644
View file @
fa1f676c
zmq_atomic_counter_dec(3)
=========================
NAME
----
zmq_atomic_counter_dec - decrement an atomic counter
SYNOPSIS
--------
*int zmq_atomic_counter_dec (void *counter);*
DESCRIPTION
-----------
The _zmq_atomic_counter_dec_ function decrements an atomic counter in
a threadsafe fashion. This function uses platform specific atomic
operations.
RETURN VALUE
------------
The _zmq_atomic_counter_dec()_ function returns 1 if the counter is
greater than zero after decrementing, or zero if the counter reached
zero.
EXAMPLE
-------
.Test code for atomic counters
----
void *counter = zmq_atomic_counter_new ();
assert (zmq_atomic_counter_value (counter) == 0);
assert (zmq_atomic_counter_inc (counter) == 0);
assert (zmq_atomic_counter_inc (counter) == 1);
assert (zmq_atomic_counter_inc (counter) == 2);
assert (zmq_atomic_counter_value (counter) == 3);
assert (zmq_atomic_counter_dec (counter) == 1);
assert (zmq_atomic_counter_dec (counter) == 1);
assert (zmq_atomic_counter_dec (counter) == 0);
zmq_atomic_counter_set (counter, 2);
assert (zmq_atomic_counter_dec (counter) == 1);
assert (zmq_atomic_counter_dec (counter) == 0);
zmq_atomic_counter_destroy (&counter);
return 0;
----
SEE ALSO
--------
linkzmq:zmq_atomic_counter_new[3]
linkzmq:zmq_atomic_counter_set[3]
linkzmq:zmq_atomic_counter_inc[3]
linkzmq:zmq_atomic_counter_value[3]
linkzmq:zmq_atomic_counter_destroy[3]
AUTHORS
-------
This page was written by the 0MQ community. To make a change please
read the 0MQ Contribution Policy at <http://www.zeromq.org/docs:contributing>.
doc/zmq_atomic_counter_destroy.txt
0 → 100644
View file @
fa1f676c
zmq_atomic_counter_destroy(3)
=============================
NAME
----
zmq_atomic_counter_destroy - destroy an atomic counter
SYNOPSIS
--------
*void zmq_atomic_counter_destroy (void **counter_p);*
DESCRIPTION
-----------
The _zmq_atomic_counter_destroy_ function destroys an atomic counter and
nullifies its reference. Pass the address of an atomic counter (void **)
rather than the counter itself. You must destroy all counters that you
create, to avoid memory leakage. This function uses platform specific
atomic operations.
RETURN VALUE
------------
The _zmq_atomic_counter_destroy()_ function has no return value.
EXAMPLE
-------
.Test code for atomic counters
----
void *counter = zmq_atomic_counter_new ();
assert (zmq_atomic_counter_value (counter) == 0);
assert (zmq_atomic_counter_inc (counter) == 0);
assert (zmq_atomic_counter_inc (counter) == 1);
assert (zmq_atomic_counter_inc (counter) == 2);
assert (zmq_atomic_counter_value (counter) == 3);
assert (zmq_atomic_counter_dec (counter) == 1);
assert (zmq_atomic_counter_dec (counter) == 1);
assert (zmq_atomic_counter_dec (counter) == 0);
zmq_atomic_counter_set (counter, 2);
assert (zmq_atomic_counter_dec (counter) == 1);
assert (zmq_atomic_counter_dec (counter) == 0);
zmq_atomic_counter_destroy (&counter);
return 0;
----
SEE ALSO
--------
linkzmq:zmq_atomic_counter_new[3]
linkzmq:zmq_atomic_counter_set[3]
linkzmq:zmq_atomic_counter_inc[3]
linkzmq:zmq_atomic_counter_dec[3]
linkzmq:zmq_atomic_counter_value[3]
AUTHORS
-------
This page was written by the 0MQ community. To make a change please
read the 0MQ Contribution Policy at <http://www.zeromq.org/docs:contributing>.
doc/zmq_atomic_counter_inc.txt
0 → 100644
View file @
fa1f676c
zmq_atomic_counter_inc(3)
=========================
NAME
----
zmq_atomic_counter_inc - increment an atomic counter
SYNOPSIS
--------
*int zmq_atomic_counter_inc (void *counter);*
DESCRIPTION
-----------
The _zmq_atomic_counter_inc_ function increments an atomic counter in a
threadsafe fashion. This function uses platform specific atomic
operations.
RETURN VALUE
------------
The _zmq_atomic_counter_inc()_ function returns the old value of the
counter, before incrementing.
EXAMPLE
-------
.Test code for atomic counters
----
void *counter = zmq_atomic_counter_new ();
assert (zmq_atomic_counter_value (counter) == 0);
assert (zmq_atomic_counter_inc (counter) == 0);
assert (zmq_atomic_counter_inc (counter) == 1);
assert (zmq_atomic_counter_inc (counter) == 2);
assert (zmq_atomic_counter_value (counter) == 3);
assert (zmq_atomic_counter_dec (counter) == 1);
assert (zmq_atomic_counter_dec (counter) == 1);
assert (zmq_atomic_counter_dec (counter) == 0);
zmq_atomic_counter_set (counter, 2);
assert (zmq_atomic_counter_dec (counter) == 1);
assert (zmq_atomic_counter_dec (counter) == 0);
zmq_atomic_counter_destroy (&counter);
return 0;
----
SEE ALSO
--------
linkzmq:zmq_atomic_counter_new[3]
linkzmq:zmq_atomic_counter_set[3]
linkzmq:zmq_atomic_counter_dec[3]
linkzmq:zmq_atomic_counter_value[3]
linkzmq:zmq_atomic_counter_destroy[3]
AUTHORS
-------
This page was written by the 0MQ community. To make a change please
read the 0MQ Contribution Policy at <http://www.zeromq.org/docs:contributing>.
doc/zmq_atomic_counter_new.txt
0 → 100644
View file @
fa1f676c
zmq_atomic_counter_new(3)
=========================
NAME
----
zmq_atomic_counter_new - create a new atomic counter
SYNOPSIS
--------
*void *zmq_atomic_counter_new (void);*
DESCRIPTION
-----------
The _zmq_atomic_counter_new_ function creates a new atomic counter. You
can use this in multithreaded applications to do, for example, reference
counting of shared objects. The atomic counter is at least 32 bits large.
This function uses platform specific atomic operations.
RETURN VALUE
------------
The _zmq_atomic_counter_new()_ function returns the new atomic counter
if successful. Otherwise it returns NULL.
EXAMPLE
-------
.Test code for atomic counters
----
void *counter = zmq_atomic_counter_new ();
assert (zmq_atomic_counter_value (counter) == 0);
assert (zmq_atomic_counter_inc (counter) == 0);
assert (zmq_atomic_counter_inc (counter) == 1);
assert (zmq_atomic_counter_inc (counter) == 2);
assert (zmq_atomic_counter_value (counter) == 3);
assert (zmq_atomic_counter_dec (counter) == 1);
assert (zmq_atomic_counter_dec (counter) == 1);
assert (zmq_atomic_counter_dec (counter) == 0);
zmq_atomic_counter_set (counter, 2);
assert (zmq_atomic_counter_dec (counter) == 1);
assert (zmq_atomic_counter_dec (counter) == 0);
zmq_atomic_counter_destroy (&counter);
return 0;
----
SEE ALSO
--------
linkzmq:zmq_atomic_counter_set[3]
linkzmq:zmq_atomic_counter_inc[3]
linkzmq:zmq_atomic_counter_dec[3]
linkzmq:zmq_atomic_counter_value[3]
linkzmq:zmq_atomic_counter_destroy[3]
AUTHORS
-------
This page was written by the 0MQ community. To make a change please
read the 0MQ Contribution Policy at <http://www.zeromq.org/docs:contributing>.
doc/zmq_atomic_counter_set.txt
0 → 100644
View file @
fa1f676c
zmq_atomic_counter_set(3)
=========================
NAME
----
zmq_atomic_counter_set - set atomic counter to new value
SYNOPSIS
--------
*void zmq_atomic_counter_set (void *counter, int value);*
DESCRIPTION
-----------
The _zmq_atomic_counter_set_ function sets the counter to a new value,
in a threadsafe fashion. The largest value that is guaranteed to work
across all platforms is 2^31-1. This function uses platform specific
atomic operations.
RETURN VALUE
------------
The _zmq_atomic_counter_set()_ function has no return value.
EXAMPLE
-------
.Test code for atomic counters
----
void *counter = zmq_atomic_counter_new ();
assert (zmq_atomic_counter_value (counter) == 0);
assert (zmq_atomic_counter_inc (counter) == 0);
assert (zmq_atomic_counter_inc (counter) == 1);
assert (zmq_atomic_counter_inc (counter) == 2);
assert (zmq_atomic_counter_value (counter) == 3);
assert (zmq_atomic_counter_dec (counter) == 1);
assert (zmq_atomic_counter_dec (counter) == 1);
assert (zmq_atomic_counter_dec (counter) == 0);
zmq_atomic_counter_set (counter, 2);
assert (zmq_atomic_counter_dec (counter) == 1);
assert (zmq_atomic_counter_dec (counter) == 0);
zmq_atomic_counter_destroy (&counter);
return 0;
----
SEE ALSO
--------
linkzmq:zmq_atomic_counter_new[3]
linkzmq:zmq_atomic_counter_inc[3]
linkzmq:zmq_atomic_counter_dec[3]
linkzmq:zmq_atomic_counter_value[3]
linkzmq:zmq_atomic_counter_destroy[3]
AUTHORS
-------
This page was written by the 0MQ community. To make a change please
read the 0MQ Contribution Policy at <http://www.zeromq.org/docs:contributing>.
doc/zmq_atomic_counter_value.txt
0 → 100644
View file @
fa1f676c
zmq_atomic_counter_value(3)
===========================
NAME
----
zmq_atomic_counter_value - return value of atomic counter
SYNOPSIS
--------
*int zmq_atomic_counter_value (void *counter);*
DESCRIPTION
-----------
The _zmq_atomic_counter_value_ function returns the value of an atomic
counter. This function uses platform specific atomic operations.
RETURN VALUE
------------
The _zmq_atomic_counter_value()_ function returns the new atomic counter
if successful. Otherwise it returns NULL.
EXAMPLE
-------
.Test code for atomic counters
----
void *counter = zmq_atomic_counter_new ();
assert (zmq_atomic_counter_value (counter) == 0);
assert (zmq_atomic_counter_inc (counter) == 0);
assert (zmq_atomic_counter_inc (counter) == 1);
assert (zmq_atomic_counter_inc (counter) == 2);
assert (zmq_atomic_counter_value (counter) == 3);
assert (zmq_atomic_counter_dec (counter) == 1);
assert (zmq_atomic_counter_dec (counter) == 1);
assert (zmq_atomic_counter_dec (counter) == 0);
zmq_atomic_counter_set (counter, 2);
assert (zmq_atomic_counter_dec (counter) == 1);
assert (zmq_atomic_counter_dec (counter) == 0);
zmq_atomic_counter_destroy (&counter);
return 0;
----
SEE ALSO
--------
linkzmq:zmq_atomic_counter_new[3]
linkzmq:zmq_atomic_counter_set[3]
linkzmq:zmq_atomic_counter_inc[3]
linkzmq:zmq_atomic_counter_dec[3]
linkzmq:zmq_atomic_counter_destroy[3]
AUTHORS
-------
This page was written by the 0MQ community. To make a change please
read the 0MQ Contribution Policy at <http://www.zeromq.org/docs:contributing>.
include/zmq.h
View file @
fa1f676c
...
@@ -71,18 +71,9 @@ extern "C" {
...
@@ -71,18 +71,9 @@ extern "C" {
#endif
#endif
/* Define integer types needed for event interface */
/* Define integer types needed for event interface */
#define ZMQ_DEFINED_STDINT 1
#if defined ZMQ_HAVE_SOLARIS || defined ZMQ_HAVE_OPENVMS
#if defined ZMQ_HAVE_SOLARIS || defined ZMQ_HAVE_OPENVMS
# include <inttypes.h>
# include <inttypes.h>
#elif defined _MSC_VER && _MSC_VER < 1600
# ifndef int32_t
typedef
__int32
int32_t
;
# endif
# ifndef uint16_t
typedef
unsigned
__int16
uint16_t
;
# endif
# ifndef uint8_t
typedef
unsigned
__int8
uint8_t
;
# endif
#else
#else
# include <stdint.h>
# include <stdint.h>
#endif
#endif
...
@@ -433,6 +424,17 @@ ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest, const char *string);
...
@@ -433,6 +424,17 @@ ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest, const char *string);
/* Returns 0 on success. */
/* Returns 0 on success. */
ZMQ_EXPORT
int
zmq_curve_keypair
(
char
*
z85_public_key
,
char
*
z85_secret_key
);
ZMQ_EXPORT
int
zmq_curve_keypair
(
char
*
z85_public_key
,
char
*
z85_secret_key
);
/******************************************************************************/
/* Atomic utility methods */
/******************************************************************************/
ZMQ_EXPORT
void
*
zmq_atomic_counter_new
(
void
);
ZMQ_EXPORT
void
zmq_atomic_counter_set
(
void
*
counter
,
int
value
);
ZMQ_EXPORT
int
zmq_atomic_counter_inc
(
void
*
counter
);
ZMQ_EXPORT
int
zmq_atomic_counter_dec
(
void
*
counter
);
ZMQ_EXPORT
int
zmq_atomic_counter_value
(
void
*
counter
);
ZMQ_EXPORT
void
zmq_atomic_counter_destroy
(
void
**
counter_p
);
/******************************************************************************/
/******************************************************************************/
/* These functions are not documented by man pages -- use at your own risk. */
/* These functions are not documented by man pages -- use at your own risk. */
...
...
src/stream_engine.cpp
View file @
fa1f676c
...
@@ -660,6 +660,18 @@ bool zmq::stream_engine_t::handshake ()
...
@@ -660,6 +660,18 @@ bool zmq::stream_engine_t::handshake ()
}
}
#endif
#endif
else
{
else
{
// Temporary support for security debugging
char
mechanism
[
21
];
memcpy
(
mechanism
,
greeting_recv
+
12
,
20
);
mechanism
[
20
]
=
0
;
printf
(
"LIBZMQ I: security failure, self=%s peer=%s
\n
"
,
options
.
mechanism
==
ZMQ_NULL
?
"NULL"
:
options
.
mechanism
==
ZMQ_PLAIN
?
"PLAIN"
:
options
.
mechanism
==
ZMQ_CURVE
?
"CURVE"
:
options
.
mechanism
==
ZMQ_GSSAPI
?
"GSSAPI"
:
"OTHER"
,
mechanism
);
error
(
protocol_error
);
error
(
protocol_error
);
return
false
;
return
false
;
}
}
...
...
src/zmq_utils.cpp
View file @
fa1f676c
...
@@ -22,6 +22,8 @@
...
@@ -22,6 +22,8 @@
#include "clock.hpp"
#include "clock.hpp"
#include "err.hpp"
#include "err.hpp"
#include "thread.hpp"
#include "thread.hpp"
#include "atomic_counter.hpp"
#include "atomic_ptr.hpp"
#include <assert.h>
#include <assert.h>
#include "../include/zmq_utils.h"
#include "../include/zmq_utils.h"
...
@@ -204,3 +206,51 @@ int zmq_curve_keypair (char *z85_public_key, char *z85_secret_key)
...
@@ -204,3 +206,51 @@ int zmq_curve_keypair (char *z85_public_key, char *z85_secret_key)
return
-
1
;
return
-
1
;
#endif
#endif
}
}
// --------------------------------------------------------------------------
// Initialize a new atomic counter, which is set to zero
void
*
zmq_atomic_counter_new
(
void
)
{
zmq
::
atomic_counter_t
*
counter
=
new
zmq
::
atomic_counter_t
;
alloc_assert
(
counter
);
return
counter
;
}
// Se the value of the atomic counter
void
zmq_atomic_counter_set
(
void
*
counter_
,
int
value_
)
{
((
zmq
::
atomic_counter_t
*
)
counter_
)
->
set
(
value_
);
}
// Increment the atomic counter, and return the old value
int
zmq_atomic_counter_inc
(
void
*
counter_
)
{
return
((
zmq
::
atomic_counter_t
*
)
counter_
)
->
add
(
1
);
}
// Decrement the atomic counter and return 1 (if counter >= 1), or
// 0 if counter hit zero.
int
zmq_atomic_counter_dec
(
void
*
counter_
)
{
return
((
zmq
::
atomic_counter_t
*
)
counter_
)
->
sub
(
1
)
?
1
:
0
;
}
// Return actual value of atomic counter
int
zmq_atomic_counter_value
(
void
*
counter_
)
{
return
((
zmq
::
atomic_counter_t
*
)
counter_
)
->
get
();
}
// Destroy atomic counter, and set reference to NULL
void
zmq_atomic_counter_destroy
(
void
**
counter_p_
)
{
delete
((
zmq
::
atomic_counter_t
*
)
*
counter_p_
);
*
counter_p_
=
NULL
;
}
tests/test_atomics.cpp
0 → 100644
View file @
fa1f676c
/*
Copyright (c) 2007-2014 Contributors as noted in the AUTHORS file
This file is part of 0MQ.
0MQ is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
0MQ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "testutil.hpp"
int
main
(
void
)
{
void
*
counter
=
zmq_atomic_counter_new
();
assert
(
zmq_atomic_counter_value
(
counter
)
==
0
);
assert
(
zmq_atomic_counter_inc
(
counter
)
==
0
);
assert
(
zmq_atomic_counter_inc
(
counter
)
==
1
);
assert
(
zmq_atomic_counter_inc
(
counter
)
==
2
);
assert
(
zmq_atomic_counter_value
(
counter
)
==
3
);
assert
(
zmq_atomic_counter_dec
(
counter
)
==
1
);
assert
(
zmq_atomic_counter_dec
(
counter
)
==
1
);
assert
(
zmq_atomic_counter_dec
(
counter
)
==
0
);
zmq_atomic_counter_set
(
counter
,
2
);
assert
(
zmq_atomic_counter_dec
(
counter
)
==
1
);
assert
(
zmq_atomic_counter_dec
(
counter
)
==
0
);
zmq_atomic_counter_destroy
(
&
counter
);
return
0
;
}
tests/test_disconnect_inproc.cpp
View file @
fa1f676c
...
@@ -25,8 +25,10 @@ zmq_msg_init(&msg) && printf("zmq_msg_init: %s\n", zmq_strerror(errno)); \
...
@@ -25,8 +25,10 @@ zmq_msg_init(&msg) && printf("zmq_msg_init: %s\n", zmq_strerror(errno)); \
zmq_msg_init_size (&msg, size + 1) && printf("zmq_msg_init_size: %s\n",zmq_strerror(errno)); \
zmq_msg_init_size (&msg, size + 1) && printf("zmq_msg_init_size: %s\n",zmq_strerror(errno)); \
memcpy(zmq_msg_data(&msg), data, size + 1);
memcpy(zmq_msg_data(&msg), data, size + 1);
int
publicationsReceived
=
0
;
// TODO: this code fails to meet our style guidelines, and needs rewriting
bool
isSubscribed
=
false
;
static
int
publicationsReceived
=
0
;
static
bool
isSubscribed
=
false
;
int
main
(
int
,
char
**
)
{
int
main
(
int
,
char
**
)
{
setup_test_environment
();
setup_test_environment
();
...
...
tests/testutil.hpp
View file @
fa1f676c
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
// This defines the settle time used in tests; raise this if we
// This defines the settle time used in tests; raise this if we
// get test failures on slower systems due to binds/connects not
// get test failures on slower systems due to binds/connects not
// settled. Tested to work reliably at 1 msec on a fast PC.
// settled. Tested to work reliably at 1 msec on a fast PC.
#define SETTLE_TIME
1
0 // In msec
#define SETTLE_TIME
5
0 // In msec
#undef NDEBUG
#undef NDEBUG
#include <time.h>
#include <time.h>
...
@@ -267,10 +267,15 @@ void setup_test_environment()
...
@@ -267,10 +267,15 @@ void setup_test_environment()
_CrtSetReportMode
(
_CRT_ASSERT
,
_CRTDBG_MODE_FILE
);
_CrtSetReportMode
(
_CRT_ASSERT
,
_CRTDBG_MODE_FILE
);
_CrtSetReportFile
(
_CRT_ASSERT
,
_CRTDBG_FILE_STDERR
);
_CrtSetReportFile
(
_CRT_ASSERT
,
_CRTDBG_FILE_STDERR
);
# endif
# endif
#else
#if defined ZMQ_HAVE_CYGWIN
// abort test after 121 seconds
alarm
(
121
);
#else
#else
// abort test after 60 seconds
// abort test after 60 seconds
alarm
(
60
);
alarm
(
60
);
#endif
#endif
#endif
#if defined __MVS__
#if defined __MVS__
// z/OS UNIX System Services: Ignore SIGPIPE during test runs, as a
// z/OS UNIX System Services: Ignore SIGPIPE during test runs, as a
// workaround for no SO_NOGSIGPIPE socket option.
// workaround for no SO_NOGSIGPIPE socket option.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment