You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2017/01/26 05:34:42 UTC

qpid-dispatch git commit: DISPATCH-625: qdrouterd crashes if it can't find the python library

Repository: qpid-dispatch
Updated Branches:
  refs/heads/master a44289be5 -> 610739ff5


DISPATCH-625: qdrouterd crashes if it can't find the python library

Check for existence of python path in main.c happens before the log and error
systems are initialized in dispatch.c, causing a crash if the path is not
found. Moved this check into dispatch.c after everything is initialized.


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/610739ff
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/610739ff
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/610739ff

Branch: refs/heads/master
Commit: 610739ff529adc295892390294b6cfdb87f84602
Parents: a44289b
Author: Alan Conway <ac...@redhat.com>
Authored: Thu Jan 26 00:32:54 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Thu Jan 26 00:32:54 2017 -0500

----------------------------------------------------------------------
 router/src/main.c     |  9 ---------
 src/dispatch.c        | 11 +++++++++++
 src/error.c           | 18 ++++++++++--------
 src/python_embedded.c |  2 +-
 4 files changed, 22 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/610739ff/router/src/main.c
----------------------------------------------------------------------
diff --git a/router/src/main.c b/router/src/main.c
index 496c616..86ca9d9 100644
--- a/router/src/main.c
+++ b/router/src/main.c
@@ -108,15 +108,6 @@ static void check(int fd) {
 
 static void main_process(const char *config_path, const char *python_pkgdir, int fd)
 {
-    qd_error_clear();
-    struct stat st;
-    if (stat(python_pkgdir, &st))
-        fail(fd, "Cannot find python library path '%s'", python_pkgdir);
-    if (!S_ISDIR(st.st_mode)) {
-        qd_error(QD_ERROR_RUNTIME, "Python library path '%s' not a directory", python_pkgdir);
-        check(fd);
-    }
-
     dispatch = qd_dispatch(python_pkgdir);
     check(fd);
     log_source = qd_log_source("MAIN"); /* Logging is initialized by qd_dispatch. */

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/610739ff/src/dispatch.c
----------------------------------------------------------------------
diff --git a/src/dispatch.c b/src/dispatch.c
index 3a8c412..6e5600d 100644
--- a/src/dispatch.c
+++ b/src/dispatch.c
@@ -62,6 +62,17 @@ qd_dispatch_t *qd_dispatch(const char *python_pkgdir)
     qd_error_initialize();
     if (qd_error_code()) { qd_dispatch_free(qd); return 0; }
 
+    if (python_pkgdir) {
+        struct stat st;
+        if (stat(python_pkgdir, &st)) {
+            qd_error_errno(errno, "Cannot find Python library path '%s'", python_pkgdir);
+            return NULL;
+        } else if (!S_ISDIR(st.st_mode)) {
+            qd_error(QD_ERROR_RUNTIME, "Python library path '%s' not a directory", python_pkgdir);
+            return NULL;
+        }
+    }
+
     qd_dispatch_set_router_area(qd, strdup("0"));
     qd_dispatch_set_router_id(qd, strdup("0"));
     qd->router_mode = QD_ROUTER_MODE_ENDPOINT;

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/610739ff/src/error.c
----------------------------------------------------------------------
diff --git a/src/error.c b/src/error.c
index d531d7a..6b7239a 100644
--- a/src/error.c
+++ b/src/error.c
@@ -17,6 +17,12 @@
  * under the License.
  */
 
+
+/* Make sure we get the XSI compliant strerror_r from string.h not the GNU one. */
+#define _POSIX_C_SOURCE 200112L
+#undef _GNU_SOURCE
+#include <string.h>
+
 #include <Python.h>
 #include <qpid/dispatch/error.h>
 #include <qpid/dispatch/enum.h>
@@ -175,22 +181,18 @@ qd_error_t qd_error_py_impl(const char *file, int line) {
     return qd_error_code();
 }
 
-static inline void ignore_result(char* ignored) {}
-
 qd_error_t qd_error_errno_impl(int errnum, const char *file, int line, const char *fmt, ...) {
     if (errnum) {
         ts.error_code = QD_ERROR_SYSTEM;
-        char buf[ERROR_MAX];
-		ignore_result(strerror_r(errno, buf, sizeof(buf)));
-
         char *begin = ts.error_message;
-        char *end = begin + ERROR_MAX;
+        char *end = begin + sizeof(ts.error_message);
         va_list arglist;
         va_start(arglist, fmt);
         vaprintf(&begin, end, fmt, arglist);
         va_end(arglist);
-        aprintf(&begin, end, ": %s", buf);
-        qd_log_impl(log_source, QD_LOG_ERROR, file, line, "%s", qd_error_message());
+        aprintf(&begin, end, ": ", errnum);
+        (void)strerror_r(errnum, begin, end - begin);
+        qd_log_impl(log_source, QD_LOG_ERROR, file, line, "%s", ts.error_message);
         return qd_error_code();
     }
     else

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/610739ff/src/python_embedded.c
----------------------------------------------------------------------
diff --git a/src/python_embedded.c b/src/python_embedded.c
index 9f94772..0c8f236 100644
--- a/src/python_embedded.c
+++ b/src/python_embedded.c
@@ -712,7 +712,7 @@ static void qd_python_setup(void)
         if (!m) {
             qd_error_py();
             qd_log(log_source, QD_LOG_CRITICAL, "Cannot load dispatch extension module '%s'", DISPATCH_MODULE);
-            abort();
+            exit(1);
         }
 
         //


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org