Commit 24ae7d9a authored by 's avatar
Browse files

fix memory leaks

git-svn-id: file:///home/svn/mapi/trunk@578 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent c450767b
......@@ -443,6 +443,7 @@ static void delete_remote_flow(remote_flowdescr_t* rflow)
pthread_spin_lock(&hostlist_lock);
flist_remove(hostlist, hflow->rhost->sockfd, FLIST_LEAVE_DATA);
pthread_spin_unlock(&hostlist_lock);
free(hflow->rhost->comm_thread);
free(hflow->rhost);
}
//we check if a host is using in other rflows and delete it -close the socket- if not
......@@ -452,6 +453,7 @@ static void delete_remote_flow(remote_flowdescr_t* rflow)
free(hflow->dbuf);
free(hflow->pkt);
flist_remove(rflow->host_flowlist,hflow->id,FLIST_FREE_DATA);
free(hflow);
}
flist_destroy(rflow->host_flowlist, FLIST_LEAVE_DATA);
free(rflow->host_flowlist);
......@@ -467,9 +469,10 @@ static void delete_remote_flow(remote_flowdescr_t* rflow)
free(res);
}
flist_destroy(rflow->function_res, FLIST_LEAVE_DATA);
free(rflow->function_res);
#ifdef WITH_AUTHENTICATION
free(rflow->username);
free(rflow->vo);
if (rflow->username!=NULL) free(rflow->username);
if (rflow->vo!=NULL) free(rflow->vo);
#endif
free(rflow);
}
......@@ -492,7 +495,7 @@ int mapi_create_flow(const char *dev)
char *hostname=NULL, *s=NULL, *k=NULL;
struct host *h=NULL;
host_flow* hflow;
char *devp=strdup(dev);
char *devp;
flist_node_t* fnode;
unsigned int idgen=0;
#endif
......@@ -510,6 +513,7 @@ int mapi_create_flow(const char *dev)
else pthread_once(&dmapi_is_initialized, (void*)dmapi_init);
if ((s = strchr(dev,':'))!=NULL) {
devp=strdup(dev);
rflow=(remote_flowdescr_t *)malloc(sizeof(remote_flowdescr_t));
rflow->fd=++fdseed;
sem_init(&rflow->fd_sem, 0, 0);
......@@ -1206,11 +1210,11 @@ int mapi_apply_function(int fd, const char* funct, ...)
return -1;
}
//we create a dummy flow descriptor just to get the function info we want from mapilh_get_function_def
flow=(flowdescr_t *)malloc(sizeof(flowdescr_t));
flow->devtype="1.3";
//flow=(flowdescr_t *)malloc(sizeof(flowdescr_t));
//flow->devtype="1.3";
is_remote = 1;//indicates that flow is remote
}
else
else {
#endif
if ((flow=flist_get(flowlist,fd))==NULL) {
DEBUG_CMD(printf("Invalid flow: %d [%s:%d]\n",fd,__FILE__,__LINE__));
......@@ -1228,6 +1232,12 @@ int mapi_apply_function(int fd, const char* funct, ...)
return -1;
}
#ifdef DIMAPI
}
if (is_remote) fdef=mapilh_get_function_def(funct,"1.3");
else
#endif
//Get information about function
fdef=mapilh_get_function_def(funct,flow->devtype);
......
......@@ -80,9 +80,11 @@ int mapiipc_client_init()
mapidaddr_len = sizeof mapidaddr.sun_family + strlen(mapidaddr.sun_path);
if (connect(sock, (struct sockaddr *)&mapidaddr, mapidaddr_len) < 0)
ERROR_CMD(printf("connect: %s [%s:%d]\n",strerror(errno),__FILE__,__LINE__));
else
//exit(EXIT_FAILURE);
return -1;
else {
free(mapidsocket);
//exit(EXIT_FAILURE);
return -1;
}
}
free(mapidsocket);
return 0;
......@@ -138,7 +140,10 @@ void *mapiipc_comm_thread(void *host) {
unsigned int dbuf_bytes=0;
int pending;
int sockfd=((struct host *)host)->sockfd;
/* Guarantees that thread resources are deallocated upon return */
pthread_detach(pthread_self());
dbuf=(struct dmapiipcbuf*)&buffer[0];
while (1) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment