X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/8b9d106fcc61fc84712c97d4db060d8302cc63fd..f0dcb6b97d6d40f67698d1f71ac26970f1776f82:/lock_tester.cc diff --git a/lock_tester.cc b/lock_tester.cc index b2df781..f535d8f 100644 --- a/lock_tester.cc +++ b/lock_tester.cc @@ -10,24 +10,23 @@ char log_thread_prefix = 'c'; // must be >= 2 const int nt = 6; //XXX: lab1's rpc handlers are blocking. Since rpcs uses a thread pool of 10 threads, we cannot test more than 10 blocking rpc. -string dst; -lock_client **lc = new lock_client * [nt]; -lock_protocol::lockid_t a = "1"; -lock_protocol::lockid_t b = "2"; -lock_protocol::lockid_t c = "3"; +static string dst; +static lock_client **lc = new lock_client * [nt]; +static lock_protocol::lockid_t a = "1"; +static lock_protocol::lockid_t b = "2"; +static lock_protocol::lockid_t c = "3"; // check_grant() and check_release() check that the lock server // doesn't grant the same lock to both clients. // it assumes that lock names are distinct in the first byte. -int ct[256]; -mutex count_mutex; +static int ct[256]; +static mutex count_mutex; 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; @@ -37,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; @@ -123,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); }