Commit add33d00 authored by 's avatar

important bug fix for mapi_get_next_pkt


git-svn-id: file:///home/svn/mapi/trunk@1423 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 81332213
......@@ -1874,6 +1874,7 @@ int check_network_mapid(void){
if(connect(sockfd, (struct sockaddr *)&mapidaddr_, mapidaddr_len_) < 0){ // mapid is down
free(mapidsocket_);
close(sockfd);
return 0;
}
......
......@@ -156,6 +156,9 @@ int mapiipc_read_fd();
void mapiipc_client_close(void);
void mapiipc_daemon_close(void);
#define PKT_LENGTH 131072 // pkt info and actual pkt
// large enough for cooking (stream re-assembled packets)
#ifdef DIMAPI
//holds info about a remote mapid
struct host {
......@@ -190,7 +193,6 @@ struct dmapiipcbuf {
};
#define BASIC_SIZE (sizeof(struct dmapiipcbuf) - DIMAPI_DATA_SIZE)
#define PKT_LENGTH 131072 // pkt info and actual pkt
typedef struct host_flow {
struct host *rhost;
......
......@@ -145,6 +145,7 @@ typedef struct functdescr {
mapidflib_function_t *funct;
void *data;
mapi_results_t *result;
struct mapipkt *pkt;
#ifdef RECONNECT
flowdescr_t *flow;
int numfd;
......@@ -1347,6 +1348,7 @@ int mapi_close_flow(int fd)
free(f->funct->instance);
free(f->funct);
free(f->data);
if (f->pkt!=NULL) free(f->pkt);
free(f);
f = NULL;
}
......@@ -1964,7 +1966,9 @@ int mapi_apply_function(int fd, const char* funct, ...)
f->result_init=0;
f->data=NULL;
f->result=NULL;
if ( strncmp(funct,"TO_BUFFER",9)==0 ) f->pkt=malloc(sizeof(struct mapipkt)+PKT_LENGTH);
else f->pkt=NULL;
f->funct=malloc(sizeof(mapidflib_function_t));
#ifdef RECONNECT // FIXME
f->funct->fd = flow->fd;
......@@ -2470,7 +2474,9 @@ mapi_get_next_pkt(int fd,int fid)
return NULL;
}
return res.res;
memcpy(f->pkt, res.res, res.size);
return f->pkt;
}
// Get the next packet from a to_buffer function, using asynchronous mechanism - PUSH MODEL (only for DiMAPI)
......
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