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

t

parent fd69388c
......@@ -107,21 +107,35 @@ void *worker(void *args) {
fflush(stdout);
read(read_pipe, newfd, sizeof(newfd));
printf("\nread %d\n", *newfd);
socketEvent.data.fd=*newfd;
if (epoll_ctl(epollfd, EPOLL_CTL_ADD, *newfd, &socketEvent) == -1) {
ev.data.fd=*newfd;
ev.events = EPOLLIN;
if (epoll_ctl(epollfd, EPOLL_CTL_ADD, *newfd, &ev) == -1) {
perror("epoll_ctl: read_pipe");
printf("haga\n");
exit(EXIT_FAILURE);
}
fflush(stdout);
}
else if(events[i].data.fd == *newfd) {
else{
struct message *requestMessage= malloc(sizeof(struct message));
read( *newfd , requestMessage, sizeof(struct message));
read(events[i].data.fd , requestMessage, sizeof(struct message));
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