diff options
author | Hyunho Kang <hhstark.kang@samsung.com> | 2016-09-27 14:31:19 +0900 |
---|---|---|
committer | Hyunho Kang <hhstark.kang@samsung.com> | 2016-09-27 14:31:59 +0900 |
commit | 5879c848cf6c094cead314d184ac616e5aca9282 (patch) | |
tree | 8d29106c36ddd9700330f68e8f36dfcdf1a2a02e | |
parent | 7490bebbfd823a5d86c4ae285c3bba1555b2a6d9 (diff) | |
download | message-port-5879c848cf6c094cead314d184ac616e5aca9282.tar.gz message-port-5879c848cf6c094cead314d184ac616e5aca9282.tar.bz2 message-port-5879c848cf6c094cead314d184ac616e5aca9282.zip |
Fix watch on not exist name bugsubmit/tizen_3.0_wearable/20161015.000004submit/tizen_3.0_tv/20161015.000004submit/tizen_3.0_mobile/20161015.000004submit/tizen_3.0_ivi/20161010.000005submit/tizen/20160927.094009accepted/tizen/wearable/20160928.050337accepted/tizen/tv/20160928.050320accepted/tizen/mobile/20160928.050300accepted/tizen/ivi/20160928.050352accepted/tizen/common/20160927.152838accepted/tizen/3.0/wearable/20161015.083515accepted/tizen/3.0/tv/20161016.005133accepted/tizen/3.0/mobile/20161015.033618accepted/tizen/3.0/ivi/20161011.055307
Change-Id: I1a3635dfc0bee44799fdd7dfe2645c5767ee1521
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
-rwxr-xr-x | src/message-port.c | 56 |
1 files changed, 42 insertions, 14 deletions
diff --git a/src/message-port.c b/src/message-port.c index 2e54cff..eb86b2f 100755 --- a/src/message-port.c +++ b/src/message-port.c @@ -325,9 +325,19 @@ static void on_name_vanished(GDBusConnection *connection, { _LOGI("name vanished : %s", name); port_list_info_s *pli = (port_list_info_s *)user_data; - g_bus_unwatch_name(pli->watcher_id); + if (pli == NULL) { + LOGE("NULL port info"); + return; + } + + _LOGI("watcher_id :%d", pli->watcher_id); + if (pli->watcher_id > 0) + g_bus_unwatch_name(pli->watcher_id); + else + _LOGE("Invalid watcher_id %d", pli->watcher_id); pli->exist = false; pli->watcher_id = 0; + _LOGI("name vanished socket : %d", pli->send_sock_fd); if (pli->send_sock_fd > 0) { close(pli->send_sock_fd); @@ -407,6 +417,26 @@ out: return remote_app_info; } +static void __watch_remote_port_info(port_list_info_s *port_info) +{ + if (port_info == NULL) + return; + + if (port_info->watcher_id < 1) { + port_info->watcher_id = g_bus_watch_name_on_connection( + __gdbus_conn, + port_info->encoded_bus_name, + G_BUS_NAME_WATCHER_FLAGS_NONE, + on_name_appeared, + on_name_vanished, + port_info, + NULL); + } else { + LOGI("Already watched port info"); + return; + } +} + static int __get_remote_port_info(const char *remote_app_id, const char *remote_port, bool is_trusted, message_port_remote_app_info_s **mri, port_list_info_s **pli) { @@ -445,17 +475,6 @@ static int __get_remote_port_info(const char *remote_app_id, const char *remote_ } else { *pli = (port_list_info_s *)cb_list->data; } - if ((*pli)->watcher_id < 1) { - LOGI("watch remote port : %s", (*pli)->encoded_bus_name); - (*pli)->watcher_id = g_bus_watch_name_on_connection( - __gdbus_conn, - (*pli)->encoded_bus_name, - G_BUS_NAME_WATCHER_FLAGS_NONE, - on_name_appeared, - on_name_vanished, - *pli, - NULL); - } out: return ret_val; @@ -960,6 +979,7 @@ static int __check_remote_port(const char *remote_app_id, const char *remote_por port_info->exist = true; *exist = true; ret_val = MESSAGEPORT_ERROR_NONE; + __watch_remote_port_info(port_info); } } out: @@ -987,8 +1007,15 @@ static void __on_sender_name_vanished(GDBusConnection *connection, if (!remove_result) _LOGE("Fail to remove sender appid from hash : %s", name); - g_bus_unwatch_name(*watcher_id); - free(watcher_id); + if (watcher_id) { + if (*watcher_id > 0) + g_bus_unwatch_name(*watcher_id); + else + LOGE("Invalid watcher_id %d", *watcher_id); + free(watcher_id); + } else { + LOGE("watcher_id is NULL"); + } } static bool __check_sender_validation(GVariant *parameters, const char *sender, GDBusConnection *conn) @@ -1409,6 +1436,7 @@ static int __message_port_send_message(const char *remote_appid, const char *rem goto out; } } + __watch_remote_port_info(port_info); if (port_info->send_sock_fd > 0) { ret = __message_port_send_async(port_info->send_sock_fd, message, |