summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/cdap.c50
-rw-r--r--src/lib/shm_ap_rbuff.c2
2 files changed, 28 insertions, 24 deletions
diff --git a/src/lib/cdap.c b/src/lib/cdap.c
index 4275bfc7..4599fd8b 100644
--- a/src/lib/cdap.c
+++ b/src/lib/cdap.c
@@ -69,6 +69,28 @@ static ssize_t cdap_msg_to_buffer(cdap_t * msg,
return len;
}
+static int next_invoke_id(struct cdap * instance)
+{
+ int ret;
+
+ pthread_mutex_lock(&instance->ids_lock);
+ ret = bmp_allocate(instance->ids);
+ pthread_mutex_unlock(&instance->ids_lock);
+
+ return ret;
+}
+
+static int release_invoke_id(struct cdap * instance,
+ int id)
+{
+ int ret;
+
+ pthread_mutex_lock(&instance->ids_lock);
+ ret = bmp_release(instance->ids, id);
+ pthread_mutex_unlock(&instance->ids_lock);
+
+ return ret;
+}
static void * sdu_reader(void * o)
{
@@ -146,6 +168,7 @@ static void * sdu_reader(void * o)
msg->result,
val,
length);
+ release_invoke_id(instance, msg->invoke_id);
free(val);
}
break;
@@ -189,6 +212,7 @@ struct cdap * cdap_create(struct cdap_ops * ops,
}
instance->ops = ops;
+ instance->fd = fd;
instance->ids = bmp_create(IDS_SIZE, 0);
if (instance->ids == NULL) {
@@ -211,6 +235,9 @@ int cdap_destroy(struct cdap * instance)
pthread_cancel(instance->reader);
+ if (flow_dealloc(instance->fd))
+ return -1;
+
pthread_mutex_lock(&instance->ids_lock);
bmp_destroy(instance->ids);
@@ -225,29 +252,6 @@ int cdap_destroy(struct cdap * instance)
return 0;
}
-static int next_invoke_id(struct cdap * instance)
-{
- int ret;
-
- pthread_mutex_lock(&instance->ids_lock);
- ret = bmp_allocate(instance->ids);
- pthread_mutex_unlock(&instance->ids_lock);
-
- return ret;
-}
-
-static int release_invoke_id(struct cdap * instance,
- int id)
-{
- int ret;
-
- pthread_mutex_lock(&instance->ids_lock);
- ret = bmp_release(instance->ids, id);
- pthread_mutex_unlock(&instance->ids_lock);
-
- return ret;
-}
-
static int write_msg(struct cdap * instance,
cdap_t * msg)
{
diff --git a/src/lib/shm_ap_rbuff.c b/src/lib/shm_ap_rbuff.c
index 605e5678..84f7617a 100644
--- a/src/lib/shm_ap_rbuff.c
+++ b/src/lib/shm_ap_rbuff.c
@@ -296,7 +296,7 @@ struct rb_entry * shm_ap_rbuff_read(struct shm_ap_rbuff * rb)
while (tail_el_ptr->port_id < 0)
*rb->ptr_tail = (*rb->ptr_tail + 1) & (SHM_RBUFF_SIZE -1);
- while(shm_rbuff_empty(rb))
+ while (shm_rbuff_empty(rb))
if (pthread_cond_wait(rb->work, rb->shm_mutex)
== EOWNERDEAD) {
LOG_DBGF("Recovering dead mutex.");