Ticket #23 (new enhancement)

Opened 3 years ago

Last modified 4 months ago

pop3-pluging blocks on read

Reported by: whaslbeck@… Owned by: michael
Priority: normal Component: lcd4linux
Version: 0.1 Severity: normal
Keywords: Cc:

Description

I discovered that lcd4linux stops updating the display after some time (about 2 or 3 days). I've done some resarch and discoverd that lcd4linux hangs inside the pop3-plugin. After attaching gdb to the running process, I get the following stacktrace:

(gdb) bt
#0  0xb7d832ce in read () from /lib/tls/libc.so.6
#1  0x08058ac3 in pop3_recv_crlf_terminated (sockfd=8, buf=0xbfc6a9c0 "", size=8192) at plugin_pop3.c:234
#2  0x08058d44 in my_POP3check (result=0x806d8d0, check=0x806d908) at plugin_pop3.c:188
#3  0x0804d72d in EvalTree (Root=0x806d8b0) at evaluator.c:1085
#4  0x0804ddd7 in Eval (tree=0x806d8b0, result=0xbfc6cb34) at evaluator.c:1294
#5  0x08050230 in widget_text_update (Self=0x8077230) at widget_text.c:280
#6  0x0804f066 in timer_process (delay=0xbfc6cbf0) at timer.c:196
#7  0x0804adbb in main (argc=4, argv=0xbfc6cc94) at lcd4linux.c:684

when I set the stackframe up to my_POP3check() and return to the application, the applicaton continues running.

So I think the read() inside pop3_recv_crlf_terminated() should be nonblocking/timeout'ed (with select() or poll()).

Regards, Walter

Attachments

Change History

Changed 3 years ago by whaslbeck@…

I added a timeout to the read() some hours ago. It runs - until now, here is the patch against current public-CVS-version:

--- plugin_pop3.c.orig	2005-12-30 17:40:26.000000000 +0100
+++ plugin_pop3.c	2005-12-30 17:40:44.000000000 +0100
@@ -81,6 +81,8 @@
 #include <unistd.h>
 /*#include <pwd.h> */
 #include <stdio.h>
+#include <sys/poll.h>
+#include <errno.h>
 
 #ifdef WITH_DMALLOC
 #include <dmalloc.h>
@@ -227,11 +229,28 @@
 static void pop3_recv_crlf_terminated(int sockfd, char *buf, int size)
 {
     /* receive one line server responses terminated with CRLF */
-    char *pos;
+    char *pos = buf;
     int bytes = 0;
+    struct pollfd rfd;
+    rfd.fd = sockfd;
+    rfd.events = POLLIN | POLLPRI;
     memset(buf, 0, size);
-    while ((pos = strstr(buf, "\r\n")) == NULL)
-	bytes += read(sockfd, buf + bytes, size - bytes);
+
+    while ((pos = strstr(buf, "\r\n")) == NULL) {
+	switch (poll(&rfd, 1, 1000) ) {
+	    case -1:
+		/* error */
+		error("[POP3] poll error: %d (%s)\n", errno, strerror(errno));
+		return;
+	    case 0:
+		/* timeout */
+		error("[POP3] poll timeout\n");
+		break;
+	    default:
+		bytes += read(sockfd, buf + bytes, size - bytes);
+	}
+    }
+
     *pos = '\0';
 }
 

Changed 4 months ago by anonymous

  • type changed from defect to enhancement

Add/Change #23 (pop3-pluging blocks on read)

Author



Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will change. Next status will be 'new'
The owner will change to anonymous. Next status will be 'assigned'
 
Note: See TracTickets for help on using tickets.