From: Matthew Barnes Date: Fri, 23 Mar 2012 18:49:44 +0000 (-0400) Subject: CamelIMAPXServer: Rework some reference counting issues. X-Git-Tag: upstream/3.7.4~1072 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7308d9d2cb56365186fa85055a5aa7b85af00435;p=platform%2Fupstream%2Fevolution-data-server.git CamelIMAPXServer: Rework some reference counting issues. Commit 7efd1e7969c70fb497febd455591041994bbf90b was incorrect. The command DOES need to be removed from 'is->queue' before starting it, however we need to hold a reference on the command so it does not get finalized while removing it from 'is->queue'. --- diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c index 1fac44e..4b0ec46 100644 --- a/camel/providers/imapx/camel-imapx-server.c +++ b/camel/providers/imapx/camel-imapx-server.c @@ -638,11 +638,17 @@ imapx_command_start_next (CamelIMAPXServer *is, if (g_queue_is_empty (&start)) c(is->tagprefix, "* no, waiting for pending select '%s'\n", camel_folder_get_full_name (is->select_pending)); - /* Start the tagged commands. */ + /* Start the tagged commands. + * + * Each command must be removed from 'is->queue' before + * starting it, so we temporarily reference the command + * to avoid accidentally finalizing it. */ while ((link = g_queue_pop_head (&start)) != NULL) { - CamelIMAPXCommand *ic = link->data; - imapx_command_start (is, ic, cancellable, error); + CamelIMAPXCommand *ic; + ic = camel_imapx_command_ref (link->data); camel_imapx_command_queue_delete_link (is->queue, link); + imapx_command_start (is, ic, cancellable, error); + camel_imapx_command_unref (ic); } return; @@ -728,11 +734,17 @@ imapx_command_start_next (CamelIMAPXServer *is, break; } - /* Start the tagged commands. */ + /* Start the tagged commands. + * + * Each command must be removed from 'is->queue' before + * starting it, so we temporarily reference the command + * to avoid accidentally finalizing it. */ while ((link = g_queue_pop_head (&start)) != NULL) { - CamelIMAPXCommand *ic = link->data; - imapx_command_start (is, ic, cancellable, error); + CamelIMAPXCommand *ic; + ic = camel_imapx_command_ref (link->data); camel_imapx_command_queue_delete_link (is->queue, link); + imapx_command_start (is, ic, cancellable, error); + camel_imapx_command_unref (ic); commands_started = TRUE; } @@ -779,11 +791,17 @@ imapx_command_start_next (CamelIMAPXServer *is, break; } - /* Start the tagged commands. */ + /* Start the tagged commands. + * + * Each command must be removed from 'is->queue' before + * starting it, so we temporarily reference the command + * to avoid accidentally finalizing it. */ while ((link = g_queue_pop_head (&start)) != NULL) { - CamelIMAPXCommand *ic = link->data; - imapx_command_start (is, ic, cancellable, error); + CamelIMAPXCommand *ic; + ic = camel_imapx_command_ref (link->data); camel_imapx_command_queue_delete_link (is->queue, link); + imapx_command_start (is, ic, cancellable, error); + camel_imapx_command_unref (ic); } } }