From 95e13360d1ef2a7caae121ae526a8a3c1ac12005 Mon Sep 17 00:00:00 2001 From: zautrix Date: Thu, 02 Sep 2004 08:57:01 +0000 Subject: Added debug putput for program hang when reading pop3 mail data --- diff --git a/kmicromail/libetpan/include/libetpan/mailstream.h b/kmicromail/libetpan/include/libetpan/mailstream.h index a4e35cd..ffb5062 100644 --- a/kmicromail/libetpan/include/libetpan/mailstream.h +++ b/kmicromail/libetpan/include/libetpan/mailstream.h @@ -34,6 +34,7 @@ */ #ifndef MAILSTREAM_H +#define DEFAULT_NETWORK_TIMEOUT 30 #define MAILSTREAM_H diff --git a/kmicromail/libetpan/tools/mailstream.c b/kmicromail/libetpan/tools/mailstream.c index 0f55e67..6d1a8cc 100644 --- a/kmicromail/libetpan/tools/mailstream.c +++ b/kmicromail/libetpan/tools/mailstream.c @@ -40,7 +40,7 @@ #include #include -#define DEFAULT_NETWORK_TIMEOUT 300 + #ifdef LIBETPAN_MAILSTREAM_DEBUG diff --git a/kmicromail/libetpan/tools/mailstream.h b/kmicromail/libetpan/tools/mailstream.h index a4e35cd..8a89a72 100644 --- a/kmicromail/libetpan/tools/mailstream.h +++ b/kmicromail/libetpan/tools/mailstream.h @@ -36,7 +36,8 @@ #ifndef MAILSTREAM_H #define MAILSTREAM_H - +//dont forget to change the value in as well +#define DEFAULT_NETWORK_TIMEOUT 30 #include #include diff --git a/kmicromail/libetpan/tools/mailstream_socket.c b/kmicromail/libetpan/tools/mailstream_socket.c index 29e50e1..04a6f48 100644 --- a/kmicromail/libetpan/tools/mailstream_socket.c +++ b/kmicromail/libetpan/tools/mailstream_socket.c @@ -169,8 +169,11 @@ static ssize_t mailstream_low_socket_read(mailstream_low * s, FD_SET(socket_data->fd, &fds_read); FD_ZERO(&fds_excp); FD_SET(socket_data->fd, &fds_excp); + // LUTZ for safety I insert here a max val as well + if ( timeout.tv_sec > DEFAULT_NETWORK_TIMEOUT ) + timeout.tv_sec = DEFAULT_NETWORK_TIMEOUT; r = select(socket_data->fd + 1, &fds_read, NULL, &fds_excp, &timeout); - if (r == 0) + if (r < 1 ) return -1; if (FD_ISSET(socket_data->fd, &fds_excp)) return -1; @@ -180,7 +183,7 @@ static ssize_t mailstream_low_socket_read(mailstream_low * s, return recv(socket_data->fd,buf,count,MSG_NOSIGNAL); //return read(socket_data->fd, buf, count); } - +#include static ssize_t mailstream_low_socket_write(mailstream_low * s, const void * buf, size_t count) { @@ -200,8 +203,12 @@ static ssize_t mailstream_low_socket_write(mailstream_low * s, FD_SET(socket_data->fd, &fds_write); FD_ZERO(&fds_excp); FD_SET(socket_data->fd, &fds_excp); + // LUTZ next line blocks sometimes + if ( timeout.tv_sec > DEFAULT_NETWORK_TIMEOUT ) + timeout.tv_sec = DEFAULT_NETWORK_TIMEOUT; + fprintf(stderr,"fd %d to secs %d \n", socket_data->fd, timeout.tv_sec ); r = select(socket_data->fd + 1, NULL, &fds_write, &fds_excp, &timeout); - if (r == 0) + if (r < 1) return -1; if (FD_ISSET(socket_data->fd, &fds_excp)) return -1; -- cgit v0.9.0.2