[evolution-patches] patch the reduce the network calls (groupwise)
- From: chen <pchenthill novell com>
- To: evolution-patches ximian com
- Subject: [evolution-patches] patch the reduce the network calls (groupwise)
- Date: Thu, 17 Feb 2005 13:31:25 +0530
Hi ,
Have attached a patch to reduce the get_category and
get_addressbook_list calls to the server.
thanks, chenthill.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/ChangeLog,v
retrieving revision 1.123
diff -u -p -r1.123 ChangeLog
--- ChangeLog 16 Feb 2005 13:07:46 -0000 1.123
+++ ChangeLog 17 Feb 2005 07:28:55 -0000
@@ -1,3 +1,16 @@
+2005-02-17 Chenthill Palanisamy <pchenthill novell com>
+
+ * e-gw-connection.c:
+ (e_gw_connection_dispose),(e_gw_connection_init): Create
+ and destroy the new hash tables for storing categories.
+ (e_gw_connection_get_settings), (e_gw_connection_get_categories),
+ (e_gw_connection_get_address_book_list): Added mutex locks and stored the
+ category/container list information in cnc private to reduce
+ the network calls.
+ (e_gw_connection_get_address_book_id): Use the new syntax for the
+ get_container_list and don free the list.
+ * e-gw-connection.h: Changed the declaration
+
2005-02-16 Vivek Jain <jvivek novell com>
* e_gw_item.c : (set_recipient_list_from_soap_parameter)
Index: e-gw-connection.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/e-gw-connection.c,v
retrieving revision 1.108
diff -u -p -r1.108 e-gw-connection.c
--- e-gw-connection.c 9 Feb 2005 04:13:33 -0000 1.108
+++ e-gw-connection.c 17 Feb 2005 07:28:55 -0000
@@ -49,6 +49,9 @@ struct _EGwConnectionPrivate {
char *user_uuid;
char *version;
char *server_time ;
+ GHashTable *categories_by_name;
+ GHashTable *categories_by_id;
+ GList *book_list;
EGwSendOptions *opts;
GMutex *reauth_mutex;
};
@@ -275,7 +278,23 @@ e_gw_connection_dispose (GObject *object
g_mutex_free (priv->reauth_mutex);
priv->reauth_mutex = NULL;
}
-
+
+ if (priv->categories_by_id) {
+ g_hash_table_destroy (priv->categories_by_id);
+ priv->categories_by_id = NULL;
+ }
+
+ if (priv->categories_by_name) {
+ g_hash_table_destroy (priv->categories_by_name);
+ priv->categories_by_name = NULL;
+ }
+
+ if (priv->book_list) {
+ g_list_foreach (priv->book_list, (GFunc) g_object_unref, NULL);
+ g_list_free (priv->book_list);
+ priv->book_list = NULL;
+ }
+
if (priv->opts) {
g_object_unref (priv->opts);
priv->opts = NULL;
@@ -337,6 +356,8 @@ e_gw_connection_init (EGwConnection *cnc
/* create the SoupSession for this connection */
priv->soup_session = soup_session_sync_new ();
priv->reauth_mutex = g_mutex_new ();
+ priv->categories_by_id = NULL;
+ priv->categories_by_name = NULL;
priv->opts = NULL;
}
@@ -1489,16 +1510,28 @@ e_gw_connection_get_address_book_list (E
SoupSoapMessage *msg;
SoupSoapResponse *response;
EGwConnectionStatus status;
+ EGwConnectionPrivate *priv;
SoupSoapParameter *param;
SoupSoapParameter *type_param;
char *value;
-
+ static GStaticMutex connecting = G_STATIC_MUTEX_INIT;
+
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_UNKNOWN);
g_return_val_if_fail (container_list != NULL, E_GW_CONNECTION_STATUS_UNKNOWN);
+ priv = cnc->priv;
+ g_static_mutex_lock (&connecting);
+
+ if (priv->book_list) {
+ *container_list = priv->book_list;
+ g_static_mutex_unlock (&connecting);
+ return E_GW_CONNECTION_STATUS_OK;
+ }
+
msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "getAddressBookListRequest");
if (!msg) {
g_warning (G_STRLOC ": Could not build SOAP message");
+ g_static_mutex_unlock (&connecting);
return E_GW_CONNECTION_STATUS_UNKNOWN;
}
@@ -1508,6 +1541,7 @@ e_gw_connection_get_address_book_list (E
response = e_gw_connection_send_message (cnc, msg);
if (!response) {
g_object_unref (msg);
+ g_static_mutex_unlock (&connecting);
return E_GW_CONNECTION_STATUS_NO_RESPONSE;
}
@@ -1518,6 +1552,7 @@ e_gw_connection_get_address_book_list (E
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
reauthenticate (cnc);
g_object_unref (response);
+ g_static_mutex_unlock (&connecting);
return status;
}
@@ -1525,6 +1560,7 @@ e_gw_connection_get_address_book_list (E
param = soup_soap_response_get_first_parameter_by_name (response, "books");
if (!param) {
g_object_unref (response);
+ g_static_mutex_unlock (&connecting);
return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
} else {
SoupSoapParameter *subparam;
@@ -1535,7 +1571,7 @@ e_gw_connection_get_address_book_list (E
container = e_gw_container_new_from_soap_parameter (subparam);
if (container) {
- *container_list = g_list_append (*container_list, container);
+ priv->book_list = g_list_append (priv->book_list, container);
type_param = soup_soap_parameter_get_first_child_by_name (subparam, "isPersonal");
value = NULL;
if (type_param)
@@ -1560,6 +1596,8 @@ e_gw_connection_get_address_book_list (E
}
g_object_unref (response);
+ *container_list = priv->book_list;
+ g_static_mutex_unlock (&connecting);
return status;
}
@@ -1576,7 +1614,6 @@ e_gw_connection_get_address_book_id ( EG
status = e_gw_connection_get_address_book_list (cnc, &container_list);
if (status != E_GW_CONNECTION_STATUS_OK) {
- e_gw_connection_free_container_list (container_list);
return status;
}
@@ -1591,8 +1628,6 @@ e_gw_connection_get_address_book_id ( EG
}
}
- e_gw_connection_free_container_list (container_list);
-
return status;
}
@@ -1658,14 +1693,19 @@ e_gw_connection_get_settings (EGwConnect
EGwConnectionStatus status;
SoupSoapParameter *param;
EGwConnectionPrivate *priv;
+ static GStaticMutex connecting = G_STATIC_MUTEX_INIT;
+
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_OBJECT);
priv = cnc->priv;
+ g_static_mutex_lock (&connecting);
+
if (priv->opts) {
g_object_ref (priv->opts);
*opts = priv->opts;
+ g_static_mutex_unlock (&connecting);
return E_GW_CONNECTION_STATUS_OK;
}
@@ -1673,6 +1713,7 @@ e_gw_connection_get_settings (EGwConnect
msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "getSettingsRequest");
if (!msg) {
g_warning (G_STRLOC ": Could not build SOAP message");
+ g_static_mutex_unlock (&connecting);
return E_GW_CONNECTION_STATUS_UNKNOWN;
}
e_gw_message_write_footer (msg);
@@ -1681,6 +1722,7 @@ e_gw_connection_get_settings (EGwConnect
response = e_gw_connection_send_message (cnc, msg);
if (!response) {
g_object_unref (msg);
+ g_static_mutex_unlock (&connecting);
return E_GW_CONNECTION_STATUS_NO_RESPONSE;
}
@@ -1690,6 +1732,7 @@ e_gw_connection_get_settings (EGwConnect
reauthenticate (cnc);
g_object_unref (response);
g_object_unref (msg);
+ g_static_mutex_unlock (&connecting);
return status;
}
@@ -1697,6 +1740,7 @@ e_gw_connection_get_settings (EGwConnect
if (!param) {
g_object_unref (response);
g_object_unref (msg);
+ g_static_mutex_unlock (&connecting);
return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
} else
priv->opts = e_gw_sendoptions_new_from_soap_parameter (param);
@@ -1705,24 +1749,38 @@ e_gw_connection_get_settings (EGwConnect
*opts = priv->opts;
g_object_unref (response);
g_object_unref (msg);
+ g_static_mutex_unlock (&connecting);
return E_GW_CONNECTION_STATUS_OK;
}
EGwConnectionStatus
-e_gw_connection_get_categories (EGwConnection *cnc, GHashTable *categories_by_id, GHashTable *categories_by_name)
+e_gw_connection_get_categories (EGwConnection *cnc, GHashTable **categories_by_id, GHashTable **categories_by_name)
{
SoupSoapMessage *msg;
SoupSoapResponse *response;
EGwConnectionStatus status;
+ EGwConnectionPrivate *priv;
SoupSoapParameter *param, *subparam, *second_level_child;
char *id, *name;
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_OBJECT);
-
+ static GStaticMutex connecting = G_STATIC_MUTEX_INIT;
+
+ priv = cnc->priv;
+ g_static_mutex_lock (&connecting);
+
+ if (priv->categories_by_id && priv->categories_by_name) {
+ *categories_by_id = priv->categories_by_id;
+ *categories_by_name = priv->categories_by_name;
+ g_static_mutex_unlock (&connecting);
+ return E_GW_CONNECTION_STATUS_OK;
+ }
+
/* build the SOAP message */
msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "getCategoryListRequest");
if (!msg) {
g_warning (G_STRLOC ": Could not build SOAP message");
+ g_static_mutex_unlock (&connecting);
return E_GW_CONNECTION_STATUS_UNKNOWN;
}
e_gw_message_write_footer (msg);
@@ -1731,6 +1789,7 @@ e_gw_connection_get_categories (EGwConne
response = e_gw_connection_send_message (cnc, msg);
if (!response) {
g_object_unref (msg);
+ g_static_mutex_unlock (&connecting);
return E_GW_CONNECTION_STATUS_NO_RESPONSE;
}
@@ -1740,6 +1799,7 @@ e_gw_connection_get_categories (EGwConne
reauthenticate (cnc);
g_object_unref (response);
g_object_unref (msg);
+ g_static_mutex_unlock (&connecting);
return status;
}
@@ -1748,9 +1808,13 @@ e_gw_connection_get_categories (EGwConne
if (!param) {
g_object_unref (response);
g_object_unref (msg);
+ g_static_mutex_unlock (&connecting);
return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
}
+ priv->categories_by_id = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+ priv->categories_by_name = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
for (subparam = soup_soap_parameter_get_first_child_by_name (param, "category");
subparam != NULL;
subparam = soup_soap_parameter_get_next_child_by_name (subparam, "category")) {
@@ -1766,9 +1830,9 @@ e_gw_connection_get_categories (EGwConne
g_free (id);
id = components[0];
if (categories_by_id)
- g_hash_table_insert (categories_by_id, g_strdup (id), g_strdup (name));
+ g_hash_table_insert (priv->categories_by_id, g_strdup (id), g_strdup (name));
if (categories_by_name)
- g_hash_table_insert (categories_by_name, g_strdup (name), g_strdup (id));
+ g_hash_table_insert (priv->categories_by_name, g_strdup (name), g_strdup (id));
g_strfreev (components);
g_free (name);
}
@@ -1778,10 +1842,11 @@ e_gw_connection_get_categories (EGwConne
/* free memory */
g_object_unref (response);
g_object_unref (msg);
+ *categories_by_id = priv->categories_by_id;
+ *categories_by_name = priv->categories_by_name;
+ g_static_mutex_unlock (&connecting);
return E_GW_CONNECTION_STATUS_OK;
-
-
}
EGwConnectionStatus
Index: e-gw-connection.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/e-gw-connection.h,v
retrieving revision 1.54
diff -u -p -r1.54 e-gw-connection.h
--- e-gw-connection.h 8 Feb 2005 09:19:13 -0000 1.54
+++ e-gw-connection.h 17 Feb 2005 07:28:55 -0000
@@ -109,7 +109,7 @@ EGwConnectionStatus e_gw_connection_crea
EGwConnectionStatus e_gw_connection_remove_book (EGwConnection *cnc, char *book_uid);
EGwConnectionStatus e_gw_connection_get_address_book_list (EGwConnection *cnc, GList **container_list);
EGwConnectionStatus e_gw_connection_get_address_book_id ( EGwConnection *cnc, char *book_name, char**id , gboolean *is_writable);
-EGwConnectionStatus e_gw_connection_get_categories (EGwConnection *cnc, GHashTable *categories_by_id, GHashTable *categoreis_by_name);
+EGwConnectionStatus e_gw_connection_get_categories (EGwConnection *cnc, GHashTable **categories_by_id, GHashTable **categoreis_by_name);
EGwConnectionStatus e_gw_connection_add_members (EGwConnection *cnc, const char *group_id, GList *member_ids);
EGwConnectionStatus e_gw_connection_remove_members (EGwConnection *cnc, const char *group_id, GList *member_ids);
EGwConnectionStatus e_gw_connection_get_items_from_ids (EGwConnection *cnc, const char *container, const char *view, GPtrArray *item_ids, GList **list);
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.421
diff -u -p -r1.421 ChangeLog
--- ChangeLog 16 Feb 2005 12:56:54 -0000 1.421
+++ ChangeLog 17 Feb 2005 07:54:11 -0000
@@ -1,3 +1,13 @@
+2005-02-17 Chenthill Palanisamy <pchenthill novell com>
+
+ * backends/groupwise/e-cal-backend-groupwise.c:
+ (populate_cache),(cache_init): Moved the get categories
+ call from populate_cache to cache_init since it has to be
+ called everytime.
+ (e_cal_backend_groupwise_finalize),
+ (e_cal_backend_groupwise_init): Hash table for categories
+ need not be created/destroyed, connection will handle it.
+
2005-02-11 Rodrigo Moya <rodrigo gnome-db org>
Fixes #71545
Index: backends/groupwise/e-cal-backend-groupwise.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/backends/groupwise/e-cal-backend-groupwise.c,v
retrieving revision 1.127
diff -u -p -r1.127 e-cal-backend-groupwise.c
--- backends/groupwise/e-cal-backend-groupwise.c 11 Feb 2005 05:26:41 -0000 1.127
+++ backends/groupwise/e-cal-backend-groupwise.c 17 Feb 2005 07:54:12 -0000
@@ -131,13 +131,7 @@ populate_cache (ECalBackendGroupwise *cb
g_mutex_lock (mutex);
- /* get the list of category ids and corresponding names from the server */
- status = e_gw_connection_get_categories (priv->cnc, priv->categories_by_id, priv->categories_by_name);
- if (status != E_GW_CONNECTION_STATUS_OK) {
- e_cal_backend_groupwise_notify_error_code (cbgw, status);
- g_mutex_unlock (mutex);
- return status;
- }
+
status = e_gw_connection_create_cursor (priv->cnc,
priv->container_id,
"recipients message recipientStatus attachments default", NULL, &cursor);
@@ -435,8 +429,15 @@ cache_init (ECalBackendGroupwise *cbgw)
if (cnc_status == E_GW_CONNECTION_STATUS_OK) {
e_cal_backend_groupwise_store_settings (opts, cbgw);
g_object_unref (opts);
- }
+ } else
+ g_warning (G_STRLOC ": Could not get the settings from the server");
+ /* get the list of category ids and corresponding names from the server */
+ cnc_status = e_gw_connection_get_categories (priv->cnc, &priv->categories_by_id, &priv->categories_by_name);
+ if (cnc_status != E_GW_CONNECTION_STATUS_OK) {
+ g_warning (G_STRLOC ": Could not get the categories from the server");
+ }
+
/* We poke the cache for a default timezone. Its
* absence indicates that the cache file has not been
* populated before. */
@@ -648,16 +649,6 @@ e_cal_backend_groupwise_finalize (GObjec
priv->password = NULL;
}
- if (priv->categories_by_id) {
- g_hash_table_destroy (priv->categories_by_id);
- priv->categories_by_id = NULL;
- }
-
- if (priv->categories_by_name) {
- g_hash_table_destroy (priv->categories_by_name);
- priv->categories_by_name = NULL;
- }
-
if (priv->container_id) {
g_free (priv->container_id);
priv->container_id = NULL;
@@ -1968,8 +1959,6 @@ e_cal_backend_groupwise_init (ECalBacken
priv = g_new0 (ECalBackendGroupwisePrivate, 1);
- priv->categories_by_id = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- priv->categories_by_name = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
priv->timeout_id = 0;
priv->cnc = NULL;
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/ChangeLog,v
retrieving revision 1.249
diff -u -p -r1.249 ChangeLog
--- ChangeLog 14 Feb 2005 19:24:41 -0000 1.249
+++ ChangeLog 17 Feb 2005 07:29:51 -0000
@@ -1,3 +1,12 @@
+2005-02-17 Chenthill Palanisamy <pchenthill novell com>
+
+ * backends/groupwise/e-book-backend-groupwise.c:
+ (e_book_backend_groupwise_authenticate_user): changed
+ the syntax of the get_categories call.
+ (e_book_backend_groupwise_dispose),
+ (e_book_backend_groupwise_init): The hash table need not
+ be created or destroyed here, since connection handles it.
+
2005-02-14 Sivaiah Nallagatla <snallagatla novell com>
* libebook/e-vcard.c (read_attribute_value) :
Index: backends/groupwise/e-book-backend-groupwise.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/backends/groupwise/e-book-backend-groupwise.c,v
retrieving revision 1.46
diff -u -p -r1.46 e-book-backend-groupwise.c
--- backends/groupwise/e-book-backend-groupwise.c 4 Feb 2005 06:30:34 -0000 1.46
+++ backends/groupwise/e-book-backend-groupwise.c 17 Feb 2005 07:29:52 -0000
@@ -2316,7 +2316,7 @@ e_book_backend_groupwise_authenticate_us
e_book_backend_notify_writable (backend, is_writable);
e_book_backend_notify_connection_status (backend, TRUE);
priv->is_writable = is_writable;
- e_gw_connection_get_categories (priv->cnc, priv->categories_by_id, priv->categories_by_name);
+ e_gw_connection_get_categories (priv->cnc, &priv->categories_by_id, &priv->categories_by_name);
if (!e_gw_connection_get_version(priv->cnc))
e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_InvalidServerVersion);
else
@@ -2595,15 +2595,6 @@ e_book_backend_groupwise_dispose (GObjec
g_free (bgw->priv->book_name);
bgw->priv->book_name = NULL;
}
- if (bgw->priv->categories_by_id) {
- g_hash_table_destroy (bgw->priv->categories_by_id);
- bgw->priv->categories_by_id = NULL;
- }
- if (bgw->priv->categories_by_name) {
- g_hash_table_destroy (bgw->priv->categories_by_name);
- bgw->priv->categories_by_name = NULL;
- }
-
if (bgw->priv->cache) {
g_object_unref (bgw->priv->cache);
}
@@ -2658,8 +2649,6 @@ e_book_backend_groupwise_init (EBookBack
EBookBackendGroupwisePrivate *priv;
priv= g_new0 (EBookBackendGroupwisePrivate, 1);
- priv->categories_by_id = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- priv->categories_by_name = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
priv->is_writable = TRUE;
priv->is_cache_ready = FALSE;
priv->marked_for_offline = FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]