fixes #418 Test inproc_lat hangs with roundtrip less than 5
fixes #486 test inproc_thr not work.
diff --git a/perf/inproc_lat.c b/perf/inproc_lat.c
index dac16ed..7322ad7 100644
--- a/perf/inproc_lat.c
+++ b/perf/inproc_lat.c
@@ -1,5 +1,6 @@
 /*
     Copyright (c) 2012 Martin Sustrik  All rights reserved.
+    Copyright 2017 Garrett D'Amore <garrett@damore.org>
 
     Permission is hereby granted, free of charge, to any person obtaining a copy
     of this software and associated documentation files (the "Software"),
@@ -38,17 +39,14 @@
 static size_t message_size;
 static int roundtrip_count;
 
-void worker (NN_UNUSED void *arg)
+void worker (void *arg)
 {
     int rc;
     int s;
     int i;
     char *buf;
 
-    s = nn_socket (AF_SP, NN_PAIR);
-    assert (s != -1);
-    rc = nn_connect (s, "inproc://inproc_lat");
-    assert (rc >= 0);
+    s = *(int *)arg;
 
     buf = malloc (message_size);
     assert (buf);
@@ -61,14 +59,13 @@
     }
 
     free (buf);
-    rc = nn_close (s);
-    assert (rc == 0);
 }
 
 int main (int argc, char *argv [])
 {
     int rc;
     int s;
+    int w;
     int i;
     char *buf;
     struct nn_thread thread;
@@ -89,12 +86,17 @@
     rc = nn_bind (s, "inproc://inproc_lat");
     assert (rc >= 0);
 
+    w = nn_socket (AF_SP, NN_PAIR);
+    assert (w != -1);
+    rc = nn_connect (w, "inproc://inproc_lat");
+    assert (rc >= 0);
+
     buf = malloc (message_size);
     assert (buf);
     memset (buf, 111, message_size);
 
     /*  Wait a bit till the worker thread blocks in nn_recv(). */
-    nn_thread_init (&thread, worker, NULL);
+    nn_thread_init (&thread, worker, &w);
     nn_sleep (100);
 
     nn_stopwatch_init (&stopwatch);
@@ -117,6 +119,8 @@
     free (buf);
     rc = nn_close (s);
     assert (rc == 0);
+    rc = nn_close (w);
+    assert (rc == 0);
 
     return 0;
 }
diff --git a/perf/inproc_thr.c b/perf/inproc_thr.c
index 4a04d96..7e794d4 100644
--- a/perf/inproc_thr.c
+++ b/perf/inproc_thr.c
@@ -1,5 +1,6 @@
 /*
     Copyright (c) 2012 Martin Sustrik  All rights reserved.
+    Copyright 2017 Garrett D'Amore <garrett@damore.org>
 
     Permission is hereby granted, free of charge, to any person obtaining a copy
     of this software and associated documentation files (the "Software"),
@@ -37,17 +38,14 @@
 static size_t message_size;
 static int message_count;
 
-void worker (NN_UNUSED void *arg)
+void worker (void *arg)
 {
     int rc;
     int s;
     int i;
     char *buf;
 
-    s = nn_socket (AF_SP, NN_PAIR);
-    assert (s != -1);
-    rc = nn_connect (s, "inproc://inproc_thr");
-    assert (rc >= 0);
+    s = *(int *)arg;
 
     buf = malloc (message_size);
     assert (buf);
@@ -62,14 +60,13 @@
     }
 
     free (buf);
-    rc = nn_close (s);
-    assert (rc == 0);
 }
 
 int main (int argc, char *argv [])
 {
     int rc;
     int s;
+    int w;
     int i;
     char *buf;
     struct nn_thread thread;
@@ -91,10 +88,15 @@
     rc = nn_bind (s, "inproc://inproc_thr");
     assert (rc >= 0);
 
+    w = nn_socket (AF_SP, NN_PAIR);
+    assert (w != -1);
+    rc = nn_connect (w, "inproc://inproc_thr");
+    assert (rc >= 0);
+
     buf = malloc (message_size);
     assert (buf);
 
-    nn_thread_init (&thread, worker, NULL);
+    nn_thread_init (&thread, worker, &w);
 
     /*  First message is used to start the stopwatch. */
     rc = nn_recv (s, buf, message_size, 0);
@@ -113,6 +115,8 @@
     free (buf);
     rc = nn_close (s);
     assert (rc == 0);
+    rc = nn_close (w);
+    assert (rc == 0);
 
     if (elapsed == 0)
         elapsed = 1;