commit 4032aa94f43f1cdf535b2011c0b5a03f64214351
Author: Oswald Buddenhagen o...@kde.org
Date: Sun Mar 13 14:24:15 2011 +0100
centralize imap_cmd disposal
src/drv_imap.c | 43 +++
1 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/src/drv_imap.c b/src/drv_imap.c
index fb6902a..1dd6f0f 100644
--- a/src/drv_imap.c
+++ b/src/drv_imap.c
@@ -206,6 +206,20 @@ new_imap_cmd( int size )
cmdp-gen.callback = cb; \
cmdp-gen.callback_aux = aux;
+static int
+done_imap_cmd( imap_store_t *ctx, struct imap_cmd *cmd, int response )
+{
+ int cancel;
+
+ cmd-param.done( ctx, cmd, response );
+ free( cmd-param.data );
+ free( cmd-cmd );
+ free( cmd );
+ cancel = ctx-store_canceled;
+ deref_store( ctx );
+ return cancel ? -1 : 0;
+}
+
static struct imap_cmd *
v_submit_imap_cmd( imap_store_t *ctx, struct imap_cmd *cmd,
const char *fmt, va_list ap )
@@ -273,11 +287,7 @@ v_submit_imap_cmd( imap_store_t *ctx, struct imap_cmd *cmd,
bail:
ctx-gen.bad_callback( ctx-gen.bad_callback_aux );
bail2:
- cmd-param.done( ctx, cmd, RESP_CANCEL );
- free( cmd-param.data );
- free( cmd-cmd );
- free( cmd );
- deref_store( ctx );
+ done_imap_cmd( ctx, cmd, RESP_CANCEL );
return NULL;
}
@@ -754,7 +764,7 @@ get_cmd_result( imap_store_t *ctx, struct imap_cmd *tcmd )
{
struct imap_cmd *cmdp, **pcmdp;
char *cmd, *arg, *arg1, *p;
- int resp, resp2, tag, greeted;
+ int cancel, resp, resp2, tag, greeted;
greeted = ctx-greeting;
while (!buffer_gets( ctx-conn, cmd )) {
@@ -801,7 +811,10 @@ get_cmd_result( imap_store_t *ctx, struct imap_cmd *tcmd )
if (greeted == GreetingPending) {
ctx-ref_count++;
imap_open_store_greeted( ctx );
- goto finalize;
+ cancel = ctx-store_canceled;
+ deref_store( ctx );
+ if (cancel)
+ return;
}
} else if (!ctx-in_progress) {
error( IMAP error: unexpected reply: %s %s\n, arg,
cmd ? cmd : );
@@ -880,14 +893,8 @@ get_cmd_result( imap_store_t *ctx, struct imap_cmd *tcmd )
resp = resp2;
if (resp == RESP_CANCEL)
ctx-gen.bad_callback(
ctx-gen.bad_callback_aux );
- cmdp-param.done( ctx, cmdp, resp );
- free( cmdp-param.data );
- free( cmdp-cmd );
- free( cmdp );
- finalize:
- if (ctx-store_canceled)
- tcmd = 0;
- deref_store( ctx );
+ if (done_imap_cmd( ctx, cmdp, resp ) 0)
+ return;
if (!tcmd || tcmd == cmdp)
return;
}
@@ -902,11 +909,7 @@ get_cmd_result_p2( imap_store_t *ctx, struct imap_cmd
*cmd, int response )
struct imap_cmd *ocmd = cmdp-orig_cmd;
if (response != RESP_OK) {
- ocmd-param.done( ctx, ocmd, response );
- free( ocmd-param.data );
- free( ocmd-cmd );
- free( ocmd );
- deref_store( ctx );
+ done_imap_cmd( ctx, ocmd, response );
} else {
ctx-uidnext = 0;
ocmd-param.create = 0;
--
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
___
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel