User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322) Build Identifier: mailwatch/1.0.1 I'm trying to use mailwatch with FreePops (http://www.freepops.org/en), which is a pop-to-webmail interface. Using Sylpheed with FreePops works OK, but mailwatch generates a broken pipe error. I've tried it with Fastmail and Yahoo email accounts and get the same result. Reproducible: Always Steps to Reproduce: 1. Install FreePops (see link above), and run in debug mode: freepopsd -P192.168.129.1:8118 -b localhost -w -l stdout 2. Set up account in mailwatch to access this, e.g. Name: Fastmail Mail server: localhost Username: user@fastmail.fm Port: 2000 (default freepops port) 3. View output of freepops Actual Results: mailwatch log: [Fastmail] send(): bad file descriptor freepops log: # freepopsd -P192.168.129.1:8118 -b localhost -w -l stdout Tue Jul 11 12:07:36 2006 freepopsd: INTERNAL: freepops started with loglevel 2 on a little endian machine. Tue Jul 11 12:07:36 2006 freepopsd: PID: Maintaining pid file "/var/run/freepopsd.pid" Tue Jul 11 12:07:36 2006 freepopsd: DBG(popserver.c, 182): [3047] ?? Ip address 127.0.0.1 real port 2000 Tue Jul 11 12:08:32 2006 freepopsd: DBG(popserver.c, 182): [3047] ?? Ip address 127.0.0.1 real port 2000 Tue Jul 11 12:08:32 2006 freepopsd: DBG(popserver.c, 182): [3049] -> +OK FreePOPs/0.0.99 pop3 server ready Tue Jul 11 12:08:32 2006 freepopsd: DBG(popserver.c, 182): [3049] <- USER user@fastmail.fm Tue Jul 11 12:08:32 2006 freepopsd: DBG(log_lua.c, 83): (@/usr/local/share/freepops/lua/fastmail.lua, 908) : fastmail.com(0.0.2a) found! Tue Jul 11 12:08:32 2006 freepopsd: DBG(log_lua.c, 83): (@/usr/local/share/freepops/lua/fastmail.lua, 939) : fastmail.com(0.0.2a) initialized! Tue Jul 11 12:08:32 2006 freepopsd: ALTSOCKLIB: altsocklib.c : senddata : 416 : (32)Broken pipe Tue Jul 11 12:08:32 2006 freepopsd: DBG(popserver.c, 182): [3049] !! Error calling "sendstring" (code -3 - Broken pipe) LUAY: lua error message: LUAY: /usr/local/share/freepops/lua/fastmail.lua:209: attempt to concatenate field `strPassword' (a nil value) LUAY: lua stack traceback: LUAY: /usr/local/share/freepops/lua/fastmail.lua: hash: 209 (Lua global) LUAY: /usr/local/share/freepops/lua/fastmail.lua: quit: 559 (Lua global) Tue Jul 11 12:08:32 2006 freepopsd: DBG(threads.c, 81): thread 0 will die Tue Jul 11 12:08:32 2006 freepopsd: DBG(popserver.c, 810): a network error occurred, this thread will die Tue Jul 11 12:08:44 2006 freepopsd: INTERNAL: FreePOPs killed by 2
Broken pipe usually means the remote end closed the connection unexpectedly. I took a look at freepops, and it's not immediately clear to me how to set it up. I don't really have the time to spend on this setting up some random 3rd party software. So, two options: 1. Tell me exactly how to set it up to reproduce your problem. 2. Recompile mailwatch with --enable-debug=yes, kill your panel ('xfce4-panel -x'), restart the panel from a terminal, and capture the output as it tries to connect.
Problem is the assumption that each pop3_recv will always return exactly one line (io up to a "\r\n"). This causes mailwatch to misunderstand what the server is saying, and end up the session prematurely (and i suspect some other bug in the error handling code, because in strace i see an attempt at sending a "QUIT" long after the socket is closed). With the patch below, yahoo POP works: *** orig/xfce4-mailwatch-plugin-1.0.1/panel-plugin/mailwatch-mailbox-pop3.c Thu Apr 20 10:24:36 2006 --- work/xfce4-mailwatch-plugin-1.0.1/panel-plugin/mailwatch-mailbox-pop3.c Sat Jun 30 20:26:56 2007 *************** *** 143,163 **** pop3_recv(XfceMailwatchPOP3Mailbox *pmailbox, gchar *buf, gsize len) { GError *error = NULL; ! gssize recvd; ! recvd = xfce_mailwatch_net_recv(pmailbox->sockfd, ! &pmailbox->security_info, ! buf, ! len, ! &error); ! if(recvd < 0) { xfce_mailwatch_log_message(pmailbox->mailwatch, XFCE_MAILWATCH_MAILBOX(pmailbox), XFCE_MAILWATCH_LOG_ERROR, error->message); g_error_free(error); ! } return recvd; } --- 143,168 ---- pop3_recv(XfceMailwatchPOP3Mailbox *pmailbox, gchar *buf, gsize len) { GError *error = NULL; ! gssize recvd = 0; ! gssize recvd_now; ! do { ! recvd_now = xfce_mailwatch_net_recv(pmailbox->sockfd, ! &pmailbox->security_info, ! buf + recvd, ! len - recvd, ! &error); ! if(recvd_now < 0) { xfce_mailwatch_log_message(pmailbox->mailwatch, XFCE_MAILWATCH_MAILBOX(pmailbox), XFCE_MAILWATCH_LOG_ERROR, error->message); g_error_free(error); ! return recvd_now; ! } ! recvd += recvd_now; ! } while (recvd <= 2 || buf[recvd-1] != '\n' || buf[recvd-2] != '\r'); return recvd; }
Please use 'diff -u'; I can't really tell what changed there, and attach the patch using the link above rather than pasting in the comments box.
Created attachment 1274 pop3 patch
I have the same problem with poczta.o2.pl server. I have done some testing with tcpdump and it appears that the initial response of the server is "+OK" and after that in another pocket the server sends rest of the line "Ready poczta.o2.pl". The Mail Watcher does not wait for that and sends the "USER foo" line before and probably treats the "Ready poczta.o2.pl" as a server response. If I understand correctly the patch by Alec Panovici makes the Mail Watcher read the server responses until /r/n is found so this will fix problem with poczta.o2.pl too. For testing you may use pop3 server poczta.o2.pl, user: bimbombam, pass: 0test5
Network code refactoring and partial rewrite is done. Problems like this should be gone. Please reopen if not. If you can test svn trunk, please do.