Commit 11676e58 authored by 's avatar
Browse files

fixed bug #440

git-svn-id: file:///home/svn/mapi/trunk@893 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 02546ee7
......@@ -111,6 +111,8 @@ typedef struct libinfo {
typedef struct flowdescr {
int fd;
int file; //File descriptor for offline flows
int fds[256]; // file descriptors
int numfd; // number of file descriptors
char *devtype;
char *shm_base;
pthread_spinlock_t *shm_spinlock;
......@@ -703,6 +705,7 @@ int mapi_create_flow(const char *dev)
//flow->error=0;
//flow->errstr[0]='\0';
flow->is_connected =0;
flow->numfd = 0; // initialize number of open file descriptors to zero
flist_init(flow->flist);
strcpy(flow->devtype,(char *)qbuf.data);
pthread_spin_lock(&mapi_lock);
......@@ -1146,6 +1149,12 @@ int mapi_close_flow(int fd)
pthread_spin_unlock(&mapi_lock);
//Free flow resources
int i; // close opened file descriptors
for(i = 0; i < flow->numfd; i++)
close(flow->fds[i]);
free(flow->devtype);
free(flow->flist);
free(flow);
......@@ -1177,7 +1186,7 @@ int mapi_apply_function(int fd, const char* funct, ...)
//funct: function to be added
{
struct mapiipcbuf qbuf;
int fds[256];
//int fds[256];
int numfd=0;
//struct functiondescr* f=malloc(sizeof(struct functiondescr));
mapidflib_function_def_t *fdef;
......@@ -1568,7 +1577,8 @@ int mapi_apply_function(int fd, const char* funct, ...)
}
DEBUG_CMD(printf("Created file for writing: %s [%s:%d]\n",filename,__FILE__,__LINE__));
fds[numfd++]=tmp;
flow->fds[flow->numfd++] = tmp;
numfd++;
addarg(&pos, &tmp, INT);
break;
......@@ -1597,7 +1607,7 @@ int mapi_apply_function(int fd, const char* funct, ...)
pthread_spin_unlock(&mapi_lock);
return -1;
}
if(!send_fd(fds,numfd)) {
if(!send_fd(flow->fds,numfd)) {
local_err=MAPI_ERROR_SEND_FD;
pthread_spin_unlock(&mapi_lock);
return -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