Commit add33d00 authored by 's avatar
Browse files

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){ ...@@ -1874,6 +1874,7 @@ int check_network_mapid(void){
if(connect(sockfd, (struct sockaddr *)&mapidaddr_, mapidaddr_len_) < 0){ // mapid is down if(connect(sockfd, (struct sockaddr *)&mapidaddr_, mapidaddr_len_) < 0){ // mapid is down
free(mapidsocket_); free(mapidsocket_);
close(sockfd);
return 0; return 0;
} }
......
...@@ -156,6 +156,9 @@ int mapiipc_read_fd(); ...@@ -156,6 +156,9 @@ int mapiipc_read_fd();
void mapiipc_client_close(void); void mapiipc_client_close(void);
void mapiipc_daemon_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 #ifdef DIMAPI
//holds info about a remote mapid //holds info about a remote mapid
struct host { struct host {
...@@ -190,7 +193,6 @@ struct dmapiipcbuf { ...@@ -190,7 +193,6 @@ struct dmapiipcbuf {
}; };
#define BASIC_SIZE (sizeof(struct dmapiipcbuf) - DIMAPI_DATA_SIZE) #define BASIC_SIZE (sizeof(struct dmapiipcbuf) - DIMAPI_DATA_SIZE)
#define PKT_LENGTH 131072 // pkt info and actual pkt
typedef struct host_flow { typedef struct host_flow {
struct host *rhost; struct host *rhost;
......
...@@ -145,6 +145,7 @@ typedef struct functdescr { ...@@ -145,6 +145,7 @@ typedef struct functdescr {
mapidflib_function_t *funct; mapidflib_function_t *funct;
void *data; void *data;
mapi_results_t *result; mapi_results_t *result;
struct mapipkt *pkt;
#ifdef RECONNECT #ifdef RECONNECT
flowdescr_t *flow; flowdescr_t *flow;
int numfd; int numfd;
...@@ -1347,6 +1348,7 @@ int mapi_close_flow(int fd) ...@@ -1347,6 +1348,7 @@ int mapi_close_flow(int fd)
free(f->funct->instance); free(f->funct->instance);
free(f->funct); free(f->funct);
free(f->data); free(f->data);
if (f->pkt!=NULL) free(f->pkt);
free(f); free(f);
f = NULL; f = NULL;
} }
...@@ -1964,7 +1966,9 @@ int mapi_apply_function(int fd, const char* funct, ...) ...@@ -1964,7 +1966,9 @@ int mapi_apply_function(int fd, const char* funct, ...)
f->result_init=0; f->result_init=0;
f->data=NULL; f->data=NULL;
f->result=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)); f->funct=malloc(sizeof(mapidflib_function_t));
#ifdef RECONNECT // FIXME #ifdef RECONNECT // FIXME
f->funct->fd = flow->fd; f->funct->fd = flow->fd;
...@@ -2470,7 +2474,9 @@ mapi_get_next_pkt(int fd,int fid) ...@@ -2470,7 +2474,9 @@ mapi_get_next_pkt(int fd,int fid)
return NULL; 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) // 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