[Libreoffice-commits] online.git: loolwsd/LOOLBroker.cpp loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp

Henry Castro hcastro at collabora.com
Tue Feb 2 01:52:55 UTC 2016


 loolwsd/LOOLBroker.cpp |   30 +++++++++++++++---------------
 loolwsd/LOOLKit.cpp    |   16 +++++++++-------
 loolwsd/LOOLWSD.cpp    |    8 ++++----
 3 files changed, 28 insertions(+), 26 deletions(-)

New commits:
commit 5fd2be332a6f1b7ae90ecdf8b4b2605768a9c730
Author: Henry Castro <hcastro at collabora.com>
Date:   Mon Feb 1 21:51:42 2016 -0400

    loolwsd: use EXIT_SOFTWARE to indicate internal error

diff --git a/loolwsd/LOOLBroker.cpp b/loolwsd/LOOLBroker.cpp
index 24e8d94..aa9d07a 100644
--- a/loolwsd/LOOLBroker.cpp
+++ b/loolwsd/LOOLBroker.cpp
@@ -229,7 +229,7 @@ namespace
             {
                 Log::error("Error: link(\"" + std::string(fpath) + "\",\"" + newPath.toString() +
                            "\") failed. Exiting.");
-                exit(1);
+                exit(Application::EXIT_SOFTWARE);
             }
             break;
         case FTW_DP:
