Add critical section on netlink send message
This commit is contained in:
parent
33ea96d9f5
commit
80b1780d92
@ -142,28 +142,31 @@ static int ac_kmod_send_and_recv(struct nl_sock* nl, struct nl_cb* nl_cb, struct
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* */
|
||||||
|
capwap_lock_enter(&g_ac.kmodhandle.msglock);
|
||||||
|
|
||||||
/* Complete send message */
|
/* Complete send message */
|
||||||
result = nl_send_auto_complete(nl, msg);
|
result = nl_send_auto_complete(nl, msg);
|
||||||
if (result < 0) {
|
if (result >= 0) {
|
||||||
nl_cb_put(cb);
|
/* Customize message callback */
|
||||||
return -1;
|
nl_cb_err(cb, NL_CB_CUSTOM, ac_kmod_error_handler, &result);
|
||||||
}
|
nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, ac_kmod_finish_handler, &result);
|
||||||
|
nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ac_kmod_ack_handler, &result);
|
||||||
/* Customize message callback */
|
|
||||||
nl_cb_err(cb, NL_CB_CUSTOM, ac_kmod_error_handler, &result);
|
if (valid_cb) {
|
||||||
nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, ac_kmod_finish_handler, &result);
|
nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, valid_cb, data);
|
||||||
nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ac_kmod_ack_handler, &result);
|
}
|
||||||
|
|
||||||
if (valid_cb) {
|
result = 1;
|
||||||
nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, valid_cb, data);
|
while (result > 0) {
|
||||||
}
|
nl_recvmsgs(nl, cb);
|
||||||
|
}
|
||||||
result = 1;
|
|
||||||
while (result > 0) {
|
|
||||||
nl_recvmsgs(nl, cb);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* */
|
||||||
|
capwap_lock_exit(&g_ac.kmodhandle.msglock);
|
||||||
nl_cb_put(cb);
|
nl_cb_put(cb);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -623,6 +626,9 @@ int ac_kmod_deauthorize_station(struct capwap_sessionid_element* sessionid, cons
|
|||||||
int ac_kmod_init(void) {
|
int ac_kmod_init(void) {
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
/* */
|
||||||
|
capwap_lock_init(&g_ac.kmodhandle.msglock);
|
||||||
|
|
||||||
/* Configure netlink callback */
|
/* Configure netlink callback */
|
||||||
g_ac.kmodhandle.nl_cb = nl_cb_alloc(NL_CB_DEFAULT);
|
g_ac.kmodhandle.nl_cb = nl_cb_alloc(NL_CB_DEFAULT);
|
||||||
if (!g_ac.kmodhandle.nl_cb) {
|
if (!g_ac.kmodhandle.nl_cb) {
|
||||||
@ -693,6 +699,9 @@ void ac_kmod_free(void) {
|
|||||||
nl_cb_put(g_ac.kmodhandle.nlmsg_cb);
|
nl_cb_put(g_ac.kmodhandle.nlmsg_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* */
|
||||||
|
capwap_lock_destroy(&g_ac.kmodhandle.msglock);
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
memset(&g_ac.kmodhandle, 0, sizeof(struct ac_kmod_handle));
|
memset(&g_ac.kmodhandle, 0, sizeof(struct ac_kmod_handle));
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ struct ac_kmod_handle {
|
|||||||
int nlsmartcapwap_id;
|
int nlsmartcapwap_id;
|
||||||
|
|
||||||
/* Send message */
|
/* Send message */
|
||||||
|
capwap_lock_t msglock;
|
||||||
struct nl_sock* nlmsg;
|
struct nl_sock* nlmsg;
|
||||||
struct nl_cb* nlmsg_cb;
|
struct nl_cb* nlmsg_cb;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user