[Libreoffice-commits] online.git: Branch 'private/Ashod/nonblocking' - net/loolnb.cpp net/socket.hpp

Michael Meeks michael.meeks at collabora.com
Mon Feb 20 22:15:29 UTC 2017


 net/loolnb.cpp |    7 +++++--
 net/socket.hpp |   22 ++++++++++++++--------
 2 files changed, 19 insertions(+), 10 deletions(-)

New commits:
commit f8bd957736c5aa78bbd3929dbe3d2c9a08114548
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Feb 20 22:14:55 2017 +0000

    Restore plain HTTP, and add 'ssl' parameter to loolnb.

diff --git a/net/loolnb.cpp b/net/loolnb.cpp
index c6abe72..b86e4e7 100644
--- a/net/loolnb.cpp
+++ b/net/loolnb.cpp
@@ -417,7 +417,7 @@ void server(const Poco::Net::SocketAddress& addr, SocketPoll& clientPoller)
     }
 }
 
-int main(int, const char**)
+int main(int argc, const char**argv)
 {
     // TODO: These would normally come from config.
     SslContext::initialize("/etc/loolwsd/cert.pem",
@@ -437,7 +437,10 @@ int main(int, const char**)
     });
 
     // Start the server.
-    server<SimpleResponseClient<SslStreamSocket>>(addrSsl, poller);
+    if (!strcmp(argv[argc-1], "ssl"))
+        server<SimpleResponseClient<SslStreamSocket>>(addrSsl, poller);
+    else
+        server<SimpleResponseClient<StreamSocket>>(addrHttp, poller);
 
     std::cout << "Shutting down server." << std::endl;
 
diff --git a/net/socket.hpp b/net/socket.hpp
index 25a335c..d9b5842 100644
--- a/net/socket.hpp
+++ b/net/socket.hpp
@@ -382,16 +382,10 @@ public:
     }
 
     /// Override to handle reading of socket data differently.
-    virtual int readData(char* buf, int len)
-    {
-        return ::read(getFD(), buf, len);
-    }
+    virtual int readData(char* buf, int len) = 0;
 
     /// Override to handle writing data to socket differently.
-    virtual int writeData(const char* buf, const int len)
-    {
-        return ::write(getFD(), buf, len);
-    }
+    virtual int writeData(const char* buf, const int len) = 0;
 
     int getPollEvents() override
     {
@@ -423,6 +417,18 @@ protected:
     {
     }
 
+    /// Override to handle reading of socket data differently.
+    virtual int readData(char* buf, int len)
+    {
+        return ::read(getFD(), buf, len);
+    }
+
+    /// Override to handle writing data to socket differently.
+    virtual int writeData(const char* buf, const int len)
+    {
+        return ::write(getFD(), buf, len);
+    }
+
     // Will construct us upon accept.
     template<class T> friend class ServerSocket;
 };


More information about the Libreoffice-commits mailing list