More clean-ups
[invirt/third/libt4.git] / lock_tester.cc
index f8e2196..0204a71 100644 (file)
@@ -4,7 +4,6 @@
 
 #include "lock_client.h"
 #include <arpa/inet.h>
-#include <sys/types.h>
 #include <unistd.h>
 
 char log_thread_prefix = 'c';
@@ -27,8 +26,7 @@ void check_grant(lock_protocol::lockid_t lid) {
     lock ml(count_mutex);
     int x = lid[0] & 0x0f;
     if (ct[x] != 0) {
-        cout << "error: server granted " << lid << " twice" << endl;
-        cerr << "error: server granted " << lid << " twice" << endl;
+        LOG_NONMEMBER("error: server granted " << lid << " twice");
         exit(1);
     }
     ct[x] += 1;
@@ -38,7 +36,7 @@ void check_release(lock_protocol::lockid_t lid) {
     lock ml(count_mutex);
     int x = lid[0] & 0x0f;
     if (ct[x] != 1) {
-        cerr << "error: client released un-held lock " << lid << endl;
+        LOG_NONMEMBER("error: client released un-held lock " << lid);
         exit(1);
     }
     ct[x] -= 1;
@@ -71,7 +69,7 @@ void test2(int i) {
     lc[i]->acquire(a);
     LOG_NONMEMBER("test2: client " << i << " acquire done");
     check_grant(a);
-    sleep(1);
+    usleep(100000);
     LOG_NONMEMBER("test2: client " << i << " release");
     check_release(a);
     lc[i]->release(a);
@@ -124,7 +122,7 @@ main(int argc, char *argv[])
     srandom((uint32_t)getpid());
 
     if (argc < 2) {
-        cerr << "Usage: " << argv[0] << " [host:]port [test]" << endl;
+        LOG_NONMEMBER("Usage: " << argv[0] << " [host:]port [test]");
         exit(1);
     }