Browse Source

tdf#107038 Poco::Timestamp replacement with std::chrono

Replaced Poco::DateTimeFormatter with Util::getHttpTimeNow

Change-Id: I1a8591a434140270929406386218d08c71a888cc
Reviewed-on: https://gerrit.libreoffice.org/78700
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
DarkByt31 2 months ago
parent
commit
8aea22a32b
4 changed files with 8 additions and 6 deletions
  1. 1 1
      net/Socket.cpp
  2. 1 1
      tools/WebSocketDump.cpp
  3. 2 2
      wsd/LOOLWSD.cpp
  4. 4 2
      wsd/TraceFile.hpp

+ 1 - 1
net/Socket.cpp

@@ -415,7 +415,7 @@ void StreamSocket::dumpState(std::ostream& os)
 void StreamSocket::send(Poco::Net::HTTPResponse& response)
 {
     response.set("User-Agent", HTTP_AGENT_STRING);
-    response.set("Date", Poco::DateTimeFormatter::format(Poco::Timestamp(), Poco::DateTimeFormat::HTTP_FORMAT));
+    response.set("Date", Util::getHttpTimeNow());
 
     std::ostringstream oss;
     response.write(oss);

+ 1 - 1
tools/WebSocketDump.cpp

@@ -161,7 +161,7 @@ private:
             // Bad request.
             std::ostringstream oss;
             oss << "HTTP/1.1 400\r\n"
-                << "Date: " << Poco::DateTimeFormatter::format(Poco::Timestamp(), Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n"
+                << "Date: " << Util::getHttpTimeNow() << "\r\n"
                 << "User-Agent: LOOLWSD WOPI Agent\r\n"
                 << "Content-Length: 0\r\n"
                 << "\r\n";

+ 2 - 2
wsd/LOOLWSD.cpp

@@ -2438,7 +2438,7 @@ private:
             // Bad request.
             std::ostringstream oss;
             oss << "HTTP/1.1 400\r\n"
-                << "Date: " << Poco::DateTimeFormatter::format(Poco::Timestamp(), Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n"
+                << "Date: " << Util::getHttpTimeNow() << "\r\n"
                 << "User-Agent: LOOLWSD WOPI Agent\r\n"
                 << "Content-Length: 0\r\n"
                 << "\r\n"
@@ -2740,7 +2740,7 @@ private:
                 LOG_ERR("Download file [" << filePathAnonym << "] not found.");
                 std::ostringstream oss;
                 oss << "HTTP/1.1 404 Not Found\r\n"
-                    << "Date: " << Poco::DateTimeFormatter::format(Poco::Timestamp(), Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n"
+                    << "Date: " << Util::getHttpTimeNow() << "\r\n"
                     << "User-Agent: " << HTTP_AGENT_STRING << "\r\n"
                     << "Content-Length: 0\r\n"
                     << "\r\n";

+ 4 - 2
wsd/TraceFile.hpp

@@ -91,7 +91,8 @@ public:
                     const bool compress,
                     const bool takeSnapshot,
                     const std::vector<std::string>& filters) :
-        _epochStart(Poco::Timestamp().epochMicroseconds()),
+        _epochStart(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now()
+                                                            .time_since_epoch()).count()),
         _recordOutgoing(recordOugoing),
         _compress(compress),
         _takeSnapshot(takeSnapshot),
@@ -258,7 +259,8 @@ private:
     {
         Util::assertIsLocked(_mutex);
 
-        const Poco::Int64 usec = Poco::Timestamp().epochMicroseconds() - _epochStart;
+        const Poco::Int64 usec = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono
+                                        ::system_clock::now().time_since_epoch()).count() - _epochStart;
         if (_compress)
         {
             _deflater.write(&delim, 1);