Commit 43eeccb7 authored by 's avatar

added missing free(dbuf), fixed some warnings


git-svn-id: file:///home/svn/mapi/trunk@276 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 2d1ee05f
...@@ -69,7 +69,6 @@ int main(int argc, char **argv) { ...@@ -69,7 +69,6 @@ int main(int argc, char **argv) {
die("Unexpected error on setsockopt()"); die("Unexpected error on setsockopt()");
} }
if (bind(serv_sock, (struct sockaddr *)&serv_addr, sizeof serv_addr) == -1) { if (bind(serv_sock, (struct sockaddr *)&serv_addr, sizeof serv_addr) == -1) {
close(serv_sock); close(serv_sock);
die("Unexpected error on bind()"); die("Unexpected error on bind()");
...@@ -112,10 +111,9 @@ void *handle_request(void *arg) { ...@@ -112,10 +111,9 @@ void *handle_request(void *arg) {
mapi_function_info_t funct_info; mapi_function_info_t funct_info;
mapi_flow_info_t flow_info; mapi_flow_info_t flow_info;
struct timeval tv; /*used for timestamping results when produced */ struct timeval tv; /*used for timestamping results when produced */
struct timezone tz; struct timezone tz;
struct mapipkt *pkt; struct mapipkt *pkt;
/* Guarantees that thread resources are deallocated upon return */ /* Guarantees that thread resources are deallocated upon return */
pthread_detach(pthread_self()); pthread_detach(pthread_self());
dbuf = (struct dmapiipcbuf *)malloc(sizeof(struct dmapiipcbuf)); dbuf = (struct dmapiipcbuf *)malloc(sizeof(struct dmapiipcbuf));
...@@ -145,7 +143,7 @@ void *handle_request(void *arg) { ...@@ -145,7 +143,7 @@ void *handle_request(void *arg) {
memcpy(dbuf,buffer,((struct dmapiipcbuf *)buffer)->length); memcpy(dbuf,buffer,((struct dmapiipcbuf *)buffer)->length);
switch(dbuf->cmd) { switch(dbuf->cmd) {
case CREATE_FLOW: case CREATE_FLOW:
mapid_result = mapi_create_flow(dbuf->data); mapid_result = mapi_create_flow((char *)dbuf->data);
fprintf(stdout,"CREATE_FLOW (%s, %d)\n",dbuf->data, mapid_result); fprintf(stdout,"CREATE_FLOW (%s, %d)\n",dbuf->data, mapid_result);
if(mapid_result <0) if(mapid_result <0)
dbuf->cmd = ERROR_ACK; dbuf->cmd = ERROR_ACK;
...@@ -337,6 +335,7 @@ void *handle_request(void *arg) { ...@@ -337,6 +335,7 @@ void *handle_request(void *arg) {
} }
} }
free(active_flows); free(active_flows);
free(dbuf);
shutdown(sock, SHUT_RDWR); shutdown(sock, SHUT_RDWR);
close(sock); close(sock);
...@@ -381,8 +380,8 @@ int getfid(struct dmapiipcbuf *dbuf){ ...@@ -381,8 +380,8 @@ int getfid(struct dmapiipcbuf *dbuf){
//for THRESHOLD //for THRESHOLD
int type, boundary, divider; int type, boundary, divider;
unsigned long long lthreshold; unsigned long long lthreshold;
char* function=dbuf->data; char *function = (char *)dbuf->data;
char* data=dbuf->data+strlen(dbuf->data)+1; char *data = (char *)(dbuf->data+strlen((char *)dbuf->data)+1);
if(!strcmp(function,"BPF_FILTER")){//Checked if(!strcmp(function,"BPF_FILTER")){//Checked
fprintf(stdout,"%s, %s\n",function, data); fprintf(stdout,"%s, %s\n",function, data);
......
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