mail_open gives an invalid handle to a MAILSTREAM
Alejandro RĂos <[email protected]> Tue, 27 May 2014 16:50:40 -0500
| Newsgroups | gmane.mail.imap.uw.c-client |
|---|---|
| Message-ID | <CAM16xaE-9cdKKAsX1=ZTrHDkvZDK_AQ1+8f_=Zn9yuJqK=NxRQ@mail.gmail.com> |
--===============0974625899767655265==
Content-Type: multipart/alternative; boundary=047d7b6d8432dbc8e004fa68afc8
--047d7b6d8432dbc8e004fa68afc8
Content-Type: text/plain; charset=UTF-8
Hello,
A setup of Asterisk 12 with IMAP-uw 2007e works ok with the default value
of "maxmsg=100" on voicemail.conf
However, if I increase that value to a higher limit (maxmsg=400, for
example), Asterisk crashes when reaching a voicemail count of about 250 to
280 messages. I have reproduced this issue with different asterisk
versions, see the full Asterisk backtrace and developer comments on
https://issues.asterisk.org/jira/browse/ASTERISK-23759
I saw a similar problem on this email thread:
https://mailman13.u.washington.edu/mailman/htdig/imap-uw/2007-October/001707.html
Looks like the issue is on the double call to mail_open, but the Asterisk
developers say the first calling of mail_open gives back an invalid handle
to a MAILSTREAM. Maybe this is due to the number of messages beign too
large? So far on all the tests the crash happens when the mailbox has
more than ~250 messages.
The fuction where mail_open is called twice is the following:
########
static int init_mailstream(struct vm_state *vms, int box)
{
MAILSTREAM *stream = NIL;
long debug;
char tmp[256];
if (!vms) {
ast_log(LOG_ERROR, "vm_state is NULL!\n");
return -1;
}
ast_debug(3, "vm_state user is:%s\n", vms->imapuser);
if (vms->mailstream == NIL || !vms->mailstream) {
ast_debug(1, "mailstream not set.\n");
} else {
stream = vms->mailstream;
}
/* debug = T; user wants protocol telemetry? */
debug = NIL; /* NO protocol telemetry? */
if (delimiter == '\0') { /* did not probe the server
yet */
char *cp;
#ifdef USE_SYSTEM_IMAP
#include <imap/linkage.c>
#elif defined(USE_SYSTEM_CCLIENT)
#include <c-client/linkage.c>
#else
#include "linkage.c"
#endif
/* Connect to INBOX first to get folders delimiter */
imap_mailbox_name(tmp, sizeof(tmp), vms, 0, 1);
ast_mutex_lock(&vms->lock);
stream = mail_open (stream, tmp, debug ? OP_DEBUG : NIL);
ast_mutex_unlock(&vms->lock);
if (stream == NIL) {
ast_log(LOG_ERROR, "Can't connect to imap server
%s\n", tmp);
return -1;
}
get_mailbox_delimiter(vms, stream);
/* update delimiter in imapfolder */
for (cp = vms->imapfolder; *cp; cp++)
if (*cp == '/')
*cp = delimiter;
}
/* Now connect to the target folder */
imap_mailbox_name(tmp, sizeof(tmp), vms, box, 1);
ast_debug(3, "Before mail_open, server: %s, box:%d\n", tmp, box);
ast_mutex_lock(&vms->lock);
vms->mailstream = mail_open (stream, tmp, debug ? OP_DEBUG : NIL);
ast_mutex_unlock(&vms->lock);
if (vms->mailstream == NIL) {
return -1;
} else {
return 0;
}
}
######################
Any help would be appreciated,
Thank you and best regards,
Alejandro
--047d7b6d8432dbc8e004fa68afc8
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: base64
PGRpdiBkaXI9Imx0ciI+PGRpdj48ZGl2PjxkaXY+PGRpdj5IZWxsbyw8YnI+PC9kaXY+PHA+QSBz
ZXR1cCBvZiBBc3RlcmlzayAxMiB3aXRoIElNQVAtdXcgMjAwN2Ugd29ya3Mgb2sgd2l0aCB0aGUg
ZGVmYXVsdCB2YWx1ZSBvZiAmcXVvdDttYXhtc2c9MTAwJnF1b3Q7IG9uIHZvaWNlbWFpbC5jb25m
PC9wPg0KDQo8cD5Ib3dldmVyLCBpZiBJIGluY3JlYXNlIHRoYXQgdmFsdWUgdG8gYSBoaWdoZXIg
bGltaXQgKG1heG1zZz00MDAsIGZvciANCmV4YW1wbGUpLCBBc3RlcmlzayBjcmFzaGVzIHdoZW4g
cmVhY2hpbmcgYSB2b2ljZW1haWwgY291bnQgb2YgYWJvdXQgMjUwIA0KdG8gMjgwIG1lc3NhZ2Vz
LsKgIEkgaGF2ZSByZXByb2R1Y2VkIHRoaXMgaXNzdWUgd2l0aCBkaWZmZXJlbnQgYXN0ZXJpc2sg
dmVyc2lvbnM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PGJyPjxicj48L2Rpdj5BbGVqYW5kcm88YnI+
PC9kaXY+DQo=
--047d7b6d8432dbc8e004fa68afc8--
--===============0974625899767655265==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Imap-uw mailing list
[email protected]
http://mailman13.u.washington.edu/mailman/listinfo/imap-uw
--===============0974625899767655265==--