@@ -592,7 +592,7 @@ static int createLibreOfficeKit(const bool sharePages,
         {
             // child
             lokit_main(loSubPath, jailId, pipe);
-            _exit(0);
+            _exit(Application::EXIT_OK);
         }
         else
         {
@@ -730,37 +730,37 @@ int main(int argc, char** argv)
     if (loSubPath.empty())
     {
         Log::error("Error: --losubpath is empty");
-        exit(-1);
+        exit(Application::EXIT_SOFTWARE);
     }
 
     if (sysTemplate.empty())
     {
         Log::error("Error: --losubpath is empty");
-        exit(-1);
+        exit(Application::EXIT_SOFTWARE);
     }
 
     if (loTemplate.empty())
     {
         Log::error("Error: --lotemplate is empty");
-        exit(-1);
+        exit(Application::EXIT_SOFTWARE);
     }
 
     if (childRoot.empty())
     {
         Log::error("Error: --childroot is empty");
-        exit(-1);
+        exit(Application::EXIT_SOFTWARE);
     }
 
     if (numPreSpawnedChildren < 1)
     {
         Log::error("Error: --numprespawns is 0");
-        exit(-1);
+        exit(Application::EXIT_SOFTWARE);
     }
 
     if ( (readerBroker = open(FIFO_FILE.c_str(), O_RDONLY) ) < 0 )
     {
         Log::error("Error: failed to open pipe [" + FIFO_FILE + "] read only. Exiting.");
-        exit(-1);
+        exit(Application::EXIT_SOFTWARE);
     }
 
     try
@@ -786,7 +786,7 @@ int main(int argc, char** argv)
     if (!File(loolkitPath).exists())
     {
         Log::error("Error: loolkit does not exists at [" + loolkitPath + "].");
-        exit(-1);
+        exit(Application::EXIT_SOFTWARE);
     }
 
     const Path jailPath = Path::forDirectory(childRoot + Path::separator() + jailId);
@@ -838,13 +838,13 @@ int main(int argc, char** argv)
     if (chroot(jailPath.toString().c_str()) == -1)
     {
         Log::error("Error: chroot(\"" + jailPath.toString() + "\") failed.");
-        exit(-1);
+        exit(Application::EXIT_SOFTWARE);
     }
 
     if (chdir("/") == -1)
     {
         Log::error("Error: chdir(\"/\") in jail failed.");
-        exit(-1);
+        exit(Application::EXIT_SOFTWARE);
     }
 
 #ifdef __linux
@@ -858,7 +858,7 @@ int main(int argc, char** argv)
     if (mkfifo(FIFO_BROKER.c_str(), 0666) == -1)
     {
         Log::error("Error: Failed to create pipe FIFO [" + FIFO_BROKER + "].");
-        exit(-1);
+        exit(Application::EXIT_SOFTWARE);
     }
 
     // Initialize LoKit and hope we can fork and save memory by sharing pages.
@@ -868,7 +868,7 @@ int main(int argc, char** argv)
     if (createLibreOfficeKit(sharePages, loSubPath, jailId) < 0)
     {
         Log::error("Error: failed to create children.");
-        exit(-1);
+        exit(Application::EXIT_SOFTWARE);
     }
 
     if (numPreSpawnedChildren > 1)
@@ -877,7 +877,7 @@ int main(int argc, char** argv)
     if ( (readerChild = open(FIFO_BROKER.c_str(), O_RDONLY) ) < 0 )
     {
         Log::error("Error: pipe opened for reading.");
-        exit(-1);
+        exit(Application::EXIT_SOFTWARE);
     }
 
     PipeRunnable pipeHandler;
@@ -991,7 +991,7 @@ int main(int argc, char** argv)
     close(readerBroker);
 
     Log::info("Process [loolbroker] finished.");
-    return 0;
+    return Application::EXIT_OK;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index ec3e7b3..f57c7ad 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -34,6 +34,7 @@
 #include <Poco/NotificationQueue.h>
 #include <Poco/Notification.h>
 #include <Poco/Mutex.h>
+#include <Poco/Util/ServerApplication.h>
 
 #define LOK_USE_UNSTABLE_API
 #include <LibreOfficeKit/LibreOfficeKitInit.h>
@@ -57,6 +58,7 @@ using Poco::Process;
 using Poco::Notification;
 using Poco::NotificationQueue;
 using Poco::FastMutex;
+using Poco::Util::Application;
 
 const std::string CHILD_URI = "/loolws/child/";
 const std::string LOKIT_BROKER = "/tmp/loolbroker.fifo";
@@ -533,7 +535,7 @@ void lokit_main(const std::string &loSubPath, const std::string& jailId, const s
     if (loKit == nullptr)
     {
         Log::error("Error: LibreOfficeKit initialization failed. Exiting.");
-        exit(-1);
+        exit(Application::EXIT_SOFTWARE);
     }
 
     try
@@ -544,13 +546,13 @@ void lokit_main(const std::string &loSubPath, const std::string& jailId, const s
         if ( (readerBroker = open(pipe.c_str(), O_RDONLY) ) < 0 )
         {
             Log::error("Error: failed to open pipe [" + pipe + "] read only.");
-            exit(-1);
+            exit(Application::EXIT_SOFTWARE);
         }
 
         if ( (writerBroker = open(LOKIT_BROKER.c_str(), O_WRONLY) ) < 0 )
         {
             Log::error("Error: failed to open pipe [" + LOKIT_BROKER + "] write only.");
-            exit(-1);
+            exit(Application::EXIT_SOFTWARE);
         }
 
         Log::info("loolkit [" + std::to_string(Process::id()) + "] is ready.");
@@ -732,19 +734,19 @@ int main(int argc, char** argv)
     if (loSubPath.empty())
     {
         Log::error("Error: --losubpath is empty");
-        exit(1);
+        exit(Application::EXIT_SOFTWARE);
     }
 
     if (jailId.empty())
     {
         Log::error("Error: --jailid is empty");
-        exit(1);
+        exit(Application::EXIT_SOFTWARE);
     }
 
     if ( pipe.empty() )
     {
         Log::error("Error: --pipe is empty");
-        exit(1);
+        exit(Application::EXIT_SOFTWARE);
     }
 
     try
@@ -767,7 +769,7 @@ int main(int argc, char** argv)
 
     lokit_main(loSubPath, jailId, pipe);
 
-    return 0;
+    return Application::EXIT_OK;
 }
 
 #endif
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index e13438e..35b8cff 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -903,7 +903,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
     {
         Log::error("Unable to access cache [" + Cache +
                    "] please make sure it exists, and has write permission for this user.");
-        return Application::EXIT_UNAVAILABLE;
+        return Application::EXIT_SOFTWARE;
     }
 
     // We use the same option set for both parent and child loolwsd,
@@ -936,7 +936,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
     if (!File(FIFO_FILE).exists() && mkfifo(FIFO_FILE.c_str(), 0666) == -1)
     {
         Log::error("Error: Failed to create pipe FIFO [" + FIFO_FILE + "].");
-        return Application::EXIT_UNAVAILABLE;
+        return Application::EXIT_SOFTWARE;
     }
 
     JailId = Util::createRandomDir(ChildRoot);
@@ -944,7 +944,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
     if (pidBroker < 0)
     {
         Log::error("Failed to spawn loolBroker.");
-        return Application::EXIT_UNAVAILABLE;
+        return Application::EXIT_SOFTWARE;
     }
 
 #ifdef __linux
@@ -985,7 +985,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
     if ( (BrokerWritePipe = open(FIFO_FILE.c_str(), O_WRONLY) ) < 0 )
     {
         Log::error("Error: failed to open pipe [" + FIFO_FILE + "] write only.");
-        return Application::EXIT_UNAVAILABLE;
+        return Application::EXIT_SOFTWARE;
     }
 
     TestInput input(*this, svs, srv);


More information about the Libreoffice-commits mailing list