]> git.sesse.net Git - cubemap/blobdiff - accesslog.cpp
Enable RX support for kTLS.
[cubemap] / accesslog.cpp
index af53872e6ec03c0d68f83b86e4b9c9f83320eb6d..2d5eb0503e9ac00ab2c0bd7207f31eda61f1fa82 100644 (file)
@@ -7,25 +7,22 @@
 #include "accesslog.h"
 #include "client.h"
 #include "log.h"
-#include "mutexlock.h"
 #include "timespec.h"
 
 using namespace std;
 
 AccessLogThread::AccessLogThread()
 {
-       pthread_mutex_init(&mutex, NULL);
 }
 
 AccessLogThread::AccessLogThread(const string &filename)
        : filename(filename) {
-       pthread_mutex_init(&mutex, NULL);
 }
 
 void AccessLogThread::write(const ClientStats& client)
 {
        {
-               MutexLock lock(&mutex);
+               lock_guard<mutex> lock(mu);
                pending_writes.push_back(client);
        }
        wakeup();
@@ -35,10 +32,10 @@ void AccessLogThread::do_work()
 {
        // Open the file.
        if (filename.empty()) {
-               logfp = NULL;
+               logfp = nullptr;
        } else {
                logfp = fopen(filename.c_str(), "a+");
-               if (logfp == NULL) {
+               if (logfp == nullptr) {
                        log_perror(filename.c_str());
                        // Continue as before.
                }
@@ -48,11 +45,11 @@ void AccessLogThread::do_work()
                // Empty the queue.
                vector<ClientStats> writes;
                {
-                       MutexLock lock(&mutex);
+                       lock_guard<mutex> lock(mu);
                        swap(pending_writes, writes);
                }
 
-               if (logfp != NULL) {
+               if (logfp != nullptr) {
                        // Do the actual writes.
                        timespec now_monotonic;
                        timespec now_realtime;
@@ -82,14 +79,14 @@ void AccessLogThread::do_work()
 
                // Wait until we are being woken up, either to quit or because
                // there is material in pending_writes.
-               wait_for_wakeup(NULL);
+               wait_for_wakeup(nullptr);
        }
 
-       if (logfp != NULL) {    
+       if (logfp != nullptr) { 
                if (fclose(logfp) == EOF) {
                        log_perror("fclose");
                }
        }
 
-       logfp = NULL;
+       logfp = nullptr;
 }