From: Thomas Jarosch Date: Mon, 24 Nov 2008 22:15:23 +0000 (+0000) Subject: libt2n: (tomj) made reentrant unit-test more robust. Gave the guard_handle a lot... X-Git-Tag: v0.5~8 X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=commitdiff_plain;h=d55e0d0f9f17e1706e9751b7e920479f31370f51 libt2n: (tomj) made reentrant unit-test more robust. Gave the guard_handle a lot of thought (volatile/atomic operations) -> it's fine. --- diff --git a/test/reentrant.cpp b/test/reentrant.cpp index bb9420a..c08df62 100644 --- a/test/reentrant.cpp +++ b/test/reentrant.cpp @@ -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