]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
RemoteLogger: Use the simpler lock_guard instead of unique_lock
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 8 Dec 2020 15:35:42 +0000 (16:35 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 5 Jan 2021 09:25:41 +0000 (10:25 +0100)
pdns/remote_logger.cc

index 10101cebda01fe539a6886b5ceb7f6e9cefe180d..a6074271c0e200bcf92016d901e003497a78b9c7 100644 (file)
@@ -116,7 +116,7 @@ bool RemoteLogger::reconnect()
     {
       /* we are now successfully connected, time to take the lock and update the
          socket */
-      std::unique_lock<std::mutex> lock(d_mutex);
+      std::lock_guard<std::mutex> lock(d_mutex);
       d_socket = std::move(newSock);
     }
   }
@@ -138,7 +138,7 @@ void RemoteLogger::queueData(const std::string& data)
     throw std::runtime_error("Got a request to write an object of size " + data.size());
   }
 
-  std::unique_lock<std::mutex> lock(d_mutex);
+  std::lock_guard<std::mutex> lock(d_mutex);
 
   if (!d_writer.hasRoomFor(data)) {
     /* not connected, queue is full, just drop */
@@ -198,7 +198,7 @@ try
     if (connected) {
       try {
         /* we don't want to take the lock while trying to reconnect */
-        std::unique_lock<std::mutex> lock(d_mutex);
+        std::lock_guard<std::mutex> lock(d_mutex);
         if (d_socket) { // check if it is set
           /* if flush() returns false, it means that we couldn't flush anything yet
              either because there is nothing to flush, or because the outgoing TCP