Changeset 2499

Show
Ignore:
Timestamp:
07/25/07 23:41:34
Author:
pvanhoof
Message:

Some reference counting problems when factoring folders

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r2497 r2499  
    55        * Disconnecting after summary retrieval of a POP folder 
    66        * Disconnecting after get-msg and sync of a POP folder 
     7        * Some reference counting problems when factoring folders 
    78 
    892007-07-24  Philip Van Hoof  <pvanhoof@gnome.org> 
  • trunk/libtinymail-camel/camel-lite/camel/providers/pop3/camel-pop3-folder.c

    r2497 r2499  
    492492        pop3_store = CAMEL_POP3_STORE (folder->parent_store); 
    493493 
     494        if (!pop3_store->delete_after && !expunge) 
     495                return; 
     496 
    494497        if (camel_disco_store_status (CAMEL_DISCO_STORE (pop3_store)) == CAMEL_DISCO_STORE_OFFLINE) 
    495498                return; 
     
    518521        } 
    519522 
     523        g_static_rec_mutex_unlock (pop3_store->eng_lock); 
     524 
    520525        camel_operation_start(NULL, _("Expunging deleted messages")); 
    521526 
     
    529534                /* busy already?  wait for that to finish first */ 
    530535                if (fi->cmd) { 
     536                        g_static_rec_mutex_lock (pop3_store->eng_lock); 
     537                        if (pop3_store->engine == NULL) { 
     538                                g_static_rec_mutex_unlock (pop3_store->eng_lock); 
     539                                return; 
     540                        } 
     541                        while (camel_pop3_engine_iterate(pop3_store->engine, fi->cmd) > 0) 
     542                                ; 
     543                        camel_pop3_engine_command_free(pop3_store->engine, fi->cmd); 
     544                        g_static_rec_mutex_unlock (pop3_store->eng_lock); 
     545 
     546                        fi->cmd = NULL; 
     547                } 
     548 
     549                /* This file is written by TnyCamelPopLocalMsgRemoveStrategy */ 
     550                expunged_path = g_strdup_printf ("%s/%s.expunged", pop3_store->storage_path, fi->uid); 
     551                if (fi->flags & g_file_test (expunged_path, G_FILE_TEST_EXISTS))  
     552                { 
     553                        g_static_rec_mutex_lock (pop3_store->eng_lock); 
     554                        if (pop3_store->engine == NULL) { 
     555                                g_static_rec_mutex_unlock (pop3_store->eng_lock); 
     556                                return; 
     557                        } 
     558                        fi->cmd = camel_pop3_engine_command_new(pop3_store->engine, 0, NULL, NULL, "DELE %u\r\n", fi->id); 
     559                        g_static_rec_mutex_unlock (pop3_store->eng_lock); 
     560 
     561                        g_unlink (expunged_path); 
     562                        /* also remove from cache */ 
     563                        if (pop3_store->cache && fi->uid) 
     564                                camel_data_cache_remove(pop3_store->cache, "cache", fi->uid, NULL); 
     565                } 
     566 
     567                g_free (expunged_path); 
     568          } 
     569 
     570          for (i = 0; i < pop3_folder->uids->len; i++) { 
     571                fi = pop3_folder->uids->pdata[i]; 
     572                /* wait for delete commands to finish */ 
     573                if (fi->cmd) { 
     574 
     575                        g_static_rec_mutex_lock (pop3_store->eng_lock); 
     576 
     577                        if (pop3_store->engine == NULL) { 
     578                                g_static_rec_mutex_unlock (pop3_store->eng_lock); 
     579                                return; 
     580                        } 
     581 
    531582                        while (camel_pop3_engine_iterate(pop3_store->engine, fi->cmd) > 0) 
    532583                                ; 
    533584                        camel_pop3_engine_command_free(pop3_store->engine, fi->cmd); 
    534585                        fi->cmd = NULL; 
    535                 } 
    536  
    537                 /* This file is written by TnyCamelPopLocalMsgRemoveStrategy */ 
    538                 expunged_path = g_strdup_printf ("%s/%s.expunged", pop3_store->storage_path, fi->uid); 
    539                 if (fi->flags & g_file_test (expunged_path, G_FILE_TEST_EXISTS))  
    540                 { 
    541                         fi->cmd = camel_pop3_engine_command_new(pop3_store->engine, 0, NULL, NULL, "DELE %u\r\n", fi->id); 
    542                         g_unlink (expunged_path); 
    543                         /* also remove from cache */ 
    544                         if (pop3_store->cache && fi->uid) 
    545                                 camel_data_cache_remove(pop3_store->cache, "cache", fi->uid, NULL); 
    546                 } 
    547  
    548                 g_free (expunged_path); 
    549           } 
    550  
    551           for (i = 0; i < pop3_folder->uids->len; i++) { 
    552                 fi = pop3_folder->uids->pdata[i]; 
    553                 /* wait for delete commands to finish */ 
    554                 if (fi->cmd) { 
    555                         while (camel_pop3_engine_iterate(pop3_store->engine, fi->cmd) > 0) 
    556                                 ; 
    557                         camel_pop3_engine_command_free(pop3_store->engine, fi->cmd); 
    558                         fi->cmd = NULL; 
     586 
     587                        g_static_rec_mutex_unlock (pop3_store->eng_lock); 
     588 
    559589                } 
    560590                camel_operation_progress(NULL, (i+1) , pop3_folder->uids->len); 
     
    574604                { 
    575605                        struct _CamelPOP3Command *cmd; 
     606 
     607                        g_static_rec_mutex_lock (pop3_store->eng_lock); 
     608 
     609                        if (pop3_store->engine == NULL) { 
     610                                g_static_rec_mutex_unlock (pop3_store->eng_lock); 
     611                                return; 
     612                        } 
     613 
    576614                        g_unlink (expunged_path); 
    577615                        cmd = camel_pop3_engine_command_new(pop3_store->engine, 0, NULL, NULL, "DELE %u\r\n", info->uid); 
     
    580618                                camel_data_cache_remove(pop3_store->cache, "cache", info->uid, NULL); 
    581619                        camel_pop3_engine_command_free(pop3_store->engine, cmd); 
     620 
     621                        g_static_rec_mutex_unlock (pop3_store->eng_lock); 
     622 
    582623                        camel_message_info_free((CamelMessageInfo *)info); 
    583624                } 
     
    587628 
    588629        camel_operation_end(NULL); 
    589  
    590         g_static_rec_mutex_unlock (pop3_store->eng_lock); 
    591630 
    592631        camel_service_disconnect (CAMEL_SERVICE (pop3_store), TRUE, &dex); 
  • trunk/libtinymail-camel/camel-lite/camel/providers/pop3/camel-pop3-store.c

    r2498 r2499  
    837837 
    838838        g_static_rec_mutex_lock (pop3_store->eng_lock); 
    839          
     839 
    840840        if (pop3_store->engine == NULL) { 
    841841                g_static_rec_mutex_unlock (pop3_store->eng_lock); 
  • trunk/libtinymail-camel/tny-camel-folder.c

    r2489 r2499  
    41394139{ 
    41404140        PokeStatusInfo *info = (PokeStatusInfo *) data; 
     4141 
    41414142        g_object_unref (info->self); 
    41424143        g_slice_free (PokeStatusInfo, info); 
     
    41684169 
    41694170                folder = poke_folders->data; 
     4171 
     4172                if (folder == NULL) 
     4173                        goto mycont; 
    41704174 
    41714175                priv = TNY_CAMEL_FOLDER_GET_PRIVATE (folder); 
     
    41984202                                info, tny_camel_folder_poke_status_destroyer); 
    41994203                } 
    4200  
    42014204                g_object_unref (folder); 
    4202  
     4205                poke_folders->data = NULL; 
     4206 
     4207mycont: 
    42034208                poke_folders = g_list_next (poke_folders); 
    42044209                mypoke_folders = poke_folders; 
  • trunk/libtinymail-camel/tny-camel-imap-store-account.c

    r2194 r2499  
    7272        TnyCamelFolder *folder = NULL; 
    7373 
    74         GList *copy = priv->managed_folders; 
     74        GList *copy = NULL; 
     75 
     76        g_static_rec_mutex_lock (priv->factory_lock); 
     77 
     78        copy = priv->managed_folders; 
    7579        while (copy) 
    7680        { 
    7781                TnyFolder *fnd = (TnyFolder*) copy->data; 
    7882                const gchar *name = tny_folder_get_id (fnd); 
    79                 if (!strcmp (name, full_name)) 
     83 
     84                /* printf ("COMPARE: [%s] [%s]\n", name, full_name); */ 
     85 
     86                if (name && full_name && !strcmp (name, full_name)) 
    8087                { 
    8188                        folder = TNY_CAMEL_FOLDER (g_object_ref (G_OBJECT (fnd))); 
     
    8895        if (!folder) { 
    8996                folder = TNY_CAMEL_FOLDER (_tny_camel_imap_folder_new ()); 
     97                priv->managed_folders = g_list_prepend (priv->managed_folders, folder); 
     98 
     99                /* printf ("CREATE: %s\n", full_name); */ 
     100 
    90101                *was_new = TRUE; 
    91102        } 
     103 
     104        g_static_rec_mutex_unlock (priv->factory_lock); 
    92105 
    93106        return (TnyFolder *) folder; 
  • trunk/libtinymail-camel/tny-camel-pop-store-account-priv.h

    r2244 r2499  
    2525struct _TnyCamelPopStoreAccountPriv 
    2626{ 
     27        TnyFolder *inbox; 
    2728        GMutex *lock; 
    2829}; 
  • trunk/libtinymail-camel/tny-camel-pop-store-account.c

    r2307 r2499  
    9595{ 
    9696        TnyCamelStoreAccountPriv *priv = TNY_CAMEL_STORE_ACCOUNT_GET_PRIVATE (self); 
    97         TnyCamelFolder *folder = NULL; 
    98  
    99         GList *copy = priv->managed_folders; 
    100         while (copy) 
    101         { 
    102                 TnyFolder *fnd = (TnyFolder*) copy->data; 
    103                 const gchar *name = tny_folder_get_id (fnd); 
    104                 if (!strcmp (name, full_name)) 
    105                 { 
    106                         folder = TNY_CAMEL_FOLDER (g_object_ref (G_OBJECT (fnd))); 
    107                         *was_new = FALSE; 
    108                         break; 
    109                 } 
    110                 copy = g_list_next (copy); 
    111         } 
    112  
    113         if (!folder) { 
    114                 folder = TNY_CAMEL_FOLDER (_tny_camel_pop_folder_new ()); 
     97        TnyCamelPopStoreAccountPriv *ppriv = TNY_CAMEL_POP_STORE_ACCOUNT_GET_PRIVATE (self); 
     98 
     99        g_static_rec_mutex_lock (priv->factory_lock); 
     100 
     101        if (!ppriv->inbox)  
     102        { 
    115103                *was_new = TRUE; 
    116         } 
    117  
    118         return (TnyFolder *) folder; 
     104                ppriv->inbox = TNY_FOLDER (_tny_camel_pop_folder_new ()); 
     105                priv->managed_folders = g_list_prepend (priv->managed_folders, ppriv->inbox); 
     106        } 
     107 
     108        g_static_rec_mutex_unlock (priv->factory_lock); 
     109 
     110        return (TnyFolder *) g_object_ref (ppriv->inbox); 
    119111} 
    120112 
     
    138130{ 
    139131        TnyCamelPopStoreAccountPriv *priv = TNY_CAMEL_POP_STORE_ACCOUNT_GET_PRIVATE (object); 
     132 
     133        if (priv->inbox) 
     134                g_object_unref (priv->inbox); 
    140135 
    141136        g_mutex_free (priv->lock); 
     
    232227 
    233228        pop3_store->immediate_delete_after = !enabled; 
    234  
    235          
    236229} 
    237230 
     
    242235        TnyCamelPopStoreAccountPriv *priv = TNY_CAMEL_POP_STORE_ACCOUNT_GET_PRIVATE (instance); 
    243236 
     237        priv->inbox = NULL; 
    244238        priv->lock = g_mutex_new (); 
    245239 
  • trunk/tests/c-demo/tny-demoui-summary-view.c

    r2467 r2499  
    9595        TnyMsgView *msg_view; 
    9696        guint accounts_reloaded_signal; 
    97         GtkWidget *status, *progress, *online_button, *poke_button
     97        GtkWidget *status, *progress, *online_button, *poke_button, *sync_button
    9898        guint status_id; 
    9999        gulong mailbox_select_sid; 
     
    13811381} 
    13821382 
     1383static void 
     1384sync_button_clicked (GtkWidget *button, gpointer user_data) 
     1385{ 
     1386        TnyDemouiSummaryView *self = user_data; 
     1387        TnyDemouiSummaryViewPriv *priv = TNY_DEMOUI_SUMMARY_VIEW_GET_PRIVATE (self); 
     1388        GtkTreeIter iter; 
     1389        GtkTreeModel *model; 
     1390 
     1391        if (gtk_tree_selection_get_selected (priv->mailbox_select, &model, &iter)) 
     1392        { 
     1393                gint type; 
     1394 
     1395                gtk_tree_model_get (model, &iter,  
     1396                        TNY_GTK_FOLDER_STORE_TREE_MODEL_TYPE_COLUMN,  
     1397                        &type, -1); 
     1398 
     1399                if (type != TNY_FOLDER_TYPE_ROOT)  
     1400                {  
     1401                        TnyFolder *folder; 
     1402                        gtk_tree_model_get (model, &iter,  
     1403                                TNY_GTK_FOLDER_STORE_TREE_MODEL_INSTANCE_COLUMN,  
     1404                                &folder, -1); 
     1405 
     1406                        if (TNY_IS_FOLDER (folder)) 
     1407                                tny_folder_sync_async (folder, TRUE, NULL, NULL, NULL); 
     1408 
     1409                        g_object_unref (folder); 
     1410                } 
     1411 
     1412        } 
     1413} 
     1414 
    13831415 
    13841416static void  
     
    16701702        priv->online_button = gtk_toggle_button_new_with_label (GO_ONLINE_TXT); 
    16711703        priv->poke_button = gtk_button_new_with_label ("Poke status"); 
     1704        priv->sync_button = gtk_button_new_with_label ("Sync"); 
    16721705        priv->current_accounts = NULL; 
    16731706 
     
    16771710        g_signal_connect (G_OBJECT (priv->poke_button), "clicked",  
    16781711                G_CALLBACK (poke_button_toggled), self); 
     1712 
     1713        g_signal_connect (G_OBJECT (priv->sync_button), "clicked",  
     1714                G_CALLBACK (sync_button_clicked), self); 
    16791715 
    16801716#if PLATFORM==1 
     
    17051741        gtk_box_pack_start (GTK_BOX (priv->status), priv->online_button, FALSE, FALSE, 0); 
    17061742        gtk_box_pack_start (GTK_BOX (priv->status), priv->poke_button, FALSE, FALSE, 0); 
     1743        gtk_box_pack_start (GTK_BOX (priv->status), priv->sync_button, FALSE, FALSE, 0); 
    17071744 
    17081745        gtk_widget_show (priv->online_button); 
    17091746        gtk_widget_show (priv->poke_button); 
     1747        gtk_widget_show (priv->sync_button); 
    17101748        gtk_widget_show (priv->status); 
    17111749        gtk_widget_show (GTK_WIDGET (vbox));