From 8ef4c0c9073b3b6a7578cffd119fdf0be7963005 Mon Sep 17 00:00:00 2001 From: Timo Lotterbach Date: Thu, 25 Oct 2012 05:12:43 -0700 Subject: [PATCH] DbusIpcModule: added checks before calling dbus_watch_handle --- .../IpcModules/DbusIpcModule/src/message.c | 38 +++++++++++++++------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/LayerManagerPlugins/IpcModules/DbusIpcModule/src/message.c b/LayerManagerPlugins/IpcModules/DbusIpcModule/src/message.c index 813249e..5e03465 100644 --- a/LayerManagerPlugins/IpcModules/DbusIpcModule/src/message.c +++ b/LayerManagerPlugins/IpcModules/DbusIpcModule/src/message.c @@ -313,13 +313,20 @@ void handleWatchesForFds(fd_set in, fd_set out) { DBusWatch* activeWatch = gDbus.incomingWatch[fd]; - pthread_mutex_lock(&gDbus.mutex); - dbus_bool_t success = dbus_watch_handle(activeWatch, DBUS_WATCH_READABLE); - pthread_mutex_unlock(&gDbus.mutex); - - if (!success) + if (activeWatch) + { + pthread_mutex_lock(&gDbus.mutex); + dbus_bool_t success = dbus_watch_handle(activeWatch, DBUS_WATCH_READABLE); + pthread_mutex_unlock(&gDbus.mutex); + + if (!success) + { + printf("incoming dbus_watch_handle() failed\n"); + } + } + else { - printf("incoming dbus_watch_handle() failed\n"); + printf("no watch was found for incoming fd %d, not calling dbus_watch_handle(NULL)\n", fd); } } } @@ -330,13 +337,20 @@ void handleWatchesForFds(fd_set in, fd_set out) { DBusWatch* activeWatch = gDbus.outgoingWatch[fd]; - pthread_mutex_lock(&gDbus.mutex); - dbus_bool_t success = dbus_watch_handle(activeWatch, DBUS_WATCH_WRITABLE); - pthread_mutex_unlock(&gDbus.mutex); - - if (!success) + if (activeWatch) + { + pthread_mutex_lock(&gDbus.mutex); + dbus_bool_t success = dbus_watch_handle(activeWatch, DBUS_WATCH_WRITABLE); + pthread_mutex_unlock(&gDbus.mutex); + + if (!success) + { + printf("outgoing dbus_watch_handle() failed\n"); + } + } + else { - printf("outgoing dbus_watch_handle() failed\n"); + printf("no watch was found for outgoing fd %d, not calling dbus_watch_handle(NULL)\n", fd); } } } -- 2.7.4