Commit 77c47536 authored by Roshan Rabinarayan's avatar Roshan Rabinarayan

t

parent fd69388c
...@@ -107,20 +107,34 @@ void *worker(void *args) { ...@@ -107,20 +107,34 @@ void *worker(void *args) {
fflush(stdout); fflush(stdout);
read(read_pipe, newfd, sizeof(newfd)); read(read_pipe, newfd, sizeof(newfd));
printf("\nread %d\n", *newfd); printf("\nread %d\n", *newfd);
socketEvent.data.fd=*newfd; ev.data.fd=*newfd;
if (epoll_ctl(epollfd, EPOLL_CTL_ADD, *newfd, &socketEvent) == -1) { ev.events = EPOLLIN;
if (epoll_ctl(epollfd, EPOLL_CTL_ADD, *newfd, &ev) == -1) {
perror("epoll_ctl: read_pipe"); perror("epoll_ctl: read_pipe");
printf("haga\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
fflush(stdout); fflush(stdout);
} }
else if(events[i].data.fd == *newfd) { else{
struct message *requestMessage= malloc(sizeof(struct message)); struct message *requestMessage= malloc(sizeof(struct message));
read( *newfd , requestMessage, sizeof(struct message)); read(events[i].data.fd , requestMessage, sizeof(struct message));
printf("[Message Received from client]\n[[Status:%c]\n[Key:%s]\n[Value:%s]]",requestMessage->status,requestMessage->key,requestMessage->value); if(requestMessage->status ==EOF)
{
ev.data.fd=events[i].data.fd;
ev.events = EPOLLIN;
epoll_ctl( epollfd, EPOLL_CTL_DEL, events[i].data.fd , &ev );
close(events[i].data.fd);
}
else
{
printf("[Message Received from client]\n[[Status:%c]\n[Key:%s]\n[Value:%s]]",requestMessage->status,requestMessage->key,requestMessage->value);
}
} }
} }
} }
......
No preview for this file type
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