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
72b517b3
Commit
72b517b3
authored
Aug 20, 2017
by
Luca Boccassi
Committed by
GitHub
Aug 20, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2704 from sigiesec/fix-test-sockopt-hwm
Problem: test_sockopt_hwm fails occasionally
parents
7283574c
00c69625
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
23 deletions
+39
-23
zmq_setsockopt.txt
doc/zmq_setsockopt.txt
+1
-1
test_sockopt_hwm.cpp
tests/test_sockopt_hwm.cpp
+38
-22
No files found.
doc/zmq_setsockopt.txt
View file @
72b517b3
...
...
@@ -822,7 +822,7 @@ in linkzmq:zmq_socket[3] for details on the exact action taken for each socket
type.
NOTE: 0MQ does not guarantee that the socket will accept as many as ZMQ_SNDHWM
messages, and the actual limit may be as much as
60-7
0% lower depending on the
messages, and the actual limit may be as much as
9
0% lower depending on the
flow of messages on the socket.
[horizontal]
...
...
tests/test_sockopt_hwm.cpp
View file @
72b517b3
...
...
@@ -103,6 +103,25 @@ void test_change_after_connected()
zmq_ctx_term
(
ctx
);
}
int
send_until_wouldblock
(
void
*
socket
)
{
int
send_count
=
0
;
while
(
send_count
<
MAX_SENDS
&&
zmq_send
(
socket
,
&
send_count
,
sizeof
(
send_count
),
ZMQ_DONTWAIT
)
==
sizeof
(
send_count
))
{
++
send_count
;
}
return
send_count
;
}
int
test_fill_up_to_hwm
(
void
*
socket
,
int
sndhwm
)
{
int
send_count
=
send_until_wouldblock
(
socket
);
fprintf
(
stderr
,
"sndhwm==%i, send_count==%i
\n
"
,
sndhwm
,
send_count
);
assert
(
send_count
<=
sndhwm
+
1
&&
send_count
>
(
sndhwm
/
10
));
return
send_count
;
}
void
test_decrease_when_full
()
{
int
rc
;
...
...
@@ -115,50 +134,47 @@ void test_decrease_when_full()
rc
=
zmq_setsockopt
(
connect_socket
,
ZMQ_RCVHWM
,
&
val
,
sizeof
(
val
));
assert
(
rc
==
0
);
val
=
100
;
rc
=
zmq_setsockopt
(
bind_socket
,
ZMQ_SNDHWM
,
&
val
,
sizeof
(
val
));
assert
(
rc
==
0
);
int
sndhwm
=
100
;
rc
=
zmq_setsockopt
(
bind_socket
,
ZMQ_SNDHWM
,
&
sndhwm
,
sizeof
(
sndhwm
));
assert
(
rc
==
0
);
zmq_bind
(
bind_socket
,
"inproc://a"
);
zmq_connect
(
connect_socket
,
"inproc://a"
);
// Fill up to hwm
int
send_count
=
0
;
while
(
send_count
<
MAX_SENDS
&&
zmq_send
(
bind_socket
,
&
send_count
,
sizeof
(
send_count
),
ZMQ_DONTWAIT
)
==
sizeof
(
send_count
))
++
send_count
;
assert
(
send_count
==
101
);
int
send_count
=
test_fill_up_to_hwm
(
bind_socket
,
sndhwm
);
// De
s
crease snd hwm
val
=
70
;
rc
=
zmq_setsockopt
(
bind_socket
,
ZMQ_SNDHWM
,
&
val
,
sizeof
(
val
));
// Decrease snd hwm
sndhwm
=
70
;
rc
=
zmq_setsockopt
(
bind_socket
,
ZMQ_SNDHWM
,
&
sndhwm
,
sizeof
(
sndhwm
));
assert
(
rc
==
0
);
size_t
placeholder
=
sizeof
(
val
)
;
val
=
0
;
rc
=
zmq_getsockopt
(
bind_socket
,
ZMQ_SNDHWM
,
&
val
,
&
placeholder
);
int
sndhwm_read
=
0
;
size_t
sndhwm_read_size
=
sizeof
(
sndhwm_read
)
;
rc
=
zmq_getsockopt
(
bind_socket
,
ZMQ_SNDHWM
,
&
sndhwm_read
,
&
sndhwm_read_size
);
assert
(
rc
==
0
);
assert
(
val
==
70
);
assert
(
sndhwm_read
==
sndhwm
);
msleep
(
SETTLE_TIME
);
// Read out all data (should get up to previous hwm worth so none were dropped)
int
read_count
=
0
;
int
read_data
=
0
;
while
(
read_count
<
MAX_SENDS
&&
zmq_recv
(
connect_socket
,
&
read_data
,
sizeof
(
read_data
),
ZMQ_DONTWAIT
)
==
sizeof
(
read_data
))
{
while
(
read_count
<
MAX_SENDS
&&
zmq_recv
(
connect_socket
,
&
read_data
,
sizeof
(
read_data
),
ZMQ_DONTWAIT
)
==
sizeof
(
read_data
))
{
assert
(
read_count
==
read_data
);
++
read_count
;
}
assert
(
read_count
==
101
);
assert
(
read_count
==
send_count
);
// Give io thread some time to catch up
msleep
(
SETTLE_TIME
);
// Fill up to new hwm
send_count
=
0
;
while
(
send_count
<
MAX_SENDS
&&
zmq_send
(
bind_socket
,
&
send_count
,
sizeof
(
send_count
),
ZMQ_DONTWAIT
)
==
sizeof
(
send_count
))
++
send_count
;
// Really this should be 71, but the lwm stuff kicks in doesn't seem quite right
assert
(
send_count
>
0
);
test_fill_up_to_hwm
(
bind_socket
,
sndhwm
);
zmq_close
(
bind_socket
);
zmq_close
(
connect_socket
);
...
...
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