Commit b0fcee06 authored by Roshan Rabinarayan's avatar Roshan Rabinarayan

infinite looping :solved

parent 77c47536
......@@ -54,12 +54,17 @@ struct message *request(char status,char* key,char* value)
void func(int sockfd,struct message* requestMessage)
{
char buff[MAX];
int n;
int n=0;
for (;;) {
bzero(buff, sizeof(buff));
n = 0;
if((n++)==0)
if(n==0)
{
n++;
printf("[Message sent to server]\n[[Status:%c]\n[Key:%s]\n[Value:%s]]",requestMessage->status,requestMessage->key,requestMessage->value);
write(sockfd, requestMessage, sizeof(struct message));
}
//printf("[Message sent to server]\n[[Status:%c]\n[Key:%s]\n[Value:%s]]",requestMessage->status,requestMessage->key,requestMessage->value);
}
......
......@@ -108,7 +108,7 @@ void *worker(void *args) {
read(read_pipe, newfd, sizeof(newfd));
printf("\nread %d\n", *newfd);
ev.data.fd=*newfd;
ev.events = EPOLLIN;
ev.events = EPOLLIN|EPOLLET;
if (epoll_ctl(epollfd, EPOLL_CTL_ADD, *newfd, &ev) == -1) {
perror("epoll_ctl: read_pipe");
exit(EXIT_FAILURE);
......@@ -119,18 +119,18 @@ void *worker(void *args) {
else{
struct message *requestMessage= malloc(sizeof(struct message));
read(events[i].data.fd , requestMessage, sizeof(struct message));
int readlength=read(events[i].data.fd , requestMessage, sizeof(struct message));
if(requestMessage->status ==EOF)
{
ev.data.fd=events[i].data.fd;
ev.events = EPOLLIN;
ev.events = EPOLLIN|EPOLLET;
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);
printf("[Message Received from client]\n[[Status:%c][Key:%s][Value:%s]]",requestMessage->status,requestMessage->key,requestMessage->value);
fflush(stdout);
}
......
No preview for this file type
No preview for this file type
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