Last summer I sent in some patches to speed up the IMAP module's dealing with large mailboxes. At the time I noted that there were similar problems with other parts of the module, but I didn't have time to fix them then.
Since I still see the problems in 4.2.0 (and I've suddenly had a need to improve performance with large #'s of mailboxes), I went ahead and finished the patch for folder lists. The changes to php_imap.c and php_imap.h are attached. Basically the same things that I did to the message list last year. If someone could briefly look these over and commit them that would be very helpful. Thanks, -Rob -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Rob Siemborski | Andrew Systems Group * Research Systems Programmer | Cyert Hall 235 * 412-268-7456 -----BEGIN GEEK CODE BLOCK---- Version: 3.12 GCS/IT/CM/PA d- s+: a-- C++++$ UBLS++++$ P+++$ L++(+++) E W+ N- o? K- w O- M-- V-- PS+ PE++ Y+ PGP+ t+@ 5+++ R@ tv-- b++ DI+++ G e h r y? ------END GEEK CODE BLOCK-----
--- php_imap.c.orig Thu Feb 28 03:26:16 2002 +++ php_imap.c Fri May 10 14:36:11 2002 @@ -286,15 +286,21 @@ * Accepts: pointer to FOBJECTLIST pointer * Author: CJH */ -void mail_free_foblist(FOBJECTLIST **foblist) +void mail_free_foblist(FOBJECTLIST **foblist, FOBJECTLIST **tail) { - if (*foblist) { /* only free if exists */ - if ((*foblist)->text.data) { - fs_give ((void **) &(*foblist)->text.data); - } - mail_free_foblist (&(*foblist)->next); - fs_give ((void **) foblist); /* return string to free storage */ - } + FOBJECTLIST *cur, *next; + + for(cur=*foblist, next=cur->next; cur; cur=next) { + next = cur->next; + + if(cur->text.data) + fs_give((void **)&(cur->text.data)); + + fs_give((void **)&cur); + } + + *tail = NIL; + *foblist = NIL; } /* }}} */ @@ -387,14 +393,21 @@ { imap_globals->imap_user = NIL; imap_globals->imap_password = NIL; - imap_globals->imap_folders = NIL; - imap_globals->imap_sfolders = NIL; + imap_globals->imap_alertstack = NIL; imap_globals->imap_errorstack = NIL; + + imap_globals->imap_folders = NIL; + imap_globals->imap_folders_tail = NIL; + imap_globals->imap_sfolders = NIL; + imap_globals->imap_sfolders_tail = NIL; imap_globals->imap_messages = NIL; imap_globals->imap_messages_tail = NIL; imap_globals->imap_folder_objects = NIL; + imap_globals->imap_folder_objects_tail = NIL; imap_globals->imap_sfolder_objects = NIL; + imap_globals->imap_sfolder_objects_tail = NIL; + imap_globals->folderlist_style = FLIST_ARRAY; } /* }}} */ @@ -633,6 +646,7 @@ acur = acur->next; } mail_free_stringlist(&IMAPG(imap_alertstack)); + IMAPG(imap_alertstack) = NIL; } return SUCCESS; } @@ -1374,7 +1388,7 @@ /* set flag for normal, old mailbox list */ IMAPG(folderlist_style) = FLIST_ARRAY; - IMAPG(imap_folders) = NIL; + IMAPG(imap_folders) = IMAPG(imap_folders_tail) = NIL; mail_list(imap_le_struct->imap_stream, Z_STRVAL_PP(ref), Z_STRVAL_PP(pat)); if (IMAPG(imap_folders) == NIL) { RETURN_FALSE; @@ -1387,6 +1401,7 @@ cur=cur->next; } mail_free_stringlist (&IMAPG(imap_folders)); + IMAPG(imap_folders) = IMAPG(imap_folders_tail) = NIL; } /* }}} */ @@ -1413,7 +1428,7 @@ /* set flag for new, improved array of objects mailbox list */ IMAPG(folderlist_style) = FLIST_OBJECT; - IMAPG(imap_folder_objects) = NIL; + IMAPG(imap_folder_objects) = IMAPG(imap_folder_objects_tail) = NIL; mail_list(imap_le_struct->imap_stream, Z_STRVAL_PP(ref), Z_STRVAL_PP(pat)); if (IMAPG(imap_folder_objects) == NIL) { RETURN_FALSE; @@ -1437,7 +1452,7 @@ add_next_index_object(return_value, mboxob); cur=cur->next; } - mail_free_foblist(&IMAPG(imap_folder_objects)); + mail_free_foblist(&IMAPG(imap_folder_objects), +&IMAPG(imap_folder_objects_tail)); efree(delim); IMAPG(folderlist_style) = FLIST_ARRAY; /* reset to default */ } @@ -1474,6 +1489,7 @@ cur=cur->next; } mail_free_stringlist (&IMAPG(imap_folders)); + IMAPG(imap_folders) = IMAPG(imap_folders_tail) = NIL; } /* }}} */ @@ -1712,6 +1728,7 @@ cur=cur->next; } mail_free_stringlist (&IMAPG(imap_sfolders)); + IMAPG(imap_sfolders) = IMAPG(imap_sfolders_tail) = NIL; } /* }}} */ @@ -1739,7 +1756,7 @@ /* set flag for new, improved array of objects list */ IMAPG(folderlist_style) = FLIST_OBJECT; - IMAPG(imap_sfolder_objects) = NIL; + IMAPG(imap_sfolder_objects) = IMAPG(imap_sfolder_objects_tail) = NIL; mail_lsub(imap_le_struct->imap_stream, Z_STRVAL_PP(ref), Z_STRVAL_PP(pat)); if (IMAPG(imap_sfolder_objects) == NIL) { RETURN_FALSE; @@ -1762,7 +1779,7 @@ add_next_index_object(return_value, mboxob); cur=cur->next; } - mail_free_foblist (&IMAPG(imap_sfolder_objects)); + mail_free_foblist (&IMAPG(imap_sfolder_objects), +&IMAPG(imap_sfolder_objects_tail)); efree(delim); IMAPG(folderlist_style) = FLIST_ARRAY; /* reset to default */ } @@ -3969,17 +3986,16 @@ IMAPG(imap_folder_objects)->delimiter = delimiter; IMAPG(imap_folder_objects)->attributes = attributes; IMAPG(imap_folder_objects)->next = NIL; + IMAPG(imap_folder_objects_tail) = IMAPG(imap_folder_objects); } else { - ocur=IMAPG(imap_folder_objects); - while (ocur->next != NIL) { - ocur=ocur->next; - } + ocur=IMAPG(imap_folder_objects_tail); ocur->next=mail_newfolderobjectlist(); ocur=ocur->next; ocur->LSIZE = strlen(ocur->LTEXT = cpystr(mailbox)); ocur->delimiter = delimiter; ocur->attributes = attributes; ocur->next = NIL; + IMAPG(imap_folder_objects_tail) = ocur; } } else { @@ -3989,15 +4005,14 @@ IMAPG(imap_folders)=mail_newstringlist(); IMAPG(imap_folders)->LSIZE=strlen(IMAPG(imap_folders)->LTEXT=cpystr(mailbox)); IMAPG(imap_folders)->next=NIL; + IMAPG(imap_folders_tail) = IMAPG(imap_folders); } else { - cur=IMAPG(imap_folders); - while (cur->next != NIL) { - cur=cur->next; - } + cur=IMAPG(imap_folders_tail); cur->next=mail_newstringlist (); cur=cur->next; cur->LSIZE = strlen (cur->LTEXT = cpystr (mailbox)); cur->next = NIL; + IMAPG(imap_folders_tail) = cur; } } } @@ -4018,17 +4033,16 @@ IMAPG(imap_sfolder_objects)->delimiter = delimiter; IMAPG(imap_sfolder_objects)->attributes = attributes; IMAPG(imap_sfolder_objects)->next = NIL; + IMAPG(imap_sfolder_objects_tail) = +IMAPG(imap_sfolder_objects); } else { - ocur=IMAPG(imap_sfolder_objects); - while (ocur->next != NIL) { - ocur=ocur->next; - } + ocur=IMAPG(imap_sfolder_objects_tail); ocur->next=mail_newfolderobjectlist(); ocur=ocur->next; ocur->LSIZE=strlen(ocur->LTEXT = cpystr(mailbox)); ocur->delimiter = delimiter; ocur->attributes = attributes; ocur->next = NIL; + IMAPG(imap_sfolder_objects_tail) = ocur; } } else { /* build the old simple array for imap_listsubscribed() */ @@ -4036,15 +4050,14 @@ IMAPG(imap_sfolders)=mail_newstringlist(); IMAPG(imap_sfolders)->LSIZE=strlen(IMAPG(imap_sfolders)->LTEXT=cpystr(mailbox)); IMAPG(imap_sfolders)->next=NIL; + IMAPG(imap_sfolders_tail) = IMAPG(imap_sfolders); } else { - cur=IMAPG(imap_sfolders); - while (cur->next != NIL) { - cur=cur->next; - } + cur=IMAPG(imap_sfolders_tail); cur->next=mail_newstringlist (); cur=cur->next; cur->LSIZE = strlen (cur->LTEXT = cpystr (mailbox)); cur->next = NIL; + IMAPG(imap_sfolders_tail) = cur; } } }
--- php_imap.h.orig Mon Mar 11 18:11:37 2002 +++ php_imap.h Fri May 10 14:37:16 2002 @@ -185,14 +185,21 @@ ZEND_BEGIN_MODULE_GLOBALS(imap) char *imap_user; char *imap_password; - STRINGLIST *imap_folders; - STRINGLIST *imap_sfolders; + STRINGLIST *imap_alertstack; ERRORLIST *imap_errorstack; + + STRINGLIST *imap_folders; + STRINGLIST *imap_folders_tail; + STRINGLIST *imap_sfolders; + STRINGLIST *imap_sfolders_tail; MESSAGELIST *imap_messages; MESSAGELIST *imap_messages_tail; FOBJECTLIST *imap_folder_objects; + FOBJECTLIST *imap_folder_objects_tail; FOBJECTLIST *imap_sfolder_objects; + FOBJECTLIST *imap_sfolder_objects_tail; + folderlist_style_t folderlist_style; long status_flags; unsigned long status_messages;
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php