Changeset 2478

Show
Ignore:
Timestamp:
07/19/07 09:18:50
Author:
jdapena
Message:

* libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c:
(imap_refresh_info): now we lock the folder also, before locking the
service, in order to respect better the lock order. This should avoid
some locks.
* libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.[ch]:
now we store a reference to the struct addrinfo used for connections. When
we are successful getting a valid addrinfo, it's stored and reused. This
way we prevent doing lots of calls to getaddrinfo and subsequent name
resolutions. As we're currently blocking while name resolution is running,
this should make the application more reponsive in general and avoid
flooding the connection.
We also removed the method (camel_imap_service_connect) as it's not used.
* libtinymail-camel/camel-lite/camel/camel-private.h:
added parenthesis to some lock macros.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/jdapena/guadec-week/ChangeLog

    r2477 r2478  
     12007-07-19  Jose Dapena Paz  <jdapena@igalia.com> 
     2 
     3        * libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c: 
     4        (imap_refresh_info): now we lock the folder also, before locking the 
     5        service, in order to respect better the lock order. This should avoid 
     6        some locks. 
     7        * libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.[ch]: 
     8        now we store a reference to the struct addrinfo used for connections. When 
     9        we are successful getting a valid addrinfo, it's stored and reused. This 
     10        way we prevent doing lots of calls to getaddrinfo and subsequent name 
     11        resolutions. As we're currently blocking while name resolution is running, 
     12        this should make the application more reponsive in general and avoid 
     13        flooding the connection. 
     14        We also removed the method (camel_imap_service_connect) as it's not used. 
     15        * libtinymail-camel/camel-lite/camel/camel-private.h: 
     16        added parenthesis to some lock macros. 
     17 
    1182007-07-17  Jose Dapena Paz  <jdapena@igalia.com> 
    219 
  • devel/jdapena/guadec-week/libtinymail-camel/camel-lite/camel/camel-private.h

    r1943 r2478  
    7878 
    7979#define CAMEL_SERVICE_LOCK(f, l) \ 
    80         (g_static_mutex_lock(&((CamelService *)f)->priv->l)) 
     80        (g_static_mutex_lock(&((CamelService *)(f))->priv->l)) 
    8181#define CAMEL_SERVICE_UNLOCK(f, l) \ 
    82         (g_static_mutex_unlock(&((CamelService *)f)->priv->l)) 
     82        (g_static_mutex_unlock(&((CamelService *)(f))->priv->l)) 
    8383#define CAMEL_SERVICE_REC_LOCK(f, l) \ 
    84         (g_static_rec_mutex_lock(&((CamelService *)f)->priv->l)) 
     84        (g_static_rec_mutex_lock(&((CamelService *)(f))->priv->l)) 
    8585#define CAMEL_SERVICE_REC_UNLOCK(f, l) \ 
    86         (g_static_rec_mutex_unlock(&((CamelService *)f)->priv->l)) 
     86        (g_static_rec_mutex_unlock(&((CamelService *)(f))->priv->l)) 
    8787#define CAMEL_SERVICE_REC_TRYLOCK(f, l) \ 
    88         (g_static_rec_mutex_trylock(&((CamelService *)f)->priv->l)) 
     88        (g_static_rec_mutex_trylock(&((CamelService *)(f))->priv->l)) 
    8989 
    9090 
  • devel/jdapena/guadec-week/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c

    r2338 r2478  
    814814         * us with a NOOP of new messages, so force a reselect which 
    815815         * should do it.  */ 
     816        CAMEL_FOLDER_REC_LOCK(folder, lock); 
    816817        CAMEL_SERVICE_REC_LOCK (imap_store, connect_lock); 
    817818 
     
    861862done: 
    862863        CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock); 
     864        CAMEL_FOLDER_REC_UNLOCK(folder, lock); 
    863865 
    864866        camel_folder_summary_save(folder->summary); 
  • devel/jdapena/guadec-week/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c

    r2422 r2478  
    350350        camel_service_disconnect((CamelService *)imap_store, TRUE, NULL); 
    351351 
     352        if (imap_store->addrinfo) { 
     353                freeaddrinfo (imap_store->addrinfo); 
     354                imap_store->addrinfo = NULL; 
     355        } 
     356 
    352357        if (imap_store->summary) { 
    353358                camel_store_summary_save((CamelStoreSummary *)imap_store->summary); 
     
    404409        imap_store->connected = FALSE; 
    405410        imap_store->preauthed = FALSE; 
     411 
     412        imap_store->addrinfo = NULL; 
    406413        ((CamelStore *)imap_store)->flags |= CAMEL_STORE_SUBSCRIPTIONS; 
    407414 
     
    11821189        char *serv; 
    11831190        const char *port; 
     1191        CamelImapStore *store = (CamelImapStore *) service; 
    11841192 
    11851193#ifndef G_OS_WIN32 
     
    12361244        hints.ai_family = PF_UNSPEC; 
    12371245 
    1238         ai = camel_getaddrinfo(service->url->host, serv, &hints, ex); 
    1239  
    1240         if (ai == NULL && port != NULL && camel_exception_get_id(ex) != CAMEL_EXCEPTION_USER_CANCEL)  
     1246        if (store->addrinfo == NULL) 
     1247                store->addrinfo = camel_getaddrinfo(service->url->host, serv, &hints, ex); 
     1248 
     1249        if (store->addrinfo == NULL && port != NULL &&  
     1250            camel_exception_get_id(ex) != CAMEL_EXCEPTION_USER_CANCEL)  
    12411251        { 
    12421252                camel_exception_clear (ex); 
    1243                 ai = camel_getaddrinfo(service->url->host, port, &hints, ex); 
    1244         } 
    1245  
    1246         if (ai == NULL) 
     1253                store->addrinfo = camel_getaddrinfo(service->url->host, port, &hints, ex); 
     1254        } 
     1255 
     1256        if (store->addrinfo == NULL) 
    12471257                return FALSE; 
    12481258 
    1249         ret = connect_to_server (service, ai, mode, must_tls, ex); 
    1250         camel_freeaddrinfo (ai); 
     1259        ret = connect_to_server (service, store->addrinfo, mode, must_tls, ex); 
    12511260 
    12521261        return ret; 
    1253 } 
    1254  
    1255 gboolean  
    1256 camel_imap_service_connect (CamelService *service, CamelException *ex) 
    1257 { 
    1258         return connect_to_server_wrapper (service, ex); 
    12591262} 
    12601263 
  • devel/jdapena/guadec-week/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.h

    r2351 r2478  
    166166        guint idle_sleep, getsrv_sleep; 
    167167        gboolean courier_crap; 
     168 
     169        struct addrinfo *addrinfo; 
    168170}; 
    169171 
     
    184186ssize_t camel_imap_store_readline (CamelImapStore *store, char **dest, CamelException *ex); 
    185187ssize_t camel_imap_store_readline_idle (CamelImapStore *store, char **dest, CamelException *ex); 
    186 gboolean camel_imap_service_connect (CamelService *service, CamelException *ex); 
    187188 
    188189gboolean camel_imap_store_restore_stream_buffer (CamelImapStore *store);