Server now checks the connection and correctly closes the clients file descriptor if the client exits silently

master
Stefan Krulj 12 years ago
parent e3e00623a7
commit e0c708eceb
  1. 2
      src/DAP_config.h
  2. 9
      src/socket_ipc.c

@ -86,7 +86,7 @@ Provides definitions about:
/// This configuration settings is used to optimized the communication performance with the
/// debugger and depends on the USB peripheral. For devices with limited RAM or USB buffer the
/// setting can be reduced (valid range is 1 .. 255). Change setting to 4 for High-Speed USB.
#define DAP_PACKET_COUNT 64 ///< Buffers: 64 = Full-Speed, 4 = High-Speed.
#define DAP_PACKET_COUNT 1 ///< Buffers: 64 = Full-Speed, 4 = High-Speed.
/// Debug Unit is connected to fixed Target Device.

@ -108,6 +108,7 @@ void wait_for_client(void) {
if(flags < 0 ){
flags = 0;
}
/* TODO change nonblocking to a timed out read */
if( fcntl(csockfd, F_SETFL, flags | O_NONBLOCK) < 0 ){
DEBUGF("ERROR seting non-blocking: %s\n", strerror(errno));
}
@ -178,7 +179,13 @@ void process_data(void) {
}
}else if( n<0 ){
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:
DEBUGF("A problem occured: %d %d %s\n", n, errno,strerror(errno) );
DEBUG("Closing connection!\n");

Loading…
Cancel
Save