Commit 8968d4ea authored by 's avatar
Browse files

fixed non-blocking support for mapi_get_next_pkt() function in dimapi.


git-svn-id: file:///home/svn/mapi/trunk@1180 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent c8612bfe
......@@ -519,6 +519,9 @@ void *mapiipc_comm_thread(void *host){ // reads an IPC message - blocking call
rflow=flist_get(remote_flowlist, hflow->scope_fd);
if (dbuf->cmd==GET_NEXT_PKT_ACK) {
if (dbuf->length == BASIC_SIZE) {
hflow->pkt->caplen = 0;
}
memcpy(hflow->pkt, dbuf->data, dbuf->length-BASIC_SIZE);
flist_append(rflow->pkt_list, 0, hflow);
sem_post(&rflow->pkt_sem);
......
......@@ -2231,6 +2231,9 @@ mapi_get_next_pkt(int fd,int fid)
local_err = MCOM_SOCKET_ERROR;
return NULL;
}
if (hflow->pkt->caplen == 0) {
return NULL;
}
return hflow->pkt;
}
else {
......@@ -2238,7 +2241,10 @@ mapi_get_next_pkt(int fd,int fid)
sem_wait(&rflow->pkt_sem);
hflow=(host_flow*)flist_pop_first(rflow->pkt_list);
if (hflow==NULL) return NULL;
if (hflow==NULL) {
return NULL;
}
//send request for next packet from this host
......@@ -2254,6 +2260,10 @@ mapi_get_next_pkt(int fd,int fid)
local_err = MCOM_SOCKET_ERROR;
return NULL;
}
/* No packet, return null */
if (hflow->pkt->caplen == 0) {
return NULL;
}
return hflow->pkt;
}
}
......
......@@ -502,9 +502,8 @@ void *handle_request(void *arg) {
dbuf->length = BASIC_SIZE + sizeof(struct mapipkt) - 4 + pkt->caplen;
}
else{
dbuf->cmd = ERROR_ACK;
dbuf->cmd = GET_NEXT_PKT_ACK;
dbuf->length = BASIC_SIZE;
fprintf(stdout,"mapi_get_next_pkt failed...\n");
}
break;
case GET_FLOW_INFO:
......
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