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
cfc754f3
Commit
cfc754f3
authored
May 23, 2014
by
Pieter Hintjens
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1020 from jemc/inproc_simult
Add failing test reproducing issue #1015.
parents
ac244b41
8b47d368
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
0 deletions
+71
-0
test_inproc_connect.cpp
tests/test_inproc_connect.cpp
+71
-0
No files found.
tests/test_inproc_connect.cpp
View file @
cfc754f3
...
...
@@ -36,6 +36,40 @@ static void pusher (void *ctx)
assert
(
rc
==
0
);
}
static
void
simult_conn
(
void
*
payload
)
{
// Pull out arguments - context followed by endpoint string
void
*
ctx
=
(
void
*
)((
void
**
)
payload
)[
0
];
char
*
endpt
=
(
char
*
)((
void
**
)
payload
)[
1
];
// Connect
void
*
connectSocket
=
zmq_socket
(
ctx
,
ZMQ_SUB
);
assert
(
connectSocket
);
int
rc
=
zmq_connect
(
connectSocket
,
endpt
);
assert
(
rc
==
0
);
// Cleanup
rc
=
zmq_close
(
connectSocket
);
assert
(
rc
==
0
);
}
static
void
simult_bind
(
void
*
payload
)
{
// Pull out arguments - context followed by endpoint string
void
*
ctx
=
(
void
*
)((
void
**
)
payload
)[
0
];
char
*
endpt
=
(
char
*
)((
void
**
)
payload
)[
1
];
// Bind
void
*
bindSocket
=
zmq_socket
(
ctx
,
ZMQ_PUB
);
assert
(
bindSocket
);
int
rc
=
zmq_bind
(
bindSocket
,
endpt
);
assert
(
rc
==
0
);
// Cleanup
rc
=
zmq_close
(
bindSocket
);
assert
(
rc
==
0
);
}
void
test_bind_before_connect
()
{
void
*
ctx
=
zmq_ctx_new
();
...
...
@@ -268,6 +302,42 @@ void test_multiple_threads ()
assert
(
rc
==
0
);
}
void
test_simultaneous_connect_bind_threads
()
{
const
unsigned
int
no_of_times
=
50
;
void
*
ctx
=
zmq_ctx_new
();
assert
(
ctx
);
void
*
threads
[
no_of_times
*
2
];
void
*
thr_args
[
no_of_times
][
2
];
char
endpts
[
no_of_times
][
20
];
// Set up thread arguments: context followed by endpoint string
for
(
unsigned
int
i
=
0
;
i
<
no_of_times
;
++
i
)
{
thr_args
[
i
][
0
]
=
(
void
*
)
ctx
;
thr_args
[
i
][
1
]
=
(
void
*
)
endpts
[
i
];
sprintf
(
endpts
[
i
],
"inproc://foo_%d"
,
i
);
}
// Spawn all threads as simultaneously as possible
for
(
unsigned
int
i
=
0
;
i
<
no_of_times
;
++
i
)
{
threads
[
i
*
2
+
0
]
=
zmq_threadstart
(
&
simult_conn
,
(
void
*
)
thr_args
[
i
]);
threads
[
i
*
2
+
1
]
=
zmq_threadstart
(
&
simult_bind
,
(
void
*
)
thr_args
[
i
]);
}
// Close all threads
for
(
unsigned
int
i
=
0
;
i
<
no_of_times
;
++
i
)
{
zmq_threadclose
(
threads
[
i
*
2
+
0
]);
zmq_threadclose
(
threads
[
i
*
2
+
1
]);
}
int
rc
=
zmq_ctx_term
(
ctx
);
assert
(
rc
==
0
);
}
void
test_identity
()
{
// Create the infrastructure
...
...
@@ -350,6 +420,7 @@ int main (void)
test_connect_before_bind_pub_sub
();
test_multiple_connects
();
test_multiple_threads
();
test_simultaneous_connect_bind_threads
();
test_identity
();
test_connect_only
();
...
...
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