libt2n: (tomj) made reentrant unit-test more robust. Gave the guard_handle a lot...
[libt2n] / test / reentrant.cpp
index bb9420a..c08df62 100644 (file)
@@ -38,7 +38,7 @@ using namespace libt2n;
 namespace
 {
 
-command_server *global_server;
+command_server *global_server = NULL;
 
 string testfunc(const string& str)
 {
@@ -46,7 +46,8 @@ string testfunc(const string& str)
     ret=str+", testfunc() was here";
 
     // call handle, eventually reentrant
-    global_server->handle(1000);
+    if (global_server)
+        global_server->handle(1000);
 
     return ret;
 }
@@ -146,7 +147,7 @@ class test_reentrant : public TestFixture
             // child
             {
                 // wait till server is up
-                sleep(1);
+                sleep(3);
 
                 // we want 8 identical childs hammering the server
                 fork();
@@ -182,6 +183,8 @@ class test_reentrant : public TestFixture
                 long long maxtime=5000000;
                 while(maxtime > 0)
                     cs.handle(maxtime,&maxtime);
+                    
+                global_server = NULL;
             }
 
             // we are still alive, everything is ok