summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/netlink-types.h1
-rw-r--r--lib/cache_mngr.c16
2 files changed, 16 insertions, 1 deletions
diff --git a/include/netlink-types.h b/include/netlink-types.h
index 2bb4f0a..057ea2b 100644
--- a/include/netlink-types.h
+++ b/include/netlink-types.h
@@ -98,6 +98,7 @@ struct nl_cache_mngr
int cm_flags;
int cm_nassocs;
struct nl_sock * cm_sock;
+ struct nl_sock * cm_sync_sock;
struct nl_cache_assoc * cm_assocs;
};
diff --git a/lib/cache_mngr.c b/lib/cache_mngr.c
index bf92d11..d5dc1f3 100644
--- a/lib/cache_mngr.c
+++ b/lib/cache_mngr.c
@@ -171,12 +171,21 @@ int nl_cache_mngr_alloc(struct nl_sock *sk, int protocol, int flags,
if ((err = nl_socket_set_nonblocking(mngr->cm_sock) < 0))
goto errout;
+ /* Create and allocate socket for sync cache fills */
+ mngr->cm_sync_sock = nl_socket_alloc();
+ if (!mngr->cm_sync_sock)
+ goto errout;
+ if ((err = nl_connect(mngr->cm_sync_sock, protocol)) < 0)
+ goto errout_free_sync_sock;
+
NL_DBG(1, "Allocated cache manager %p, protocol %d, %d caches\n",
mngr, protocol, mngr->cm_nassocs);
*result = mngr;
return 0;
+errout_free_sync_sock:
+ nl_socket_free(mngr->cm_sync_sock);
errout:
nl_cache_mngr_free(mngr);
return err;
@@ -256,7 +265,7 @@ retry:
return err;
}
- err = nl_cache_refill(mngr->cm_sock, cache);
+ err = nl_cache_refill(mngr->cm_sync_sock, cache);
if (err < 0)
goto errout_drop_membership;
@@ -490,6 +499,11 @@ void nl_cache_mngr_free(struct nl_cache_mngr *mngr)
if (mngr->cm_sock)
nl_close(mngr->cm_sock);
+ if (mngr->cm_sync_sock) {
+ nl_close(mngr->cm_sync_sock);
+ nl_socket_free(mngr->cm_sync_sock);
+ }
+
if (mngr->cm_flags & NL_ALLOCATED_SOCK)
nl_socket_free(mngr->cm_sock);