|
|
|
@ -108,6 +108,7 @@ void wait_for_client(void) { |
|
|
|
if(flags < 0 ){ |
|
|
|
if(flags < 0 ){ |
|
|
|
flags = 0; |
|
|
|
flags = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* TODO change nonblocking to a timed out read */ |
|
|
|
if( fcntl(csockfd, F_SETFL, flags | O_NONBLOCK) < 0 ){ |
|
|
|
if( fcntl(csockfd, F_SETFL, flags | O_NONBLOCK) < 0 ){ |
|
|
|
DEBUGF("ERROR seting non-blocking: %s\n", strerror(errno)); |
|
|
|
DEBUGF("ERROR seting non-blocking: %s\n", strerror(errno)); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -178,7 +179,13 @@ void process_data(void) { |
|
|
|
} |
|
|
|
} |
|
|
|
}else if( n<0 ){ |
|
|
|
}else if( n<0 ){ |
|
|
|
switch( errno ) { |
|
|
|
switch( errno ) { |
|
|
|
case EAGAIN: break; |
|
|
|
case EAGAIN: |
|
|
|
|
|
|
|
/* try to write an empty message to check connection */ |
|
|
|
|
|
|
|
n = write(csockfd,NULL,0); |
|
|
|
|
|
|
|
if( n == 0 ){ |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/*no break*/ |
|
|
|
default: |
|
|
|
default: |
|
|
|
DEBUGF("A problem occured: %d %d %s\n", n, errno,strerror(errno) ); |
|
|
|
DEBUGF("A problem occured: %d %d %s\n", n, errno,strerror(errno) ); |
|
|
|
DEBUG("Closing connection!\n"); |
|
|
|
DEBUG("Closing connection!\n"); |
|
|
|
|