Skip to content

Commit

Permalink
Added testcase for LIBZMQ-84
Browse files Browse the repository at this point in the history
  • Loading branch information
hintjens committed Jan 1, 2013
1 parent 82ff0e8 commit 37a06a1
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions 84/issue.c
@@ -0,0 +1,37 @@
#include <zmq.h>
#include <assert.h>

// Use the following command to check for sockets left in TIME_WAIT
// due to creation of emulated socketpair in Windows.
// netstat -an | grep 5905

// With the patch, this test program should run to completion and yield
// no additional TIME_WAIT entries

// Without the patch, "Address already in use (signaler.cpp)" assertion
// will occur and netstat will be filled with TIME_WAIT entries.
// Windows XP is more susceptible to this exception as it has less
// ephemeral ports than newer versions of Windows.

// On Windows XP, the program below will assert before loop iteration 1000

int main (void)
{
int cnt = 0;
for (cnt=0; cnt < 10000; cnt++) {
// 3 signaling mailboxes are created per context
void *ctx = zmq_ctx_new();
assert (ctx);
// 1 signaling mailbox is created per zmq socket
void *sock = zmq_socket (ctx, ZMQ_DEALER);
assert (sock);
int rc = zmq_close (sock);
assert (rc == 0);
rc = zmq_ctx_destroy(ctx);
assert (rc == 0);

if (cnt && cnt % 100==0)
printf("%d\n", cnt);
}
return 0;
}

0 comments on commit 37a06a1

Please sign in to comment.