Lines Matching refs:mngr
69 struct nl_cache_mngr *mngr = arg; in event_input() local
79 mngr, msg); in event_input()
85 if (mngr->cm_protocol != protocol) in event_input()
88 for (i = 0; i < mngr->cm_nassocs; i++) { in event_input()
89 if (mngr->cm_assocs[i].ca_cache) { in event_input()
90 ops = mngr->cm_assocs[i].ca_cache->c_ops; in event_input()
101 msg, mngr->cm_assocs[i].ca_cache); in event_input()
102 p.pp_arg = &mngr->cm_assocs[i]; in event_input()
138 struct nl_cache_mngr *mngr; in nl_cache_mngr_alloc() local
145 mngr = calloc(1, sizeof(*mngr)); in nl_cache_mngr_alloc()
146 if (!mngr) in nl_cache_mngr_alloc()
156 mngr->cm_sock = sk; in nl_cache_mngr_alloc()
157 mngr->cm_nassocs = NASSOC_INIT; in nl_cache_mngr_alloc()
158 mngr->cm_protocol = protocol; in nl_cache_mngr_alloc()
159 mngr->cm_flags = flags; in nl_cache_mngr_alloc()
160 mngr->cm_assocs = calloc(mngr->cm_nassocs, in nl_cache_mngr_alloc()
162 if (!mngr->cm_assocs) in nl_cache_mngr_alloc()
166 nl_socket_disable_seq_check(mngr->cm_sock); in nl_cache_mngr_alloc()
168 if ((err = nl_connect(mngr->cm_sock, protocol)) < 0) in nl_cache_mngr_alloc()
171 if ((err = nl_socket_set_nonblocking(mngr->cm_sock)) < 0) in nl_cache_mngr_alloc()
175 mngr->cm_sync_sock = nl_socket_alloc(); in nl_cache_mngr_alloc()
176 if (!mngr->cm_sync_sock) { in nl_cache_mngr_alloc()
180 if ((err = nl_connect(mngr->cm_sync_sock, protocol)) < 0) in nl_cache_mngr_alloc()
184 mngr, protocol, mngr->cm_nassocs); in nl_cache_mngr_alloc()
186 *result = mngr; in nl_cache_mngr_alloc()
190 nl_socket_free(mngr->cm_sync_sock); in nl_cache_mngr_alloc()
192 nl_cache_mngr_free(mngr); in nl_cache_mngr_alloc()
221 int nl_cache_mngr_add_cache(struct nl_cache_mngr *mngr, struct nl_cache *cache, in nl_cache_mngr_add_cache() argument
232 if (ops->co_protocol != mngr->cm_protocol) in nl_cache_mngr_add_cache()
238 for (i = 0; i < mngr->cm_nassocs; i++) in nl_cache_mngr_add_cache()
239 if (mngr->cm_assocs[i].ca_cache && in nl_cache_mngr_add_cache()
240 mngr->cm_assocs[i].ca_cache->c_ops == ops) in nl_cache_mngr_add_cache()
244 for (i = 0; i < mngr->cm_nassocs; i++) in nl_cache_mngr_add_cache()
245 if (!mngr->cm_assocs[i].ca_cache) in nl_cache_mngr_add_cache()
248 if (i >= mngr->cm_nassocs) { in nl_cache_mngr_add_cache()
249 mngr->cm_nassocs += NASSOC_EXPAND; in nl_cache_mngr_add_cache()
250 mngr->cm_assocs = realloc(mngr->cm_assocs, in nl_cache_mngr_add_cache()
251 mngr->cm_nassocs * in nl_cache_mngr_add_cache()
253 if (mngr->cm_assocs == NULL) in nl_cache_mngr_add_cache()
256 memset(mngr->cm_assocs + (mngr->cm_nassocs - NASSOC_EXPAND), 0, in nl_cache_mngr_add_cache()
260 "to %d\n", mngr, mngr->cm_nassocs); in nl_cache_mngr_add_cache()
265 err = nl_socket_add_membership(mngr->cm_sock, grp->ag_group); in nl_cache_mngr_add_cache()
270 err = nl_cache_refill(mngr->cm_sync_sock, cache); in nl_cache_mngr_add_cache()
274 mngr->cm_assocs[i].ca_cache = cache; in nl_cache_mngr_add_cache()
275 mngr->cm_assocs[i].ca_change = cb; in nl_cache_mngr_add_cache()
276 mngr->cm_assocs[i].ca_change_data = data; in nl_cache_mngr_add_cache()
278 if (mngr->cm_flags & NL_AUTO_PROVIDE) in nl_cache_mngr_add_cache()
282 cache, nl_cache_name(cache), mngr); in nl_cache_mngr_add_cache()
288 nl_socket_drop_membership(mngr->cm_sock, grp->ag_group); in nl_cache_mngr_add_cache()
321 int nl_cache_mngr_add(struct nl_cache_mngr *mngr, const char *name, in nl_cache_mngr_add() argument
337 err = nl_cache_mngr_add_cache(mngr, cache, cb, data); in nl_cache_mngr_add()
359 int nl_cache_mngr_get_fd(struct nl_cache_mngr *mngr) in nl_cache_mngr_get_fd() argument
361 return nl_socket_get_fd(mngr->cm_sock); in nl_cache_mngr_get_fd()
383 int nl_cache_mngr_poll(struct nl_cache_mngr *mngr, int timeout) in nl_cache_mngr_poll() argument
387 .fd = nl_socket_get_fd(mngr->cm_sock), in nl_cache_mngr_poll()
391 NL_DBG(3, "Cache manager %p, poll() fd %d\n", mngr, fds.fd); in nl_cache_mngr_poll()
393 NL_DBG(3, "Cache manager %p, poll() returned %d\n", mngr, ret); in nl_cache_mngr_poll()
401 return nl_cache_mngr_data_ready(mngr); in nl_cache_mngr_poll()
419 int nl_cache_mngr_data_ready(struct nl_cache_mngr *mngr) in nl_cache_mngr_data_ready() argument
425 mngr, nl_socket_get_fd(mngr->cm_sock)); in nl_cache_mngr_data_ready()
427 cb = nl_cb_clone(mngr->cm_sock->s_cb); in nl_cache_mngr_data_ready()
431 nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, event_input, mngr); in nl_cache_mngr_data_ready()
433 while ((err = nl_recvmsgs_report(mngr->cm_sock, cb)) > 0) { in nl_cache_mngr_data_ready()
435 mngr, err); in nl_cache_mngr_data_ready()
455 void nl_cache_mngr_info(struct nl_cache_mngr *mngr, struct nl_dump_params *p) in nl_cache_mngr_info() argument
460 nl_dump_line(p, "cache-manager <%p>\n", mngr); in nl_cache_mngr_info()
462 nl_nlfamily2str(mngr->cm_protocol, buf, sizeof(buf))); in nl_cache_mngr_info()
463 nl_dump_line(p, " .flags = %#x\n", mngr->cm_flags); in nl_cache_mngr_info()
464 nl_dump_line(p, " .nassocs = %u\n", mngr->cm_nassocs); in nl_cache_mngr_info()
465 nl_dump_line(p, " .sock = <%p>\n", mngr->cm_sock); in nl_cache_mngr_info()
467 for (i = 0; i < mngr->cm_nassocs; i++) { in nl_cache_mngr_info()
468 struct nl_cache_assoc *assoc = &mngr->cm_assocs[i]; in nl_cache_mngr_info()
494 void nl_cache_mngr_free(struct nl_cache_mngr *mngr) in nl_cache_mngr_free() argument
498 if (!mngr) in nl_cache_mngr_free()
501 if (mngr->cm_sock) in nl_cache_mngr_free()
502 nl_close(mngr->cm_sock); in nl_cache_mngr_free()
504 if (mngr->cm_sync_sock) { in nl_cache_mngr_free()
505 nl_close(mngr->cm_sync_sock); in nl_cache_mngr_free()
506 nl_socket_free(mngr->cm_sync_sock); in nl_cache_mngr_free()
509 if (mngr->cm_flags & NL_ALLOCATED_SOCK) in nl_cache_mngr_free()
510 nl_socket_free(mngr->cm_sock); in nl_cache_mngr_free()
512 for (i = 0; i < mngr->cm_nassocs; i++) { in nl_cache_mngr_free()
513 if (mngr->cm_assocs[i].ca_cache) { in nl_cache_mngr_free()
514 nl_cache_mngt_unprovide(mngr->cm_assocs[i].ca_cache); in nl_cache_mngr_free()
515 nl_cache_free(mngr->cm_assocs[i].ca_cache); in nl_cache_mngr_free()
519 free(mngr->cm_assocs); in nl_cache_mngr_free()
521 NL_DBG(1, "Cache manager %p freed\n", mngr); in nl_cache_mngr_free()
523 free(mngr); in nl_cache_mngr_free()