summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2016-08-11 17:39:39 +0200
committerSander Vrijders <[email protected]>2016-08-11 17:39:39 +0200
commit5432e665fd6eac776c5985d98058e5c4645ec0e4 (patch)
tree10b398bf23356751a961c332a9dff053c6927f24 /src
parentcf30e07cf862b117013e8c7fa2fb5c2ac8fef245 (diff)
downloadouroboros-5432e665fd6eac776c5985d98058e5c4645ec0e4.tar.gz
ouroboros-5432e665fd6eac776c5985d98058e5c4645ec0e4.zip
ipcpd: Add condition variable to IPCP state
This adds a condition variable to the IPCP state, so that upon state changes any listeners to state changes can be notified. It also replaces the read/write lock with a mutex in order to be able to do so.
Diffstat (limited to 'src')
-rw-r--r--src/ipcpd/ipcp.c13
-rw-r--r--src/ipcpd/ipcp.h5
-rw-r--r--src/ipcpd/local/main.c72
-rw-r--r--src/ipcpd/normal/fmgr.c30
-rw-r--r--src/ipcpd/normal/main.c59
-rw-r--r--src/ipcpd/normal/ribmgr.c46
-rw-r--r--src/ipcpd/shim-eth-llc/main.c100
-rw-r--r--src/ipcpd/shim-udp/main.c140
8 files changed, 235 insertions, 230 deletions
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c
index 24f580e5..5c066cb0 100644
--- a/src/ipcpd/ipcp.c
+++ b/src/ipcpd/ipcp.c
@@ -42,11 +42,22 @@ struct ipcp * ipcp_instance_create()
i->irmd_fd = -1;
i->state = IPCP_INIT;
- pthread_rwlock_init(&i->state_lock, NULL);
+ pthread_mutex_init(&i->state_lock, NULL);
+ pthread_cond_init(&i->state_cond, NULL);
return i;
}
+void ipcp_state_change(struct ipcp * ipcp,
+ enum ipcp_state state)
+{
+ if (ipcp == NULL)
+ return;
+
+ ipcp->state = state;
+ pthread_cond_broadcast(&ipcp->state_cond);
+}
+
int ipcp_parse_arg(int argc, char * argv[])
{
char * log_file;
diff --git a/src/ipcpd/ipcp.h b/src/ipcpd/ipcp.h
index 630f7922..8b7d4ec9 100644
--- a/src/ipcpd/ipcp.h
+++ b/src/ipcpd/ipcp.h
@@ -45,10 +45,13 @@ struct ipcp {
int irmd_fd;
enum ipcp_state state;
- pthread_rwlock_t state_lock;
+ pthread_mutex_t state_lock;
+ pthread_cond_t state_cond;
};
struct ipcp * ipcp_instance_create();
+void ipcp_state_change(struct ipcp * ipcp,
+ enum ipcp_state state);
void * ipcp_main_loop(void * o);
void * ipcp_sdu_loop(void * o);
int ipcp_parse_arg(int argc, char * argv[]);
diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c
index 3f5bf908..72bf0e4b 100644
--- a/src/ipcpd/local/main.c
+++ b/src/ipcpd/local/main.c
@@ -133,7 +133,7 @@ void shim_ap_fini()
if (_ap_instance == NULL)
return;
- pthread_rwlock_wrlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_SHUTDOWN)
LOG_WARN("Cleaning up AP while not in shutdown.");
@@ -152,7 +152,7 @@ void shim_ap_fini()
shm_ap_rbuff_close(_ap_instance->flows[i].rb);
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
free(_ap_instance);
}
@@ -187,10 +187,10 @@ static void * ipcp_local_sdu_loop(void * o)
continue;
}
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_ENROLLED) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return (void *) 1; /* -ENOTENROLLED */
}
@@ -198,7 +198,7 @@ static void * ipcp_local_sdu_loop(void * o)
fd = _ap_instance->in_out[port_id_to_fd(e->port_id)];
if (fd == -1) {
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
free(e);
continue;
}
@@ -209,7 +209,7 @@ static void * ipcp_local_sdu_loop(void * o)
;
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
free(e);
}
@@ -233,14 +233,14 @@ void ipcp_sig_handler(int sig, siginfo_t * info, void * c)
LOG_DBG("Terminating by order of %d. Bye.",
info->si_pid);
- pthread_rwlock_wrlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state == IPCP_ENROLLED)
clean_threads = true;
_ipcp->state = IPCP_SHUTDOWN;
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
if (clean_threads) {
pthread_cancel(_ap_instance->sduloop);
@@ -261,10 +261,10 @@ static int ipcp_local_bootstrap(struct dif_config * conf)
return -1;
}
- pthread_rwlock_wrlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_INIT) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_ERR("IPCP in wrong state.");
return -1;
}
@@ -276,7 +276,7 @@ static int ipcp_local_bootstrap(struct dif_config * conf)
ipcp_local_sdu_loop,
NULL);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBG("Bootstrapped local IPCP with api %d.",
getpid());
@@ -286,21 +286,21 @@ static int ipcp_local_bootstrap(struct dif_config * conf)
static int ipcp_local_name_reg(char * name)
{
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_ENROLLED) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBGF("Won't register with non-enrolled IPCP.");
return -1; /* -ENOTENROLLED */
}
if (ipcp_data_add_reg_entry(_ipcp->data, name)) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBGF("Failed to add %s to local registry.", name);
return -1;
}
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBG("Registered %s.", name);
@@ -309,11 +309,11 @@ static int ipcp_local_name_reg(char * name)
static int ipcp_local_name_unreg(char * name)
{
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
ipcp_data_del_reg_entry(_ipcp->data, name);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return 0;
}
@@ -336,17 +336,17 @@ static int ipcp_local_flow_alloc(pid_t n_api,
/* This ipcpd has all QoS */
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_ENROLLED) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBGF("Won't allocate flow with non-enrolled IPCP.");
return -1; /* -ENOTENROLLED */
}
rb = shm_ap_rbuff_open(n_api);
if (rb == NULL) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return -1; /* -ENORBUFF */
}
@@ -355,7 +355,7 @@ static int ipcp_local_flow_alloc(pid_t n_api,
in_fd = bmp_allocate(_ap_instance->fds);
if (!bmp_is_id_valid(_ap_instance->fds, in_fd)) {
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return -EMFILE;
}
@@ -372,7 +372,7 @@ static int ipcp_local_flow_alloc(pid_t n_api,
if (port_id < 0) {
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_ERR("Could not get port id from IRMd");
/* shm_ap_rbuff_close(n_api); */
return -1;
@@ -382,7 +382,7 @@ static int ipcp_local_flow_alloc(pid_t n_api,
if (!bmp_is_id_valid(_ap_instance->fds, out_fd)) {
/* shm_ap_rbuff_close(n_api); */
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return -1; /* -ENOMOREFDS */
}
@@ -394,7 +394,7 @@ static int ipcp_local_flow_alloc(pid_t n_api,
_ap_instance->in_out[out_fd] = in_fd;
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBGF("Pending local allocation request, port_id %d.", port_id);
@@ -413,7 +413,7 @@ static int ipcp_local_flow_alloc_resp(pid_t n_api,
if (response)
return 0;
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
/* awaken pending flow */
@@ -422,14 +422,14 @@ static int ipcp_local_flow_alloc_resp(pid_t n_api,
in_fd = port_id_to_fd(port_id);
if (in_fd < 0) {
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBGF("Could not find flow with port_id %d.", port_id);
return -1;
}
if (_ap_instance->flows[in_fd].state != FLOW_PENDING) {
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBGF("Flow was not pending.");
return -1;
}
@@ -441,7 +441,7 @@ static int ipcp_local_flow_alloc_resp(pid_t n_api,
_ap_instance->flows[in_fd].port_id = -1;
_ap_instance->in_out[in_fd] = -1;
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return -1;
}
@@ -453,7 +453,7 @@ static int ipcp_local_flow_alloc_resp(pid_t n_api,
out_fd = _ap_instance->in_out[in_fd];
if (out_fd < 0) {
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBGF("No pending local flow with port_id %d.", port_id);
return -1;
}
@@ -461,7 +461,7 @@ static int ipcp_local_flow_alloc_resp(pid_t n_api,
if (_ap_instance->flows[out_fd].state != FLOW_PENDING) {
/* FIXME: clean up other end */
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBGF("Flow was not pending.");
return -1;
}
@@ -469,7 +469,7 @@ static int ipcp_local_flow_alloc_resp(pid_t n_api,
_ap_instance->flows[out_fd].state = FLOW_ALLOCATED;
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
if ((ret = ipcp_flow_alloc_reply(getpid(),
_ap_instance->flows[out_fd].port_id,
@@ -489,13 +489,13 @@ static int ipcp_local_flow_dealloc(int port_id)
int fd = -1;
struct shm_ap_rbuff * rb;
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
pthread_rwlock_wrlock(&_ap_instance->flows_lock);
fd = port_id_to_fd(port_id);
if (fd < 0) {
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBGF("Could not find flow with port_id %d.", port_id);
return 0;
}
@@ -517,7 +517,7 @@ static int ipcp_local_flow_dealloc(int port_id)
if (rb != NULL)
shm_ap_rbuff_close(rb);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBGF("Flow with port_id %d deallocated.", port_id);
@@ -611,7 +611,7 @@ int main(int argc, char * argv[])
exit(EXIT_FAILURE);
}
- pthread_rwlock_wrlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
pthread_sigmask(SIG_BLOCK, &sigset, NULL);
@@ -619,7 +619,7 @@ int main(int argc, char * argv[])
pthread_sigmask(SIG_UNBLOCK, &sigset, NULL);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
if (ipcp_create_r(getpid())) {
LOG_ERR("Failed to notify IRMd we are initialized.");
diff --git a/src/ipcpd/normal/fmgr.c b/src/ipcpd/normal/fmgr.c
index f9de16c4..70afff37 100644
--- a/src/ipcpd/normal/fmgr.c
+++ b/src/ipcpd/normal/fmgr.c
@@ -80,21 +80,22 @@ static void * fmgr_listen(void * o)
int fd;
char * ae_name;
- /* FIXME: Avoid busy wait and react to pthread_cond_t */
- pthread_rwlock_rdlock(&_ipcp->state_lock);
- while (!(_ipcp->state == IPCP_ENROLLED ||
- _ipcp->state == IPCP_SHUTDOWN)) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
- sched_yield();
- pthread_rwlock_rdlock(&_ipcp->state_lock);
- }
+ while (true) {
+ pthread_mutex_lock(&_ipcp->state_lock);
+ while (!(_ipcp->state == IPCP_ENROLLED ||
+ _ipcp->state == IPCP_SHUTDOWN))
+ pthread_cond_wait(&_ipcp->state_cond,
+ &_ipcp->state_lock);
+
+ if (_ipcp->state == IPCP_SHUTDOWN) {
+ pthread_mutex_unlock(&_ipcp->state_lock);
+ return 0;
+ }
+ pthread_mutex_unlock(&_ipcp->state_lock);
- while (_ipcp->state != IPCP_SHUTDOWN) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
fd = flow_accept(&ae_name);
if (fd < 0) {
LOG_ERR("Failed to accept flow.");
- pthread_rwlock_rdlock(&_ipcp->state_lock);
continue;
}
@@ -103,14 +104,12 @@ static void * fmgr_listen(void * o)
if (flow_alloc_resp(fd, -1))
LOG_ERR("Failed to reply to flow allocation.");
flow_dealloc(fd);
- pthread_rwlock_rdlock(&_ipcp->state_lock);
continue;
}
if (flow_alloc_resp(fd, 0)) {
LOG_ERR("Failed to reply to flow allocation.");
flow_dealloc(fd);
- pthread_rwlock_rdlock(&_ipcp->state_lock);
continue;
}
@@ -121,7 +120,6 @@ static void * fmgr_listen(void * o)
if (ribmgr_add_flow(fd)) {
LOG_ERR("Failed to hand fd to RIB.");
flow_dealloc(fd);
- pthread_rwlock_rdlock(&_ipcp->state_lock);
continue;
}
}
@@ -130,7 +128,6 @@ static void * fmgr_listen(void * o)
if (frct_dt_flow(fd)) {
LOG_ERR("Failed to hand fd to FRCT.");
flow_dealloc(fd);
- pthread_rwlock_rdlock(&_ipcp->state_lock);
continue;
}
}
@@ -138,11 +135,8 @@ static void * fmgr_listen(void * o)
if (add_n_1_fd(fd, ae_name)) {
LOG_ERR("Failed to add file descriptor to list.");
flow_dealloc(fd);
- pthread_rwlock_rdlock(&_ipcp->state_lock);
continue;
}
-
- pthread_rwlock_rdlock(&_ipcp->state_lock);
}
return (void *) 0;
diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c
index b5aad271..ea8d75e1 100644
--- a/src/ipcpd/normal/main.c
+++ b/src/ipcpd/normal/main.c
@@ -73,11 +73,11 @@ void ipcp_sig_handler(int sig, siginfo_t * info, void * c)
LOG_DBG("Terminating by order of %d. Bye.",
info->si_pid);
- pthread_rwlock_wrlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
- _ipcp->state = IPCP_SHUTDOWN;
+ ipcp_state_change(_ipcp, IPCP_SHUTDOWN);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
pthread_cancel(normal_data(_ipcp)->mainloop);
@@ -97,21 +97,21 @@ void ipcp_sig_handler(int sig, siginfo_t * info, void * c)
static int normal_ipcp_name_reg(char * name)
{
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_ENROLLED) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBGF("Won't register with non-enrolled IPCP.");
return -1; /* -ENOTENROLLED */
}
if (ipcp_data_add_reg_entry(_ipcp->data, name)) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_ERR("Failed to add %s to local registry.", name);
return -1;
}
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBG("Registered %s.", name);
@@ -120,59 +120,56 @@ static int normal_ipcp_name_reg(char * name)
static int normal_ipcp_name_unreg(char * name)
{
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
ipcp_data_del_reg_entry(_ipcp->data, name);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return 0;
}
static int normal_ipcp_enroll(char * dif_name)
{
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_INIT) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_ERR("Won't enroll an IPCP that is not in INIT.");
return -1; /* -ENOTINIT */
}
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
if (fmgr_mgmt_flow(dif_name)) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_ERR("Failed to establish management flow.");
return -1;
}
- /* FIXME: Wait passively until state changed to ENROLLED */
- pthread_rwlock_rdlock(&_ipcp->state_lock);
- while (_ipcp->state != IPCP_ENROLLED) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
- sched_yield();
- pthread_rwlock_rdlock(&_ipcp->state_lock);
- }
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ /* FIXME: Change into timedwait, see solution in irmd first */
+ pthread_mutex_lock(&_ipcp->state_lock);
+ while (_ipcp->state != IPCP_ENROLLED)
+ pthread_cond_wait(&_ipcp->state_cond, &_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return 0;
}
static int normal_ipcp_bootstrap(struct dif_config * conf)
{
- LOG_DBGF("bootstrapping in dif %s.", conf->dif_name);
+ LOG_DBGF("Bootstrapping in DIF %s.", conf->dif_name);
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_INIT) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_ERR("Won't bootstrap an IPCP that is not in INIT.");
return -1; /* -ENOTINIT */
}
if (ribmgr_bootstrap(conf)) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_ERR("Failed to bootstrap RIB manager.");
return -1;
}
@@ -182,9 +179,9 @@ static int normal_ipcp_bootstrap(struct dif_config * conf)
return -1;
}
- _ipcp->state = IPCP_ENROLLED;
+ ipcp_state_change(_ipcp, IPCP_ENROLLED);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return 0;
}
@@ -239,7 +236,7 @@ void normal_ipcp_data_destroy()
if (_ipcp == NULL)
return;
- pthread_rwlock_wrlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_SHUTDOWN)
LOG_WARN("Cleaning up while not in shutdown.");
@@ -249,7 +246,7 @@ void normal_ipcp_data_destroy()
if (normal_data(_ipcp)->rb != NULL)
shm_ap_rbuff_close(normal_data(_ipcp)->rb);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
free(_ipcp->data);
}
@@ -323,7 +320,7 @@ int main(int argc, char * argv[])
exit(EXIT_FAILURE);
}
- pthread_rwlock_wrlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
pthread_sigmask(SIG_BLOCK, &sigset, NULL);
@@ -332,7 +329,7 @@ int main(int argc, char * argv[])
pthread_sigmask(SIG_UNBLOCK, &sigset, NULL);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
if (ipcp_create_r(getpid())) {
LOG_ERR("Failed to notify IRMd we are initialized.");
diff --git a/src/ipcpd/normal/ribmgr.c b/src/ipcpd/normal/ribmgr.c
index 2a68877a..bbc29b64 100644
--- a/src/ipcpd/normal/ribmgr.c
+++ b/src/ipcpd/normal/ribmgr.c
@@ -220,15 +220,15 @@ int ribmgr_cdap_write(struct cdap * instance,
static_info_msg_t * msg;
int ret = 0;
- pthread_rwlock_wrlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state == IPCP_PENDING_ENROLL &&
strcmp(name, STATIC_INFO) == 0) {
LOG_DBG("Received static DIF information.");
msg = static_info_msg__unpack(NULL, len, data);
if (msg == NULL) {
- _ipcp->state = IPCP_INIT;
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ ipcp_state_change(_ipcp, IPCP_INIT);
+ pthread_mutex_unlock(&_ipcp->state_lock);
cdap_send_reply(instance, invoke_id, -1, NULL, 0);
LOG_ERR("Failed to unpack static info message.");
return -1;
@@ -246,8 +246,8 @@ int ribmgr_cdap_write(struct cdap * instance,
rib->address = msg->address;
if (frct_init(&rib->dtc, rib->address)) {
- _ipcp->state = IPCP_INIT;
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ ipcp_state_change(_ipcp, IPCP_INIT);
+ pthread_mutex_unlock(&_ipcp->state_lock);
cdap_send_reply(instance, invoke_id, -1, NULL, 0);
static_info_msg__free_unpacked(msg, NULL);
LOG_ERR("Failed to init FRCT");
@@ -257,7 +257,7 @@ int ribmgr_cdap_write(struct cdap * instance,
static_info_msg__free_unpacked(msg, NULL);
} else
ret = -1;
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
if (cdap_send_reply(instance, invoke_id, ret, NULL, 0)) {
LOG_ERR("Failed to send reply to write request.");
@@ -298,13 +298,13 @@ int ribmgr_cdap_start(struct cdap * instance,
size_t len = 0;
int iid = 0;
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state == IPCP_ENROLLED &&
strcmp(name, ENROLLMENT) == 0) {
LOG_DBG("New enrollment request.");
if (cdap_send_reply(instance, invoke_id, 0, NULL, 0)) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_ERR("Failed to send reply to enrollment request.");
return -1;
}
@@ -323,14 +323,14 @@ int ribmgr_cdap_start(struct cdap * instance,
len = static_info_msg__get_packed_size(&stat_info);
if (len == 0) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_ERR("Failed to get size of static information.");
return -1;
}
data = malloc(len);
if (data == NULL) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_ERR("Failed to allocate memory.");
return -1;
}
@@ -344,7 +344,7 @@ int ribmgr_cdap_start(struct cdap * instance,
iid = cdap_send_write(instance, STATIC_INFO, data, len, 0);
if (iid < 0) {
pthread_mutex_unlock(&rib->cdap_reqs_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
free(data);
LOG_ERR("Failed to send static information.");
return -1;
@@ -352,7 +352,7 @@ int ribmgr_cdap_start(struct cdap * instance,
if (cdap_request_add(instance, WRITE, STATIC_INFO, iid)) {
pthread_mutex_unlock(&rib->cdap_reqs_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
free(data);
LOG_ERR("Failed to add CDAP request to list.");
return -1;
@@ -368,7 +368,7 @@ int ribmgr_cdap_start(struct cdap * instance,
iid = cdap_send_stop(instance, ENROLLMENT);
if (iid < 0) {
pthread_mutex_unlock(&rib->cdap_reqs_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
free(data);
LOG_ERR("Failed to send stop of enrollment.");
return -1;
@@ -376,7 +376,7 @@ int ribmgr_cdap_start(struct cdap * instance,
if (cdap_request_add(instance, STOP, ENROLLMENT, iid)) {
pthread_mutex_unlock(&rib->cdap_reqs_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
free(data);
LOG_ERR("Failed to add CDAP request to list.");
return -1;
@@ -386,12 +386,12 @@ int ribmgr_cdap_start(struct cdap * instance,
free(data);
} else {
if (cdap_send_reply(instance, invoke_id, -1, NULL, 0)) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_ERR("Failed to send reply to start request.");
return -1;
}
}
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return 0;
}
@@ -402,21 +402,21 @@ int ribmgr_cdap_stop(struct cdap * instance,
{
int ret = 0;
- pthread_rwlock_wrlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state == IPCP_PENDING_ENROLL &&
strcmp(name, ENROLLMENT) == 0) {
LOG_DBG("Stop enrollment received.");
- _ipcp->state = IPCP_ENROLLED;
+ ipcp_state_change(_ipcp, IPCP_ENROLLED);
} else
ret = -1;
if (cdap_send_reply(instance, invoke_id, ret, NULL, 0)) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_ERR("Failed to send reply to stop request.");
return -1;
}
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return 0;
}
@@ -452,11 +452,11 @@ int ribmgr_add_flow(int fd)
flow->instance = instance;
flow->fd = fd;
- pthread_rwlock_wrlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
pthread_rwlock_wrlock(&rib->flows_lock);
if (list_empty(&rib->flows) &&
_ipcp->state == IPCP_INIT) {
- _ipcp->state = IPCP_PENDING_ENROLL;
+ ipcp_state_change(_ipcp, IPCP_PENDING_ENROLL);
pthread_mutex_lock(&rib->cdap_reqs_lock);
iid = cdap_send_start(instance,
@@ -480,7 +480,7 @@ int ribmgr_add_flow(int fd)
}
pthread_mutex_unlock(&rib->cdap_reqs_lock);
}
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
list_add(&flow->next, &rib->flows);
pthread_rwlock_unlock(&rib->flows_lock);
diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c
index 145085e7..e4d7429a 100644
--- a/src/ipcpd/shim-eth-llc/main.c
+++ b/src/ipcpd/shim-eth-llc/main.c
@@ -197,7 +197,7 @@ void eth_llc_ipcp_data_destroy()
if (_ipcp == NULL)
return;
- pthread_rwlock_wrlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_SHUTDOWN)
LOG_WARN("Cleaning up while not in shutdown.");
@@ -218,7 +218,7 @@ void eth_llc_ipcp_data_destroy()
shm_ap_rbuff_close(ipcp_flow(i)->rb);
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
ipcp_data_destroy(_ipcp->data);
}
@@ -478,12 +478,12 @@ static int eth_llc_ipcp_port_req(uint8_t r_sap,
ssize_t index = 0;
int i;
- pthread_rwlock_wrlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
pthread_rwlock_wrlock(&shim_data(_ipcp)->flows_lock);
index = bmp_allocate(shim_data(_ipcp)->indices);
if (index < 0) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
LOG_ERR("Out of free indices.");
return -1;
@@ -496,7 +496,7 @@ static int eth_llc_ipcp_port_req(uint8_t r_sap,
if (port_id < 0) {
bmp_release(shim_data(_ipcp)->indices, index);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
LOG_ERR("Could not get port id from IRMd.");
return -1;
@@ -511,7 +511,7 @@ static int eth_llc_ipcp_port_req(uint8_t r_sap,
}
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBG("New flow request, port_id %d, remote SAP %d.", port_id, r_sap);
@@ -528,20 +528,20 @@ static int eth_llc_ipcp_port_alloc_reply(uint8_t ssap,
int port_id = -1;
int i;
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
pthread_rwlock_rdlock(&shim_data(_ipcp)->flows_lock);
index = sap_to_index(ssap);
if (index < 0) {
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_ERR("No flow found with that SAP.");
return -1; /* -EFLOWNOTFOUND */
}
if (ipcp_flow(index)->state != FLOW_PENDING) {
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return -1; /* -EFLOWNOTPENDING */
}
@@ -558,7 +558,7 @@ static int eth_llc_ipcp_port_alloc_reply(uint8_t ssap,
}
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBG("Flow reply, port_id %d, remote SAP %d.", port_id, dsap);
@@ -578,13 +578,13 @@ static int eth_llc_ipcp_flow_dealloc_req(uint8_t ssap,
int port_id = -1;
int i = 0;
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
pthread_rwlock_wrlock(&shim_data(_ipcp)->flows_lock);
i = sap_to_index(ssap);
if (i < 0) {
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_ERR("No flow found for remote deallocation request.");
return 0;
}
@@ -593,7 +593,7 @@ static int eth_llc_ipcp_flow_dealloc_req(uint8_t ssap,
destroy_ipcp_flow(i);
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
ipcp_flow_dealloc(0, port_id);
@@ -669,14 +669,14 @@ static void * eth_llc_ipcp_sdu_reader(void * o)
memset(br_addr, 0xff, MAC_SIZE * sizeof(uint8_t));
while (true) {
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_ENROLLED) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return (void *) 1; /* -ENOTENROLLED */
}
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
#if defined(PACKET_RX_RING) && defined(PACKET_TX_RING)
header = (void *) shim_data(_ipcp)->rx_ring +
@@ -789,13 +789,13 @@ static void * eth_llc_ipcp_sdu_writer(void * o)
if (e == NULL)
continue;
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_ENROLLED) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return (void *) 1; /* -ENOTENROLLED */
}
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
len = shm_du_map_read((uint8_t **) &buf,
shim_data(_ipcp)->dum,
@@ -847,14 +847,14 @@ void ipcp_sig_handler(int sig, siginfo_t * info, void * c)
LOG_DBG("Terminating by order of %d. Bye.",
info->si_pid);
- pthread_rwlock_wrlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state == IPCP_ENROLLED)
clean_threads = true;
_ipcp->state = IPCP_SHUTDOWN;
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
if (clean_threads) {
pthread_cancel(shim_data(_ipcp)->sdu_reader);
@@ -1030,10 +1030,10 @@ static int eth_llc_ipcp_bootstrap(struct dif_config * conf)
#endif
- pthread_rwlock_wrlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_INIT) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_ERR("IPCP in wrong state.");
close(fd);
return -1;
@@ -1055,7 +1055,7 @@ static int eth_llc_ipcp_bootstrap(struct dif_config * conf)
eth_llc_ipcp_sdu_writer,
NULL);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBG("Bootstrapped shim IPCP over Ethernet with LLC with api %d.",
getpid());
@@ -1065,21 +1065,21 @@ static int eth_llc_ipcp_bootstrap(struct dif_config * conf)
static int eth_llc_ipcp_name_reg(char * name)
{
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_ENROLLED) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBGF("Won't register with non-enrolled IPCP.");
return -1; /* -ENOTENROLLED */
}
if (ipcp_data_add_reg_entry(_ipcp->data, name)) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_ERR("Failed to add %s to local registry.", name);
return -1;
}
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBG("Registered %s.", name);
@@ -1088,11 +1088,11 @@ static int eth_llc_ipcp_name_reg(char * name)
static int eth_llc_ipcp_name_unreg(char * name)
{
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
ipcp_data_del_reg_entry(_ipcp->data, name);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return 0;
}
@@ -1120,11 +1120,11 @@ static int eth_llc_ipcp_flow_alloc(pid_t n_api,
if (rb == NULL)
return -1; /* -ENORBUFF */
- pthread_rwlock_wrlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_ENROLLED) {
shm_ap_rbuff_close(rb);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBGF("Won't allocate flow with non-enrolled IPCP.");
return -1; /* -ENOTENROLLED */
}
@@ -1132,7 +1132,7 @@ static int eth_llc_ipcp_flow_alloc(pid_t n_api,
index = bmp_allocate(shim_data(_ipcp)->indices);
if (index < 0) {
shm_ap_rbuff_close(rb);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return -1;
}
@@ -1143,7 +1143,7 @@ static int eth_llc_ipcp_flow_alloc(pid_t n_api,
shm_ap_rbuff_close(rb);
bmp_release(shim_data(_ipcp)->indices, index);
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return -1;
}
@@ -1153,7 +1153,7 @@ static int eth_llc_ipcp_flow_alloc(pid_t n_api,
shim_data(_ipcp)->flows[index].sap = ssap;
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
memset(r_addr, 0xff, MAC_SIZE * sizeof(uint8_t));
@@ -1161,11 +1161,11 @@ static int eth_llc_ipcp_flow_alloc(pid_t n_api,
dst_name,
src_ae_name) < 0) {
LOG_DBGF("Port alloc returned -1.");
- pthread_rwlock_wrlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
pthread_rwlock_wrlock(&shim_data(_ipcp)->flows_lock);
destroy_ipcp_flow(index);
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return -1;
}
@@ -1183,20 +1183,20 @@ static int eth_llc_ipcp_flow_alloc_resp(pid_t n_api,
int index = -1;
uint8_t ssap = 0;
- pthread_rwlock_wrlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
pthread_rwlock_wrlock(&shim_data(_ipcp)->flows_lock);
index = port_id_to_index(port_id);
if (index < 0) {
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBGF("Could not find flow with port_id %d.", port_id);
return -1;
}
if (ipcp_flow(index)->state != FLOW_PENDING) {
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBGF("Flow was not pending.");
return -1;
}
@@ -1208,7 +1208,7 @@ static int eth_llc_ipcp_flow_alloc_resp(pid_t n_api,
ipcp_flow(index)->port_id = -1;
bmp_release(shim_data(_ipcp)->indices, index);
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return -1;
}
@@ -1219,7 +1219,7 @@ static int eth_llc_ipcp_flow_alloc_resp(pid_t n_api,
shm_ap_rbuff_close(ipcp_flow(index)->rb);
bmp_release(shim_data(_ipcp)->indices, index);
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return -1;
}
@@ -1228,17 +1228,17 @@ static int eth_llc_ipcp_flow_alloc_resp(pid_t n_api,
shim_data(_ipcp)->flows[index].sap = ssap;
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
if (eth_llc_ipcp_port_alloc_resp(shim_data(_ipcp)->flows[index].r_addr,
shim_data(_ipcp)->flows[index].r_sap,
ssap,
response) < 0) {
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
pthread_rwlock_wrlock(&shim_data(_ipcp)->flows_lock);
destroy_ipcp_flow(index);
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBGF("Could not send response.");
return -1;
@@ -1257,13 +1257,13 @@ static int eth_llc_ipcp_flow_dealloc(int port_id)
int i;
int ret;
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
pthread_rwlock_wrlock(&shim_data(_ipcp)->flows_lock);
index = port_id_to_index(port_id);
if (index < 0) {
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return 0;
}
@@ -1277,7 +1277,7 @@ static int eth_llc_ipcp_flow_dealloc(int port_id)
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
ret = eth_llc_ipcp_port_dealloc(addr, sap);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
if (ret < 0)
LOG_DBGF("Could not notify remote.");
@@ -1353,7 +1353,7 @@ int main(int argc, char * argv[])
_ipcp->ops = &eth_llc_ops;
_ipcp->state = IPCP_INIT;
- pthread_rwlock_wrlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
pthread_sigmask(SIG_BLOCK, &sigset, NULL);
@@ -1362,7 +1362,7 @@ int main(int argc, char * argv[])
pthread_sigmask(SIG_UNBLOCK, &sigset, NULL);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
if (ipcp_create_r(getpid())) {
LOG_ERR("Failed to notify IRMd we are initialized.");
diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c
index 8d9ac25c..672941da 100644
--- a/src/ipcpd/shim-udp/main.c
+++ b/src/ipcpd/shim-udp/main.c
@@ -154,7 +154,7 @@ void shim_ap_fini()
if (_ap_instance == NULL)
return;
- pthread_rwlock_wrlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_SHUTDOWN)
LOG_WARN("Cleaning up AP while not in shutdown.");
@@ -173,7 +173,7 @@ void shim_ap_fini()
shm_ap_rbuff_close(_ap_instance->flows[i].rb);
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
free(_ap_instance);
}
@@ -197,10 +197,10 @@ static ssize_t ipcp_udp_flow_write(int fd, void * buf, size_t count)
ssize_t index;
struct rb_entry e;
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_ENROLLED) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return -1; /* -ENOTENROLLED */
}
@@ -221,7 +221,7 @@ static ssize_t ipcp_udp_flow_write(int fd, void * buf, size_t count)
;
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return 0;
}
@@ -463,7 +463,7 @@ static int ipcp_udp_port_req(struct sockaddr_in * c_saddr,
return -1;
}
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
pthread_rwlock_wrlock(&_ap_instance->flows_lock);
/* reply to IRM */
@@ -473,7 +473,7 @@ static int ipcp_udp_port_req(struct sockaddr_in * c_saddr,
if (port_id < 0) {
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_ERR("Could not get port id from IRMd");
close(fd);
return -1;
@@ -484,7 +484,7 @@ static int ipcp_udp_port_req(struct sockaddr_in * c_saddr,
_ap_instance->flows[fd].state = FLOW_PENDING;
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBG("Pending allocation request, port_id %d, UDP port (%d, %d).",
port_id, ntohs(f_saddr.sin_port), ntohs(c_saddr->sin_port));
@@ -506,20 +506,20 @@ static int ipcp_udp_port_alloc_reply(int src_udp_port,
LOG_DBG("Received reply for flow on udp port %d.",
ntohs(dst_udp_port));
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
pthread_rwlock_rdlock(&_ap_instance->flows_lock);
fd = udp_port_to_fd(dst_udp_port);
if (fd == -1) {
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBG("Unknown flow on UDP port %d.", ntohs(dst_udp_port));
return -1; /* -EUNKNOWNFLOW */
}
if (_ap_instance->flows[fd].state != FLOW_PENDING) {
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBG("Flow on UDP port %d not pending.",
ntohs(dst_udp_port));
return -1; /* -EFLOWNOTPENDING */
@@ -538,7 +538,7 @@ static int ipcp_udp_port_alloc_reply(int src_udp_port,
(struct sockaddr *) &t_saddr,
&t_saddr_len) < 0) {
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBG("Flow with port_id %d has no peer.", port_id);
return -1;
}
@@ -550,7 +550,7 @@ static int ipcp_udp_port_alloc_reply(int src_udp_port,
(struct sockaddr *) &t_saddr,
sizeof(t_saddr)) < 0) {
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
close(fd);
return -1;
}
@@ -559,7 +559,7 @@ static int ipcp_udp_port_alloc_reply(int src_udp_port,
}
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
if ((ret = ipcp_flow_alloc_reply(getpid(),
@@ -582,13 +582,13 @@ static int ipcp_udp_flow_dealloc_req(int udp_port)
struct shm_ap_rbuff * rb;
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
pthread_rwlock_rdlock(&_ap_instance->flows_lock);
fd = udp_port_to_fd(udp_port);
if (fd < 0) {
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBG("Could not find flow on UDP port %d.",
ntohs(udp_port));
return 0;
@@ -610,7 +610,7 @@ static int ipcp_udp_flow_dealloc_req(int udp_port)
if (rb != NULL)
shm_ap_rbuff_close(rb);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
ipcp_flow_dealloc(0, port_id);
@@ -632,16 +632,16 @@ static void * ipcp_udp_listener()
int sfd = 0;
shim_udp_msg_t * msg = NULL;
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_ENROLLED) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return (void *) 1; /* -ENOTENROLLED */
}
sfd = shim_data(_ipcp)->s_fd;
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
memset(&buf, 0, SHIM_UDP_MSG_SIZE);
n = sizeof(c_saddr);
@@ -705,10 +705,10 @@ static void * ipcp_udp_sdu_reader()
while (true) {
struct timeval tv = {0, FD_UPDATE_TIMEOUT};
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_ENROLLED) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return (void *) 1; /* -ENOTENROLLED */
}
@@ -721,7 +721,7 @@ static void * ipcp_udp_sdu_reader()
pthread_mutex_unlock(&_ap_instance->fd_set_lock);
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
if (select(FD_SETSIZE, &read_fds, NULL, NULL, &tv) <= 0) {
continue;
@@ -765,10 +765,10 @@ static void * ipcp_udp_sdu_loop(void * o)
continue;
}
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_ENROLLED) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return (void *) 1; /* -ENOTENROLLED */
}
@@ -776,7 +776,7 @@ static void * ipcp_udp_sdu_loop(void * o)
_ap_instance->dum,
e->index);
if (len <= 0) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
free(e);
continue;
}
@@ -786,7 +786,7 @@ static void * ipcp_udp_sdu_loop(void * o)
fd = port_id_to_fd(e->port_id);
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
if (fd == -1) {
free(e);
@@ -796,12 +796,12 @@ static void * ipcp_udp_sdu_loop(void * o)
if (send(fd, buf, len, 0) < 0)
LOG_ERR("Failed to send SDU.");
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ap_instance->dum != NULL)
shm_du_map_remove(_ap_instance->dum, e->index);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
free(e);
}
@@ -824,14 +824,14 @@ void ipcp_sig_handler(int sig, siginfo_t * info, void * c)
LOG_DBG("Terminating by order of %d. Bye.",
info->si_pid);
- pthread_rwlock_wrlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state == IPCP_ENROLLED)
clean_threads = true;
_ipcp->state = IPCP_SHUTDOWN;
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
if (clean_threads) {
pthread_cancel(_ap_instance->handler);
@@ -916,10 +916,10 @@ static int ipcp_udp_bootstrap(struct dif_config * conf)
return -1;
}
- pthread_rwlock_wrlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_INIT) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_ERR("IPCP in wrong state.");
close(fd);
return -1;
@@ -947,7 +947,7 @@ static int ipcp_udp_bootstrap(struct dif_config * conf)
ipcp_udp_sdu_loop,
NULL);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBG("Bootstrapped shim IPCP over UDP with api %d.",
getpid());
@@ -1098,16 +1098,16 @@ static int ipcp_udp_name_reg(char * name)
return -1;
}
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_ENROLLED) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBG("Won't register with non-enrolled IPCP.");
return -1; /* -ENOTENROLLED */
}
if (ipcp_data_add_reg_entry(_ipcp->data, name)) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_ERR("Failed to add %s to local registry.", name);
return -1;
}
@@ -1117,7 +1117,7 @@ static int ipcp_udp_name_reg(char * name)
dns_addr = shim_data(_ipcp)->dns_addr;
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
if (dns_addr != 0) {
ip_addr = shim_data(_ipcp)->ip_addr;
@@ -1136,14 +1136,14 @@ static int ipcp_udp_name_reg(char * name)
dnsstr, name, DNS_TTL, ipstr);
if (ddns_send(cmd)) {
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
ipcp_data_del_reg_entry(_ipcp->data, name);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return -1;
}
}
#else
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
#endif
LOG_DBG("Registered %s.", name);
@@ -1167,17 +1167,17 @@ static int ipcp_udp_name_unreg(char * name)
#ifdef CONFIG_OUROBOROS_ENABLE_DNS
/* unregister application with DNS server */
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_ENROLLED) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBG("IPCP is not enrolled");
return -1; /* -ENOTENROLLED */
}
dns_addr = shim_data(_ipcp)->dns_addr;
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
if (dns_addr != 0) {
if (inet_ntop(AF_INET, &dns_addr, dnsstr, INET_ADDRSTRLEN)
@@ -1191,11 +1191,11 @@ static int ipcp_udp_name_unreg(char * name)
}
#endif
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
ipcp_data_del_reg_entry(_ipcp->data, name);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return 0;
}
@@ -1253,10 +1253,10 @@ static int ipcp_udp_flow_alloc(pid_t n_api,
return -1;
}
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_ENROLLED) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBG("Won't allocate flow with non-enrolled IPCP.");
close(fd);
return -1; /* -ENOTENROLLED */
@@ -1266,7 +1266,7 @@ static int ipcp_udp_flow_alloc(pid_t n_api,
dns_addr = shim_data(_ipcp)->dns_addr;
if (dns_addr != 0) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
ip_addr = ddns_resolve(dst_name, dns_addr);
if (ip_addr == 0) {
@@ -1275,9 +1275,9 @@ static int ipcp_udp_flow_alloc(pid_t n_api,
return -1;
}
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_ENROLLED) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBG("Won't allocate flow with non-enrolled IPCP.");
close(fd);
return -1; /* -ENOTENROLLED */
@@ -1320,13 +1320,13 @@ static int ipcp_udp_flow_alloc(pid_t n_api,
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
if (ipcp_udp_port_alloc(ip_addr,
f_saddr.sin_port,
dst_name,
src_ae_name) < 0) {
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
pthread_rwlock_rdlock(&_ap_instance->flows_lock);
clr_fd(fd);
@@ -1340,7 +1340,7 @@ static int ipcp_udp_flow_alloc(pid_t n_api,
_ap_instance->flows[fd].rb = NULL;
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
close(fd);
return -1;
}
@@ -1363,10 +1363,10 @@ static int ipcp_udp_flow_alloc_resp(pid_t n_api,
if (response)
return 0;
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_ENROLLED) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBG("IPCP in wrong state.");
close(fd);
return -1; /* -ENOTENROLLED */
@@ -1379,14 +1379,14 @@ static int ipcp_udp_flow_alloc_resp(pid_t n_api,
fd = port_id_to_fd(port_id);
if (fd < 0) {
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBG("Could not find flow with port_id %d.", port_id);
return -1;
}
if (_ap_instance->flows[fd].state != FLOW_PENDING) {
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBG("Flow was not pending.");
return -1;
}
@@ -1397,7 +1397,7 @@ static int ipcp_udp_flow_alloc_resp(pid_t n_api,
_ap_instance->flows[fd].state = FLOW_NULL;
_ap_instance->flows[fd].port_id = -1;
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return -1;
}
@@ -1420,13 +1420,13 @@ static int ipcp_udp_flow_alloc_resp(pid_t n_api,
set_fd(fd);
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
if (ipcp_udp_port_alloc_resp(r_saddr.sin_addr.s_addr,
f_saddr.sin_port,
r_saddr.sin_port,
response) < 0) {
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
pthread_rwlock_rdlock(&_ap_instance->flows_lock);
clr_fd(fd);
@@ -1439,7 +1439,7 @@ static int ipcp_udp_flow_alloc_resp(pid_t n_api,
_ap_instance->flows[fd].rb = NULL;
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
return -1;
}
@@ -1457,13 +1457,13 @@ static int ipcp_udp_flow_dealloc(int port_id)
struct sockaddr_in r_saddr;
socklen_t r_saddr_len = sizeof(r_saddr);
- pthread_rwlock_rdlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
pthread_rwlock_rdlock(&_ap_instance->flows_lock);
fd = port_id_to_fd(port_id);
if (fd < 0) {
pthread_rwlock_unlock(&_ap_instance->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBG("Could not find flow with port_id %d.", port_id);
return 0;
}
@@ -1484,7 +1484,7 @@ static int ipcp_udp_flow_dealloc(int port_id)
shm_ap_rbuff_close(rb);
if (getpeername(fd, (struct sockaddr *) &r_saddr, &r_saddr_len) < 0) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
LOG_DBG("Flow with port_id %d has no peer.", port_id);
close(fd);
return 0;
@@ -1494,7 +1494,7 @@ static int ipcp_udp_flow_dealloc(int port_id)
r_saddr.sin_port = LISTEN_PORT;
if (connect(fd, (struct sockaddr *) &r_saddr, sizeof(r_saddr)) < 0) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
close(fd);
return 0 ;
}
@@ -1502,12 +1502,12 @@ static int ipcp_udp_flow_dealloc(int port_id)
if (ipcp_udp_port_dealloc(r_saddr.sin_addr.s_addr,
remote_udp) < 0) {
LOG_DBG("Could not notify remote.");
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
close(fd);
return 0;
}
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
close(fd);
@@ -1599,7 +1599,7 @@ int main(int argc, char * argv[])
exit(EXIT_FAILURE);
}
- pthread_rwlock_wrlock(&_ipcp->state_lock);
+ pthread_mutex_lock(&_ipcp->state_lock);
pthread_sigmask(SIG_BLOCK, &sigset, NULL);
@@ -1607,7 +1607,7 @@ int main(int argc, char * argv[])
pthread_sigmask(SIG_UNBLOCK, &sigset, NULL);
- pthread_rwlock_unlock(&_ipcp->state_lock);
+ pthread_mutex_unlock(&_ipcp->state_lock);
if (ipcp_create_r(getpid())) {
LOG_ERR("Failed to notify IRMd we are initialized.");