summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNishant Chaprana <n.chaprana@samsung.com>2020-10-12 13:33:23 +0530
committerJaehyun Kim <jeik01.kim@samsung.com>2020-11-16 12:39:48 +0900
commitc1fc22b8c2f61e438227d5d04de2b024824f5700 (patch)
tree1ef6efa4926e9c0e60b13b239d05123b2b762596
parentb333d54db46deb7b603ace67f78bd50ecf0a7f42 (diff)
downloadconnman-c1fc22b8c2f61e438227d5d04de2b024824f5700.tar.gz
connman-c1fc22b8c2f61e438227d5d04de2b024824f5700.tar.bz2
connman-c1fc22b8c2f61e438227d5d04de2b024824f5700.zip
Add retry mechanism when socket GIO channel fails
Change-Id: I21f1d8c970f1053ce4337dc0d251d2fa20bbd509 Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
-rw-r--r--packaging/connman.spec2
-rwxr-xr-xsrc/connman.h5
-rwxr-xr-xsrc/main.c4
-rw-r--r--src/rtnl.c36
4 files changed, 46 insertions, 1 deletions
diff --git a/packaging/connman.spec b/packaging/connman.spec
index c62c806c..e108c84a 100644
--- a/packaging/connman.spec
+++ b/packaging/connman.spec
@@ -5,7 +5,7 @@
Name: connman
Version: 1.37
-Release: 46
+Release: 47
License: GPL-2.0+
Summary: Connection Manager
Url: http://connman.net
diff --git a/src/connman.h b/src/connman.h
index 9e28ffea..38242712 100755
--- a/src/connman.h
+++ b/src/connman.h
@@ -27,6 +27,7 @@
#if defined TIZEN_EXT
#define WIFI_COUNTRY_CODE_LEN 2
#define WIFI_PHY_MODE_LEN 18
+#define GIO_SOCKET_RETRY_COUNT 3
#endif
#include <connman/dbus.h>
@@ -1014,7 +1015,11 @@ const char *__connman_notifier_get_state(void);
#include <connman/rtnl.h>
+#if defined TIZEN_EXT
+int __connman_rtnl_init(int retry_count);
+#else
int __connman_rtnl_init(void);
+#endif
void __connman_rtnl_start(void);
void __connman_rtnl_cleanup(void);
diff --git a/src/main.c b/src/main.c
index 7e638120..34d572db 100755
--- a/src/main.c
+++ b/src/main.c
@@ -1407,7 +1407,11 @@ int main(int argc, char *argv[])
__connman_clock_init();
__connman_ipconfig_init();
+#if defined TIZEN_EXT
+ __connman_rtnl_init(GIO_SOCKET_RETRY_COUNT);
+#else /* TIZEN_EXT */
__connman_rtnl_init();
+#endif /* TIZEN_EXT */
__connman_task_init();
__connman_proxy_init();
__connman_detect_init();
diff --git a/src/rtnl.c b/src/rtnl.c
index aa5c07cc..7da55fa5 100644
--- a/src/rtnl.c
+++ b/src/rtnl.c
@@ -1586,8 +1586,15 @@ static gboolean netlink_event(GIOChannel *chan, GIOCondition cond, gpointer data
ssize_t status;
int fd;
+#if defined TIZEN_EXT
+ if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) {
+ __connman_rtnl_init(GIO_SOCKET_RETRY_COUNT);
+ return FALSE;
+ }
+#else /* TIZEN_EXT */
if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR))
return FALSE;
+#endif /* TIZEN_EXT */
memset(buf, 0, sizeof(buf));
memset(&nladdr, 0, sizeof(nladdr));
@@ -1600,11 +1607,21 @@ static gboolean netlink_event(GIOChannel *chan, GIOCondition cond, gpointer data
if (errno == EINTR || errno == EAGAIN)
return TRUE;
+#if defined TIZEN_EXT
+ __connman_rtnl_init(GIO_SOCKET_RETRY_COUNT);
+#endif /* TIZEN_EXT */
return FALSE;
}
+#if defined TIZEN_EXT
+ if (status == 0) {
+ __connman_rtnl_init(GIO_SOCKET_RETRY_COUNT);
+ return FALSE;
+ }
+#else /* TIZEN_EXT */
if (status == 0)
return FALSE;
+#endif /* TIZEN_EXT */
if (nladdr.nl_pid != 0) { /* not sent by kernel, ignore */
DBG("Received msg from %u, ignoring it", nladdr.nl_pid);
@@ -1748,19 +1765,34 @@ int __connman_rtnl_request_update(void)
return send_getlink();
}
+#if defined TIZEN_EXT
+int __connman_rtnl_init(int retry_count)
+#else /* TIZEN_EXT */
int __connman_rtnl_init(void)
+#endif /* TIZEN_EXT */
{
struct sockaddr_nl addr;
int sk;
+#if defined TIZEN_EXT
+ if (retry_count < 0)
+ return -1;
+
+ DBG("retry_count %d", retry_count);
+#else /* TIZEN_EXT */
DBG("");
+#endif /* TIZEN_EXT */
interface_list = g_hash_table_new_full(g_direct_hash, g_direct_equal,
NULL, free_interface);
sk = socket(PF_NETLINK, SOCK_DGRAM | SOCK_CLOEXEC, NETLINK_ROUTE);
if (sk < 0)
+#if defined TIZEN_EXT
+ return __connman_rtnl_init(retry_count - 1);
+#else /* TIZEN_EXT */
return -1;
+#endif /* TIZEN_EXT */
memset(&addr, 0, sizeof(addr));
addr.nl_family = AF_NETLINK;
@@ -1770,7 +1802,11 @@ int __connman_rtnl_init(void)
if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
close(sk);
+#if defined TIZEN_EXT
+ return __connman_rtnl_init(retry_count - 1);
+#else /* TIZEN_EXT */
return -1;
+#endif /* TIZEN_EXT */
}
channel = g_io_channel_unix_new(sk);