Commit 2d188af0 authored by 's avatar
Browse files

Fixed bug #469. Cleanup function is called when a flow is appended to delete...

Fixed bug #469. Cleanup function is called when a flow is appended to delete list (in mapid_close_flow)

git-svn-id: file:///home/svn/mapi/trunk@1284 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 495d16a2
......@@ -539,7 +539,6 @@ static void delete_flow(mapidlib_instance_t *i,struct mapidlibflow *flow) {
flist_t *functions;
flist_node_t *funct_node;
mapidflib_function_t *funct;
// pthread_spinlock_t *lock;
DEBUG_CMD(printf("Deleting flow %d [%s:%d]\n",flow->fd,__FILE__,__LINE__));
......@@ -926,7 +925,7 @@ free_functionlist (struct mapidlibflow *fl)
free(flist_remove(fl->hwinfo->gflist->fflist,fl->fd));
pthread_spin_unlock(&fl->hwinfo->gflist->lock);
cur=flist_head(fl->functionlist);
cur=flist_head(fl->functionlist);
while(cur) {
fn=flist_data(cur);
......@@ -934,8 +933,6 @@ free_functionlist (struct mapidlibflow *fl)
fn->instance->def->cleanup(fn->instance);
free(fn->instance->def);
// if(fn->internal_data!=NULL)
// free(fn->internal_data);
free(fn->instance);
free(fn);
cur=cur->next;
......@@ -957,8 +954,6 @@ free_functionlist (struct mapidlibflow *fl)
#ifdef WITH_AUTHENTICATION
free(fl->vo);
#endif
//free(fl);
}
static void free_sharedmem(struct mapidlibflow *f)
......@@ -984,8 +979,8 @@ int
mapid_close_flow(mapidlib_instance_t *i,int fd)
{
struct mapidlibflow *f;
//flist_node_t *n2;
// mapidflib_function_instance_t *funct;
mapidflib_function_t *fn;
flist_node_t *fnode;
#ifdef WITH_PRIORITIES
f=flist_priorities_get(i->flowlist,fd);
......@@ -1005,14 +1000,21 @@ mapid_close_flow(mapidlib_instance_t *i,int fd)
DEBUG_CMD(printf ("Added flow to delete list, fd=%d [%s:%d]\n", fd, __FILE__,__LINE__));
flist_append(&i->close,fd, (void *)0x1); /* 0x1 ... so flist_get works as exist operator */
pthread_mutex_unlock(&i->lock);
for(fnode = flist_head(f->functionlist); fnode != NULL; fnode = flist_next(fnode)){
fn = flist_data(fnode);
//it is not possible to delete flows here as it can cause race condition with process packet thread
// delete_flow(i, f);
if(fn->instance->def->cleanup != NULL && fn->instance->status == MAPIFUNC_INIT){
fn->instance->def->cleanup(fn->instance);
fn->instance->status = MAPIFUNC_UNINIT; // in order to avoid the unnecessary call of cleanup function in free_functionlist()
}
}
pthread_mutex_unlock(&i->lock);
//it is not possible to delete flows here as it can cause race condition with process packet thread
// delete_flow(i, f);
return 0;
}
......
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