summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libetpan/include/libetpan/mailstream.h1
-rw-r--r--kmicromail/libetpan/tools/mailstream.c2
-rw-r--r--kmicromail/libetpan/tools/mailstream.h3
-rw-r--r--kmicromail/libetpan/tools/mailstream_socket.c13
4 files changed, 14 insertions, 5 deletions
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
@@ -21,32 +21,33 @@
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* $Id$
*/
#ifndef MAILSTREAM_H
+#define DEFAULT_NETWORK_TIMEOUT 30
#define MAILSTREAM_H
#include <sys/time.h>
#include <libetpan/mailstream_low.h>
#include <libetpan/mailstream_helper.h>
#include <libetpan/mailstream_socket.h>
#include <libetpan/mailstream_ssl.h>
#include <libetpan/mailstream_types.h>
#ifdef __cplusplus
extern "C" {
#endif
mailstream * mailstream_new(mailstream_low * low, size_t buffer_size);
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
@@ -27,33 +27,33 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* $Id$
*/
#include "mailstream.h"
#include "maillock.h"
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
-#define DEFAULT_NETWORK_TIMEOUT 300
+
#ifdef LIBETPAN_MAILSTREAM_DEBUG
#define STREAM_DEBUG
#include <stdio.h>
#define LOG_FILE "libetpan-stream-debug.log"
int mailstream_debug = 0;
#define STREAM_LOG_BUF(buf, size) \
if (mailstream_debug) { \
FILE * f; \
mode_t old_mask; \
\
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
@@ -23,33 +23,34 @@
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* $Id$
*/
#ifndef MAILSTREAM_H
#define MAILSTREAM_H
-
+//dont forget to change the value in <libetpan/mailstream.h> as well
+#define DEFAULT_NETWORK_TIMEOUT 30
#include <sys/time.h>
#include <libetpan/mailstream_low.h>
#include <libetpan/mailstream_helper.h>
#include <libetpan/mailstream_socket.h>
#include <libetpan/mailstream_ssl.h>
#include <libetpan/mailstream_types.h>
#ifdef __cplusplus
extern "C" {
#endif
mailstream * mailstream_new(mailstream_low * low, size_t buffer_size);
ssize_t mailstream_write(mailstream * s, const void * buf, size_t count);
ssize_t mailstream_read(mailstream * s, void * buf, size_t count);
int mailstream_close(mailstream * s);
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
@@ -156,65 +156,72 @@ static ssize_t mailstream_low_socket_read(mailstream_low * s,
socket_data = (struct mailstream_socket_data *) s->data;
/* timeout */
{
fd_set fds_read;
fd_set fds_excp;
struct timeval timeout;
int r;
timeout = mailstream_network_delay;
FD_ZERO(&fds_read);
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;
if (!FD_ISSET(socket_data->fd, &fds_read))
return 0;
}
return recv(socket_data->fd,buf,count,MSG_NOSIGNAL);
//return read(socket_data->fd, buf, count);
}
-
+#include <stdio.h>
static ssize_t mailstream_low_socket_write(mailstream_low * s,
const void * buf, size_t count)
{
struct mailstream_socket_data * socket_data;
socket_data = (struct mailstream_socket_data *) s->data;
/* timeout */
{
fd_set fds_write;
fd_set fds_excp;
struct timeval timeout;
int r;
timeout = mailstream_network_delay;
FD_ZERO(&fds_write);
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;
if (!FD_ISSET(socket_data->fd, &fds_write))
return 0;
}
return send(socket_data->fd,buf,count,MSG_NOSIGNAL);
//return write(socket_data->fd, buf, count);
}
/* mailstream */
mailstream * mailstream_socket_open(int fd)
{