diff options
author | Thomas Haller <thaller@redhat.com> | 2015-05-07 10:16:15 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-06-17 11:41:42 +0200 |
commit | 9a16ce08765faf76e29300090661a5c8e979f6bb (patch) | |
tree | 33e7a3dd2be89dda761d72bdd4fae88bac7cfb91 /src | |
parent | 977626d9429baa2d30c575d045aab12b12a044be (diff) | |
download | NetworkManager-9a16ce08765faf76e29300090661a5c8e979f6bb.tar.gz |
platform: refactor flushing of event socket to _nl_sock_flush_data()
Diffstat (limited to 'src')
-rw-r--r-- | src/platform/nm-linux-platform.c | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 480cbd8011..150ad20ac3 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -277,6 +277,33 @@ nm_rtnl_addr_set_prefixlen (struct rtnl_addr *rtnladdr, int plen) /******************************************************************/ +static int +_nl_sock_flush_data (struct nl_sock *sk) +{ + int nle; + struct nl_cb *cb; + + cb = nl_cb_clone (nl_socket_get_cb (sk)); + if (cb == NULL) + return -NLE_NOMEM; + + nl_cb_set (cb, NL_CB_VALID, NL_CB_DEFAULT, NULL, NULL); + do { + errno = 0; + + nle = nl_recvmsgs (sk, cb); + + /* Work around a libnl bug fixed in 3.2.22 (375a6294) */ + if (nle == 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) + nle = -NLE_AGAIN; + } while (nle != -NLE_AGAIN); + + nl_cb_put (cb); + return nle; +} + +/******************************************************************/ + #if HAVE_LIBNL_INET6_ADDR_GEN_MODE static int _support_user_ipv6ll = 0; #endif @@ -4360,17 +4387,8 @@ event_handler (GIOChannel *channel, warning ("Too many netlink events. Need to resynchronize platform cache"); /* Drain the event queue, we've lost events and are out of sync anyway and we'd * like to free up some space. We'll read in the status synchronously. */ - nl_socket_modify_cb (priv->nlh_event, NL_CB_VALID, NL_CB_DEFAULT, NULL, NULL); - do { - errno = 0; - - nle = nl_recvmsgs_default (priv->nlh_event); + _nl_sock_flush_data (priv->nlh_event); - /* Work around a libnl bug fixed in 3.2.22 (375a6294) */ - if (nle == 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) - nle = -NLE_AGAIN; - } while (nle != -NLE_AGAIN); - nl_socket_modify_cb (priv->nlh_event, NL_CB_VALID, NL_CB_CUSTOM, event_notification, user_data); delayed_action_schedule (platform, DELAYED_ACTION_TYPE_REFRESH_ALL, NULL); delayed_action_handle_all (platform); break; |