Major clean-ups. Migrating to C++11.
[invirt/third/libt4.git] / lock_server.cc
index 3801814..be0c1c9 100644 (file)
@@ -5,6 +5,7 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <arpa/inet.h>
+#include "lock.h"
 
 lock_server::lock_server():
     nacquire (0)
@@ -14,11 +15,10 @@ lock_server::lock_server():
 // caller must hold lock_lock
 mutex &
 lock_server::get_lock(lock_protocol::lockid_t lid) {
-    lock_lock.acquire();
+    lock ml(lock_lock);
     // by the semantics of std::map, this will create
     // the mutex if it doesn't already exist
     mutex &l = locks[lid];
-    lock_lock.release();
     return l;
 }
 
@@ -34,13 +34,13 @@ lock_server::stat(int clt, lock_protocol::lockid_t lid, int &r)
 lock_protocol::status
 lock_server::acquire(int clt, lock_protocol::lockid_t lid, int &r)
 {
-    get_lock(lid).acquire();
+    get_lock(lid).lock();
     return lock_protocol::OK;
 }
 
 lock_protocol::status
 lock_server::release(int clt, lock_protocol::lockid_t lid, int &r)
 {
-    get_lock(lid).release();
+    get_lock(lid).unlock();
     return lock_protocol::OK;
 }