Subject: imap/locking/timeouts/mail_ping

From: Stuart Parmenter <[email-masked]>
Date: Sun, 3 May 1998 16:41:43 -0400

Hello,

I am having problems when calling mail_ping on an mailbox with an IMAP stream.
Local mailboxes do not seem to present this problem

Here is what the backtrace looks like...

#2  0x8060bff in fatal (string=0x8093b10 "Lock when already locked") at ftl_unix.c:45
#3  0x805bd36 in mail_lock (stream=0x810c730) at mail.c:2335
#4  0x8073649 in imap_send (stream=0x810c730, cmd=0x80959c2 "FETCH", args=0xbfffe918) at imap4r1.c:1722
#5  0x8071d5e in imap_structure (stream=0x810c730, msgno=8, body=0x0, flags=0) at imap4r1.c:1056
#6  0x8058bae in mail_fetch_structure (stream=0x810c730, msgno=8, body=0x0, flags=0) at mail.c:971
#7  0x805a31d in mail_fetchfrom (s=0x8136068 "", stream=0x810c730, msgno=8, length=1024) at mail.c:1630
#8  0x804e08a in append_messages (bindex=0x80f2740, first=8, last=8) at balsa-index.c:493
#9  0x804da3d in balsa_index_append_new_messages (bindex=0x80f2740) at balsa-index.c:296
#10 0x804fd89 in mm_exists (stream=0x810c730, number=8) at c-client.c:113
#11 0x805bc59 in mail_exists (stream=0x810c730, nmsgs=8) at mail.c:2286
#12 0x80759d7 in imap_parse_unsolicited (stream=0x810c730, reply=0x810c80c) at imap4r1.c:2458
#13 0x807484b in imap_reply (stream=0x810c730, tag=0xbffff3c4 "00000007") at imap4r1.c:2123
#14 0x8074768 in imap_sout (stream=0x810c730, tag=0xbffff3c4 "00000007", base=0x810c844 "00000007 NOOP\r\n", s=0xbffff3c0) at imap4r1.c:2086
#15 0x8073cab in imap_send (stream=0x810c730, cmd=0x8095c94 "NOOP", args=0x0) at imap4r1.c:1837
#16 0x8072ffd in imap_ping (stream=0x810c730) at imap4r1.c:1527
#17 0x805a798 in mail_ping (stream=0x810c730) at mail.c:1755

Its quite possible i'm doing something I shouldn't be, but like I said, it
works fine on local mailboxes.

On another note, how can one tell if the server has timed out, and if so, is
there a way to reconnect without emmiting the same callbacks as would normally
be called on a mail_open() call, since it would just be needed to reestablish
the link?

Any help would be greatly appriciated!  Thanks again!

Stuart Parmenter

---

From: Mark Crispin <[email-masked]>
Date: Sun, 3 May 1998 18:30:59 -0700 (PDT)

Your problem is that your mm_exists() callback routine is calling c-client
recursively via balse_index_append_new_messsages(), append_messages(), and
thence to mail_fetchfrom().

You are not permitted to make recursive calls into c-client.

No mm_???() routine may call a mail_???() routine (or call a routine that will
eventually call a mail_???() routine).

The "Lock when already locked" message tells you that your program attempted a
forbidden recusive call.

The way to tell that the server has timed out is (1) you should get a BYE
mm_notify() event (2) mail_ping() will return failure.  The only way to
reconnect is to do a new mail_open().  The old connection is toast, and with
it any remote server or context.