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
46c5a239
Commit
46c5a239
authored
Nov 19, 2013
by
Richard Newton
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #758 from hintjens/master
Fixed test_many_sockets
parents
0ee76912
4d22d456
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
42 deletions
+31
-42
test_many_sockets.cpp
tests/test_many_sockets.cpp
+31
-42
No files found.
tests/test_many_sockets.cpp
View file @
46c5a239
...
...
@@ -23,76 +23,65 @@
#include <stdlib.h>
#include <vector>
void
test_system_max
()
{
// Keep allocating sockets until we run out of system resources
const
int
no_of_sockets
=
2
*
65536
;
void
*
ctx
=
zmq_ctx_new
();
zmq_ctx_set
(
ctx
,
ZMQ_MAX_SOCKETS
,
no_of_sockets
);
std
::
vector
<
void
*>
sockets
;
void
*
ctx
=
zmq_ctx_new
();
zmq_ctx_set
(
ctx
,
ZMQ_MAX_SOCKETS
,
no_of_sockets
);
std
::
vector
<
void
*>
sockets
;
while
(
true
)
{
void
*
socket
=
zmq_socket
(
ctx
,
ZMQ_PAIR
);
while
(
true
)
{
void
*
socket
=
zmq_socket
(
ctx
,
ZMQ_PAIR
);
if
(
!
socket
)
break
;
sockets
.
push_back
(
socket
);
sockets
.
push_back
(
socket
);
}
assert
((
int
)
sockets
.
size
()
<
no_of_sockets
);
assert
((
int
)
sockets
.
size
()
<
no_of_sockets
);
// System is out of resources, further calls to zmq_socket should return NULL.
for
(
unsigned
int
i
=
0
;
i
<
10
;
++
i
)
{
void
*
socket
=
zmq_socket
(
ctx
,
ZMQ_PAIR
);
assert
(
socket
==
NULL
);
// System is out of resources, further calls to zmq_socket should return NULL
for
(
unsigned
int
i
=
0
;
i
<
10
;
++
i
)
{
void
*
socket
=
zmq_socket
(
ctx
,
ZMQ_PAIR
);
assert
(
socket
==
NULL
);
}
// Clean up.
for
(
unsigned
int
i
=
0
;
i
<
sockets
.
size
();
++
i
)
zmq_close
(
sockets
[
i
]);
for
(
unsigned
int
i
=
0
;
i
<
sockets
.
size
();
++
i
)
zmq_close
(
sockets
[
i
]);
zmq_ctx_destroy
(
ctx
);
zmq_ctx_destroy
(
ctx
);
}
void
test_zmq_default_max
()
{
// Keep allocating sockets until we hit the default zeromq limit
void
*
ctx
=
zmq_ctx_new
();
// Keep allocating sockets until we hit the default limit
void
*
ctx
=
zmq_ctx_new
();
std
::
vector
<
void
*>
sockets
;
while
(
true
)
{
void
*
socket
=
zmq_socket
(
ctx
,
ZMQ_PAIR
);
while
(
true
)
{
void
*
socket
=
zmq_socket
(
ctx
,
ZMQ_PAIR
);
if
(
!
socket
)
break
;
sockets
.
push_back
(
socket
);
sockets
.
push_back
(
socket
);
}
// We may stop sooner if system has fewer available sockets
assert
(
sockets
.
size
()
<=
ZMQ_MAX_SOCKETS_DFLT
);
assert
(
sockets
.
size
()
==
ZMQ_MAX_SOCKETS_DFLT
);
// At zeromq max, further calls to zmq_socket should return NULL.
for
(
unsigned
int
i
=
0
;
i
<
10
;
++
i
)
{
void
*
socket
=
zmq_socket
(
ctx
,
ZMQ_PAIR
);
assert
(
socket
==
NULL
);
// Further calls to zmq_socket should return NULL
for
(
unsigned
int
i
=
0
;
i
<
10
;
++
i
)
{
void
*
socket
=
zmq_socket
(
ctx
,
ZMQ_PAIR
);
assert
(
socket
==
NULL
);
}
//
Clean up.
for
(
unsigned
int
i
=
0
;
i
<
sockets
.
size
();
++
i
)
zmq_close
(
sockets
[
i
]);
//
Clean up
for
(
unsigned
int
i
=
0
;
i
<
sockets
.
size
();
++
i
)
zmq_close
(
sockets
[
i
]);
zmq_ctx_destroy
(
ctx
);
zmq_ctx_destroy
(
ctx
);
}
int
main
(
void
)
int
main
(
void
)
{
setup_test_environment
();
setup_test_environment
();
test_system_max
();
test_zmq_default_max
();
...
...
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