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
4aaf3e63
Commit
4aaf3e63
authored
Jun 12, 2012
by
Ian Barber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Add disconnect test"
This reverts commit
d8f3487e
.
parent
eb14890d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
118 deletions
+3
-118
test_connect_delay.cpp
tests/test_connect_delay.cpp
+3
-118
No files found.
tests/test_connect_delay.cpp
View file @
4aaf3e63
...
...
@@ -27,111 +27,6 @@
#include "../include/zmq.h"
static
void
*
server
(
void
*
c
)
{
void
*
socket
,
*
context
;
char
buffer
[
16
];
int
rc
,
val
;
shoulddie
=
*
(
long
*
)
sd
;
context
=
zmq_init
(
1
);
assert
(
context
);
socket
=
zmq_socket
(
context
,
ZMQ_PULL
);
assert
(
socket
);
val
=
0
;
rc
=
zmq_setsockopt
(
socket
,
ZMQ_LINGER
,
&
val
,
sizeof
(
val
));
assert
(
rc
==
0
);
rc
=
zmq_bind
(
socket
,
"ipc:///tmp/recon"
);
assert
(
rc
==
0
);
memset
(
&
buffer
,
0
,
sizeof
(
buffer
));
rc
=
zmq_recv
(
socket
,
&
buffer
,
sizeof
(
buffer
),
0
);
// Intentionally bail out
rc
=
zmq_close
(
socket
);
assert
(
rc
==
0
);
rc
=
zmq_term
(
context
);
assert
(
rc
==
0
);
usleep
(
200000
);
context
=
zmq_init
(
1
);
assert
(
context
);
socket
=
zmq_socket
(
context
,
ZMQ_PULL
);
assert
(
socket
);
val
=
0
;
rc
=
zmq_setsockopt
(
socket
,
ZMQ_LINGER
,
&
val
,
sizeof
(
val
));
assert
(
rc
==
0
);
rc
=
zmq_bind
(
socket
,
"ipc:///tmp/recon"
);
assert
(
rc
==
0
);
usleep
(
200000
);
memset
(
&
buffer
,
0
,
sizeof
(
buffer
));
rc
=
zmq_recv
(
socket
,
&
buffer
,
sizeof
(
buffer
),
ZMQ_DONTWAIT
);
assert
(
rc
!=
-
1
);
// Start closing the socket while the connecting process is underway.
rc
=
zmq_close
(
socket
);
assert
(
rc
==
0
);
rc
=
zmq_term
(
context
);
assert
(
rc
==
0
);
pthread_exit
(
NULL
);
}
static
void
*
worker
(
void
*
n
)
{
void
*
socket
,
*
context
;
int
rc
,
hadone
,
val
;
context
=
zmq_init
(
1
);
assert
(
context
);
socket
=
zmq_socket
(
context
,
ZMQ_PUSH
);
assert
(
socket
);
val
=
0
;
rc
=
zmq_setsockopt
(
socket
,
ZMQ_LINGER
,
&
val
,
sizeof
(
val
));
assert
(
rc
==
0
);
val
=
1
;
rc
=
zmq_setsockopt
(
socket
,
ZMQ_DELAY_ATTACH_ON_CONNECT
,
&
val
,
sizeof
(
val
));
assert
(
rc
==
0
);
rc
=
zmq_connect
(
socket
,
"ipc:///tmp/recon"
);
assert
(
rc
==
0
);
hadone
=
0
;
// Not checking RC as some may be -1
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
usleep
(
200000
);
rc
=
zmq_send
(
socket
,
"hi"
,
2
,
ZMQ_DONTWAIT
);
if
(
rc
!=
-
1
)
hadone
++
;
}
assert
(
hadone
>=
2
);
assert
(
hadone
<
4
);
rc
=
zmq_close
(
socket
);
assert
(
rc
==
0
);
rc
=
zmq_term
(
context
);
assert
(
rc
==
0
);
pthread_exit
(
NULL
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
fprintf
(
stderr
,
"test_connect_delay running...
\n
"
);
...
...
@@ -174,7 +69,7 @@ int main (int argc, char *argv [])
seen
=
0
;
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
memset
(
&
buffer
,
0
,
sizeof
(
buffer
));
memset
(
&
buffer
,
0
,
sizeof
(
buffer
));
rc
=
zmq_recv
(
to
,
&
buffer
,
sizeof
(
buffer
),
ZMQ_DONTWAIT
);
if
(
rc
==
-
1
)
break
;
...
...
@@ -244,19 +139,9 @@ int main (int argc, char *argv [])
rc
=
zmq_close
(
to
);
assert
(
rc
==
0
);
rc
=
zmq_ctx_destroy
(
context
);
assert
(
rc
==
0
);
fprintf
(
stderr
,
" Running DELAY_ATTACH_ON_CONNECT with disconnect
\n
"
);
pthread_t
serv
,
work
;
rc
=
pthread_create
(
&
serv
,
NULL
,
server
,
NULL
);
rc
=
zmq_ctx_destroy
(
context
);
assert
(
rc
==
0
);
rc
=
pthread_create
(
&
work
,
NULL
,
worker
,
NULL
);
assert
(
rc
==
0
);
pthread_exit
(
NULL
);
return
0
;
}
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