summaryrefslogtreecommitdiff
path: root/src/ipcpd
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2016-10-24 16:48:32 +0000
committerSander Vrijders <[email protected]>2016-10-24 16:48:32 +0000
commit66b712598ff7947574c2f227c1484bea4783be76 (patch)
treeab571093282b69ff1acfb13ea33428c2843c2b2f /src/ipcpd
parentb05290df28e380ddc789fd5e7eada95e9adef389 (diff)
parentf9aecc005360388cfebd625925e9219aa27c3466 (diff)
downloadouroboros-66b712598ff7947574c2f227c1484bea4783be76.tar.gz
ouroboros-66b712598ff7947574c2f227c1484bea4783be76.zip
Merged in dstaesse/ouroboros/be-local (pull request #278)
ipcpd: Fix memleaks in local IPCP
Diffstat (limited to 'src/ipcpd')
-rw-r--r--src/ipcpd/local/main.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c
index 192607c1..347c7f2f 100644
--- a/src/ipcpd/local/main.c
+++ b/src/ipcpd/local/main.c
@@ -49,6 +49,7 @@ int irmd_api;
struct {
int in_out[IRMD_MAX_FLOWS];
flow_set_t * flows;
+ fqueue_t * fq;
pthread_rwlock_t lock;
pthread_t sduloop;
@@ -64,6 +65,12 @@ static int local_data_init(void)
if (local_data.flows == NULL)
return -ENFILE;
+ local_data.fq = fqueue_create();
+ if (local_data.fq == NULL) {
+ flow_set_destroy(local_data.flows);
+ return -ENOMEM;
+ }
+
pthread_rwlock_init(&local_data.lock, NULL);
return 0;
@@ -71,40 +78,35 @@ static int local_data_init(void)
static void local_data_fini(void)
{
+ flow_set_destroy(local_data.flows);
+ fqueue_destroy(local_data.fq);
pthread_rwlock_destroy(&local_data.lock);
}
static void * ipcp_local_sdu_loop(void * o)
{
struct timespec timeout = {0, EVENT_WAIT_TIMEOUT * 1000};
- fqueue_t * fq = fqueue_create();
- if (fq == NULL)
- return (void *) 1;
(void) o;
while (true) {
int fd;
- int ret;
ssize_t idx;
- ret = flow_event_wait(local_data.flows, fq, &timeout);
- if (ret == -ETIMEDOUT)
+ if (flow_event_wait(local_data.flows, local_data.fq, &timeout)
+ == -ETIMEDOUT)
continue;
- assert(!ret);
-
pthread_rwlock_rdlock(&ipcpi.state_lock);
if (ipcp_get_state() != IPCP_ENROLLED) {
pthread_rwlock_unlock(&ipcpi.state_lock);
- fqueue_destroy(fq);
return (void *) 1; /* -ENOTENROLLED */
}
pthread_rwlock_rdlock(&local_data.lock);
- while ((fd = fqueue_next(fq)) >= 0) {
+ while ((fd = fqueue_next(local_data.fq)) >= 0) {
idx = local_flow_read(fd);
assert((size_t) idx < (SHM_BUFFER_SIZE));
@@ -151,7 +153,8 @@ static int ipcp_local_bootstrap(struct dif_config * conf)
assert(conf);
assert(conf->type == THIS_TYPE);
- (void) conf;
+ /* this IPCP doesn't need to maintain its dif_name */
+ free(conf->dif_name);
pthread_rwlock_wrlock(&ipcpi.state_lock);