[libgda] Reworked connection status changes handling
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Reworked connection status changes handling
- Date: Mon, 15 Dec 2014 21:26:46 +0000 (UTC)
commit 31b31eabc48434b73fcf5430e35c4096c2775c94
Author: Vivien Malerba <malerba gnome-db org>
Date: Sun Dec 14 14:59:20 2014 +0100
Reworked connection status changes handling
libgda/gda-connection-internal.h | 6 +-
libgda/gda-connection.c | 122 ++++++++++++++++++------------
libgda/gda-meta-store.c | 13 +++-
libgda/gda-server-provider.c | 112 +++++++++++++++------------
libgda/libgda.symbols | 3 +-
providers/ldap/gda-ldap-provider.c | 2 +-
providers/ldap/gda-ldap-util.c | 18 ++--
providers/ldap/gdaprov-data-model-ldap.c | 26 +++---
tools/common/t-config-info.c | 11 +++-
9 files changed, 186 insertions(+), 127 deletions(-)
---
diff --git a/libgda/gda-connection-internal.h b/libgda/gda-connection-internal.h
index dc58f2c..0914cbb 100644
--- a/libgda/gda-connection-internal.h
+++ b/libgda/gda-connection-internal.h
@@ -46,9 +46,9 @@ G_BEGIN_DECLS
GdaWorker *_gda_connection_get_worker (GdaConnection *cnc);
guint _gda_connection_get_exec_slowdown (GdaConnection *cnc);
-void _gda_connection_status_start_batch (GdaConnection *cnc, GdaConnectionStatus status);
-void _gda_connection_status_stop_batch (GdaConnection *cnc);
-void gda_connection_set_status (GdaConnection *cnc, GdaConnectionStatus status);
+void _gda_connection_set_status (GdaConnection *cnc, GdaConnectionStatus status);
+void gda_connection_increase_usage (GdaConnection *cnc);
+void gda_connection_decrease_usage (GdaConnection *cnc);
/*
* Opens a connection to an SQLite database. This function is intended to be used
diff --git a/libgda/gda-connection.c b/libgda/gda-connection.c
index 3f0b14a..8b102fb 100644
--- a/libgda/gda-connection.c
+++ b/libgda/gda-connection.c
@@ -102,7 +102,7 @@ struct _GdaConnectionPrivate {
GList *events_list; /* for API compat */
GdaConnectionStatus status;
- guint batch_status;
+ guint busy_count;
GdaTransactionStatus *trans_status;
GHashTable *prepared_stmts;
@@ -445,7 +445,7 @@ gda_connection_init (GdaConnection *cnc, G_GNUC_UNUSED GdaConnectionClass *klass
cnc->priv->events_array_full = FALSE;
cnc->priv->events_array_next = 0;
cnc->priv->status = GDA_CONNECTION_STATUS_CLOSED;
- cnc->priv->batch_status = 0;
+ cnc->priv->busy_count = 0;
cnc->priv->trans_status = NULL; /* no transaction yet */
cnc->priv->prepared_stmts = NULL;
@@ -1578,78 +1578,106 @@ assert_status_transaction (GdaConnectionStatus old, GdaConnectionStatus new)
}
}
-/**
- * gda_connection_set_status: (skip)
+/*
+ * _gda_connection_declare_closed:
* @cnc: a #GdaConnection
- *
- * Set @cnc's new status, may emit the "status-changed" signal along the way. This function is reserved to
database
- * provider's implementation
- *
- * WARNING: @cnc _MUST_ be locked before this function is called
*/
void
-gda_connection_set_status (GdaConnection *cnc, GdaConnectionStatus status)
+_gda_connection_declare_closed (GdaConnection *cnc)
{
- if (!cnc || (status == cnc->priv->status))
+ if (!cnc)
return;
- if ((cnc->priv->batch_status > 0) &&
- (status != GDA_CONNECTION_STATUS_CLOSED))
- return;
+ g_return_if_fail (cnc->priv->status == GDA_CONNECTION_STATUS_IDLE);
+
+ assert_status_transaction (cnc->priv->status, GDA_CONNECTION_STATUS_CLOSED);
+ g_signal_emit (G_OBJECT (cnc), gda_connection_signals[STATUS_CHANGED], 0,
GDA_CONNECTION_STATUS_CLOSED);
+}
+/*
+ * _gda_connection_set_status:
+ * This function can't be used to switch to GDA_CONNECTION_STATUS_BUSY, one must switch to
+ * GDA_CONNECTION_STATUS_IDLE and use gda_connection_increase/decrease_usage() functions.
+ *
+ * WARNING: @cnc _MUST_ be locked using gda_connection_lock() before this function is called
+ */
+void
+_gda_connection_set_status (GdaConnection *cnc, GdaConnectionStatus status)
+{
+ if (!cnc || (cnc->priv->status == status))
+ return;
+ if ((status == GDA_CONNECTION_STATUS_CLOSED) ||
+ (status == GDA_CONNECTION_STATUS_OPENING))
+ g_return_if_fail (cnc->priv->busy_count == 0);
+ g_return_if_fail (status != GDA_CONNECTION_STATUS_BUSY);
assert_status_transaction (cnc->priv->status, status);
- cnc->priv->batch_status = 0;
cnc->priv->status = status;
g_signal_emit (G_OBJECT (cnc), gda_connection_signals[STATUS_CHANGED], 0, status);
- if (status == GDA_CONNECTION_STATUS_CLOSED)
- g_signal_emit (G_OBJECT (cnc), gda_connection_signals[CLOSED], 0, status);
+ /*g_print ("CNC %p status is %d\n", cnc, cnc->priv->status);*/
}
-/*
- * _gda_connection_status_start_batch:
+/**
+ * gda_connection_increase_usage:
+ * @cnc: a #GdaConnection
*
- * This function ensures that the connection's status is set and remains to @status, except for the CLOSED
- * status.
+ * Declare that @cnc is being used, which may emit the "status-changed" signal along the way. Any call to
this function
+ * must be followed by one single call to gda_connection_decrease_usage(). The connection's status must
either be
+ * IDLE, BUSY, or OPENING when this function is called. If the status is IDLE, then it will be switched to
BUSY.
*
- * To cancel the effect, use _gda_connection_status_stop_batch().
+ * Note: This function is reserved to database provider's implementation
*
- * WARNING: @cnc _MUST_ be locked before this function is called
+ * WARNING: @cnc _MUST_ be locked using gda_lockable_lock() before this function is called
*/
void
-_gda_connection_status_start_batch (GdaConnection *cnc, GdaConnectionStatus status)
+gda_connection_increase_usage (GdaConnection *cnc)
{
- cnc->priv->batch_status++;
- if (cnc->priv->status != status) {
- assert_status_transaction (cnc->priv->status, status);
- cnc->priv->status = status;
- g_signal_emit (G_OBJECT (cnc), gda_connection_signals[STATUS_CHANGED], 0, status);
+ if (!cnc)
+ return;
+
+ g_return_if_fail ((cnc->priv->status == GDA_CONNECTION_STATUS_IDLE) ||
+ (cnc->priv->status == GDA_CONNECTION_STATUS_BUSY) ||
+ (cnc->priv->status == GDA_CONNECTION_STATUS_OPENING));
+
+ cnc->priv->busy_count ++;
+ if (cnc->priv->status == GDA_CONNECTION_STATUS_IDLE) {
+ assert_status_transaction (cnc->priv->status, GDA_CONNECTION_STATUS_BUSY);
+ cnc->priv->status = GDA_CONNECTION_STATUS_BUSY;
+ g_signal_emit (G_OBJECT (cnc), gda_connection_signals[STATUS_CHANGED], 0,
GDA_CONNECTION_STATUS_BUSY);
+ /*g_print ("CNC %p status is %d\n", cnc, cnc->priv->status);*/
}
}
-/*
- * _gda_connection_status_stop_batch:
+/**
+ * gda_connection_decrease_usage:
+ * @cnc: a #GdaConnection
*
- * See _gda_connection_status_start_batch().
+ * Declare that @cnc is not being used, which may emit the "status-changed" signal along the way. Any call
to this function
+ * must be following a single call to gda_connection_increase_usage(). The connection's status must either be
+ * BUSY or OPENING when this function is called. If it's BUSY, then it may be changed to IDLE after this
call.
*
- * This functions ensures that the connections's status is IDLE.
+ * Note: This function is reserved to database provider's implementation
*
- * WARNING: @cnc _MUST_ be locked before this function is called
+ * WARNING: @cnc _MUST_ be locked using gda_lockable_lock() before this function is called
*/
void
-_gda_connection_status_stop_batch (GdaConnection *cnc)
+gda_connection_decrease_usage (GdaConnection *cnc)
{
- if (cnc->priv->batch_status == 0)
+ if (!cnc)
return;
- cnc->priv->batch_status --;
- if (cnc->priv->status != GDA_CONNECTION_STATUS_IDLE) {
+ g_assert (cnc->priv->busy_count > 0);
+ g_return_if_fail ((cnc->priv->status == GDA_CONNECTION_STATUS_BUSY) ||
+ (cnc->priv->status == GDA_CONNECTION_STATUS_OPENING));
+
+ cnc->priv->busy_count --;
+ if ((cnc->priv->busy_count == 0) && (cnc->priv->status == GDA_CONNECTION_STATUS_BUSY)) {
assert_status_transaction (cnc->priv->status, GDA_CONNECTION_STATUS_IDLE);
cnc->priv->status = GDA_CONNECTION_STATUS_IDLE;
g_signal_emit (G_OBJECT (cnc), gda_connection_signals[STATUS_CHANGED], 0,
GDA_CONNECTION_STATUS_IDLE);
+ /*g_print ("CNC %p status is %d\n", cnc, cnc->priv->status);*/
}
}
-
/**
* gda_connection_get_status:
* @cnc: a #GdaConnection
@@ -4733,7 +4761,7 @@ gda_connection_update_meta_store (GdaConnection *cnc, GdaMetaContext *context, G
cnc->priv->exec_slowdown = 0;
}
- _gda_connection_status_start_batch (cnc, GDA_CONNECTION_STATUS_BUSY);
+ gda_connection_increase_usage (cnc); /* USAGE ++ */
if (context) {
GdaMetaContext *lcontext;
@@ -4744,7 +4772,7 @@ gda_connection_update_meta_store (GdaConnection *cnc, GdaMetaContext *context, G
lcontext = _gda_meta_store_validate_context (store, context, error);
if (!lcontext) {
- _gda_connection_status_stop_batch (cnc);
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_connection_unlock ((GdaLockable*) cnc);
cnc->priv->exec_slowdown = real_slowdown;
return FALSE;
@@ -4759,7 +4787,7 @@ gda_connection_update_meta_store (GdaConnection *cnc, GdaMetaContext *context, G
up_templates = build_upstream_context_templates (store, lcontext, NULL, &lerror);
if (!up_templates) {
if (lerror) {
- _gda_connection_status_stop_batch (cnc);
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_connection_unlock ((GdaLockable*) cnc);
g_propagate_error (error, lerror);
cnc->priv->exec_slowdown = real_slowdown;
@@ -4769,7 +4797,7 @@ gda_connection_update_meta_store (GdaConnection *cnc, GdaMetaContext *context, G
dn_templates = build_downstream_context_templates (store, lcontext, NULL, &lerror);
if (!dn_templates) {
if (lerror) {
- _gda_connection_status_stop_batch (cnc);
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_connection_unlock ((GdaLockable*) cnc);
g_propagate_error (error, lerror);
cnc->priv->exec_slowdown = real_slowdown;
@@ -4830,7 +4858,7 @@ gda_connection_update_meta_store (GdaConnection *cnc, GdaMetaContext *context, G
g_slist_free (cbd.context_templates);
g_hash_table_destroy (cbd.context_templates_hash);
- _gda_connection_status_stop_batch (cnc);
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_connection_unlock ((GdaLockable*) cnc);
cnc->priv->exec_slowdown = real_slowdown;
return retval;
@@ -4874,7 +4902,7 @@ gda_connection_update_meta_store (GdaConnection *cnc, GdaMetaContext *context, G
gboolean retval;
if (! _gda_meta_store_begin_data_reset (store, error)) {
- _gda_connection_status_stop_batch (cnc);
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_connection_unlock ((GdaLockable*) cnc);
cnc->priv->exec_slowdown = real_slowdown;
return FALSE;
@@ -4902,13 +4930,13 @@ gda_connection_update_meta_store (GdaConnection *cnc, GdaMetaContext *context, G
}
}
retval = _gda_meta_store_finish_data_reset (store, error);
- _gda_connection_status_stop_batch (cnc);
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_connection_unlock ((GdaLockable*) cnc);
cnc->priv->exec_slowdown = real_slowdown;
return retval;
onerror:
- _gda_connection_status_stop_batch (cnc);
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_connection_unlock ((GdaLockable*) cnc);
_gda_meta_store_cancel_data_reset (store, NULL);
cnc->priv->exec_slowdown = real_slowdown;
diff --git a/libgda/gda-meta-store.c b/libgda/gda-meta-store.c
index a3aefbd..f85c346 100644
--- a/libgda/gda-meta-store.c
+++ b/libgda/gda-meta-store.c
@@ -799,8 +799,13 @@ gda_meta_store_constructor (GType type,
/* in memory DB */
g_object_set (object, "cnc-string", "SQLite://DB_DIR=.;DB_NAME=__gda_tmp", NULL);
- if (store->priv->cnc)
+ if (store->priv->cnc) {
+ gda_lockable_lock (GDA_LOCKABLE (store->priv->cnc));
+ gda_connection_increase_usage (store->priv->cnc); /* USAGE ++ */
store->priv->schema_ok = initialize_cnc_struct (store, &(store->priv->init_error));
+ gda_connection_decrease_usage (store->priv->cnc); /* USAGE -- */
+ gda_lockable_unlock (GDA_LOCKABLE (store->priv->cnc));
+ }
/* create a local copy of all the DbObject structures defined in klass->cpriv */
if (store->priv->catalog && !store->priv->schema) {
@@ -4156,6 +4161,8 @@ gda_meta_store_set_attribute_value (GdaMetaStore *store, const gchar *att_name,
}
/* start a transaction if possible */
+ gda_lockable_lock (GDA_LOCKABLE (store->priv->cnc));
+ gda_connection_increase_usage (store->priv->cnc); /* USAGE ++ */
if (! gda_connection_get_transaction_status (store->priv->cnc))
started_transaction = gda_connection_begin_transaction (store->priv->cnc, NULL,
GDA_TRANSACTION_ISOLATION_UNKNOWN,
@@ -4182,12 +4189,16 @@ gda_meta_store_set_attribute_value (GdaMetaStore *store, const gchar *att_name,
}
if (started_transaction)
gda_connection_commit_transaction (store->priv->cnc, NULL, NULL);
+ gda_connection_decrease_usage (store->priv->cnc); /* USAGE -- */
+ gda_lockable_unlock (GDA_LOCKABLE (store->priv->cnc));
g_rec_mutex_unlock (& (store->priv->mutex));
return TRUE;
onerror:
if (started_transaction)
gda_connection_rollback_transaction (store->priv->cnc, NULL, NULL);
+ gda_connection_decrease_usage (store->priv->cnc); /* USAGE -- */
+ gda_lockable_unlock (GDA_LOCKABLE (store->priv->cnc));
g_rec_mutex_unlock (& (store->priv->mutex));
return FALSE;
}
diff --git a/libgda/gda-server-provider.c b/libgda/gda-server-provider.c
index 5c769f4..bf7c08d 100644
--- a/libgda/gda-server-provider.c
+++ b/libgda/gda-server-provider.c
@@ -2107,11 +2107,11 @@ stage2_open_connection (GdaWorker *worker, GdaConnection *cnc, gpointer result)
if (!cdata) {
g_warning ("Internal error: connection reported as opened, yet no provider data set");
result = NULL;
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_CLOSED);
+ _gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_CLOSED);
}
else {
+ _gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_IDLE);
g_signal_emit_by_name (G_OBJECT (cnc), "opened");
- _gda_connection_status_stop_batch (cnc);
}
}
@@ -2168,7 +2168,7 @@ _gda_server_provider_open_connection (GdaServerProvider *provider, GdaConnection
}
gda_lockable_lock ((GdaLockable*) cnc); /* CNC LOCK */
- _gda_connection_status_start_batch (cnc, GDA_CONNECTION_STATUS_OPENING);
+ _gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_OPENING);
GdaWorker *worker;
worker = _gda_server_provider_create_worker (provider, TRUE);
@@ -2178,7 +2178,7 @@ _gda_server_provider_open_connection (GdaServerProvider *provider, GdaConnection
if (cb_func) {
if (!gda_worker_set_callback (worker, context,
(GdaWorkerCallback) server_provider_job_done_callback,
provider, error)) {
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_CLOSED);
+ _gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_CLOSED);
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
gda_worker_unref (worker);
return FALSE;
@@ -2206,7 +2206,7 @@ _gda_server_provider_open_connection (GdaServerProvider *provider, GdaConnection
(GdaWorkerFunc) worker_open_connection,
jdata, NULL, NULL, error);
if (job_id == 0) {
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_CLOSED);
+ _gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_CLOSED);
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
WorkerOpenConnectionData_free (jdata);
return FALSE; /* error */
@@ -2311,10 +2311,8 @@ stage2_close_connection (GdaConnection *cnc, gpointer result)
if (cdata->provider_data_destroy_func)
cdata->provider_data_destroy_func (cdata);
}
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_CLOSED);
+ _gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_CLOSED);
}
- else
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_IDLE);
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
@@ -2355,8 +2353,6 @@ _gda_server_provider_close_connection (GdaServerProvider *provider, GdaConnectio
jdata->provider = provider;
jdata->cnc = g_object_ref (cnc);
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_BUSY);
-
GdaWorker *worker;
worker = cdata->worker;
@@ -2439,14 +2435,14 @@ _gda_server_provider_statement_prepare (GdaServerProvider *provider, GdaConnecti
data.cnc = cnc;
data.stmt = stmt;
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_BUSY);
+ gda_connection_increase_usage (cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_statement_prepare, (gpointer) &data, NULL, NULL, NULL);
if (context)
g_main_context_unref (context);
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_IDLE);
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
gda_worker_unref (worker);
@@ -2559,14 +2555,14 @@ _gda_server_provider_statement_execute (GdaServerProvider *provider, GdaConnecti
data.col_types = col_types;
data.last_inserted_row = last_inserted_row;
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_BUSY);
+ gda_connection_increase_usage (cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_statement_execute, (gpointer) &data, NULL, NULL, error);
if (context)
g_main_context_unref (context);
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_IDLE);
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
gda_worker_unref (worker);
@@ -2647,16 +2643,18 @@ _gda_server_provider_statement_to_sql (GdaServerProvider *provider, GdaConnecti
data.flags = flags;
data.params_used = params_used;
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_BUSY);
+ if (cnc)
+ gda_connection_increase_usage (cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_stmt_to_sql, (gpointer) &data, NULL, NULL, error);
if (context)
g_main_context_unref (context);
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_IDLE);
- if (cnc)
+ if (cnc) {
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
+ }
gda_worker_unref (worker);
@@ -2727,16 +2725,18 @@ _gda_server_provider_identifier_quote (GdaServerProvider *provider, GdaConnectio
data.for_meta_store = for_meta_store;
data.force_quotes = force_quotes;
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_BUSY);
+ if (cnc)
+ gda_connection_increase_usage (cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_identifier_quote, (gpointer) &data, NULL, NULL, NULL);
if (context)
g_main_context_unref (context);
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_IDLE);
- if (cnc)
+ if (cnc) {
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
+ }
gda_worker_unref (worker);
@@ -2953,16 +2953,18 @@ _gda_server_provider_meta_0arg (GdaServerProvider *provider, GdaConnection *cnc,
data.values[2] = NULL;
data.values[3] = NULL;
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_BUSY);
+ if (cnc)
+ gda_connection_increase_usage (cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_meta, (gpointer) &data, NULL, NULL, NULL);
if (context)
g_main_context_unref (context);
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_IDLE);
- if (cnc)
+ if (cnc) {
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
+ }
gda_worker_unref (worker);
@@ -3014,16 +3016,18 @@ _gda_server_provider_meta_1arg (GdaServerProvider *provider, GdaConnection *cnc,
data.values[2] = NULL;
data.values[3] = NULL;
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_BUSY);
+ if (cnc)
+ gda_connection_increase_usage (cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_meta, (gpointer) &data, NULL, NULL, NULL);
if (context)
g_main_context_unref (context);
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_IDLE);
- if (cnc)
+ if (cnc) {
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
+ }
gda_worker_unref (worker);
@@ -3075,16 +3079,18 @@ _gda_server_provider_meta_2arg (GdaServerProvider *provider, GdaConnection *cnc,
data.values[2] = NULL;
data.values[3] = NULL;
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_BUSY);
+ if (cnc)
+ gda_connection_increase_usage (cnc); /* USAGE -- */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_meta, (gpointer) &data, NULL, NULL, NULL);
if (context)
g_main_context_unref (context);
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_IDLE);
- if (cnc)
+ if (cnc) {
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
+ }
gda_worker_unref (worker);
@@ -3137,16 +3143,18 @@ _gda_server_provider_meta_3arg (GdaServerProvider *provider, GdaConnection *cnc,
data.values[2] = value2;
data.values[3] = NULL;
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_BUSY);
+ if (cnc)
+ gda_connection_increase_usage (cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_meta, (gpointer) &data, NULL, NULL, NULL);
if (context)
g_main_context_unref (context);
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_IDLE);
- if (cnc)
+ if (cnc) {
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
+ }
gda_worker_unref (worker);
@@ -3199,16 +3207,18 @@ _gda_server_provider_meta_4arg (GdaServerProvider *provider, GdaConnection *cnc,
data.values[2] = value2;
data.values[3] = value3;
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_BUSY);
+ if (cnc)
+ gda_connection_increase_usage (cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_meta, (gpointer) &data, NULL, NULL, NULL);
if (context)
g_main_context_unref (context);
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_IDLE);
- if (cnc)
+ if (cnc) {
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
+ }
gda_worker_unref (worker);
@@ -3286,14 +3296,14 @@ _gda_server_provider_begin_transaction (GdaServerProvider *provider, GdaConnecti
data.name = name;
data.level = level;
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_BUSY);
+ gda_connection_increase_usage (cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_begin_transaction, (gpointer) &data, NULL, NULL, error);
if (context)
g_main_context_unref (context);
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_IDLE);
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
gda_worker_unref (worker);
@@ -3355,14 +3365,14 @@ _gda_server_provider_commit_transaction (GdaServerProvider *provider, GdaConnect
data.cnc = cnc;
data.name = name;
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_BUSY);
+ gda_connection_increase_usage (cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_commit_transaction, (gpointer) &data, NULL, NULL, error);
if (context)
g_main_context_unref (context);
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_IDLE);
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
gda_worker_unref (worker);
@@ -3424,14 +3434,14 @@ _gda_server_provider_rollback_transaction (GdaServerProvider *provider, GdaConne
data.cnc = cnc;
data.name = name;
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_BUSY);
+ gda_connection_increase_usage (cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_rollback_transaction, (gpointer) &data, NULL, NULL, error);
if (context)
g_main_context_unref (context);
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_IDLE);
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
gda_worker_unref (worker);
@@ -3485,14 +3495,14 @@ _gda_server_provider_add_savepoint (GdaServerProvider *provider, GdaConnection *
data.cnc = cnc;
data.name = name;
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_BUSY);
+ gda_connection_increase_usage (cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_add_savepoint, (gpointer) &data, NULL, NULL, error);
if (context)
g_main_context_unref (context);
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_IDLE);
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
gda_worker_unref (worker);
@@ -3546,14 +3556,14 @@ _gda_server_provider_rollback_savepoint (GdaServerProvider *provider, GdaConnect
data.cnc = cnc;
data.name = name;
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_BUSY);
+ gda_connection_increase_usage (cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_rollback_savepoint, (gpointer) &data, NULL, NULL, error);
if (context)
g_main_context_unref (context);
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_IDLE);
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
gda_worker_unref (worker);
@@ -3607,14 +3617,14 @@ _gda_server_provider_delete_savepoint (GdaServerProvider *provider, GdaConnectio
data.cnc = cnc;
data.name = name;
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_BUSY);
+ gda_connection_increase_usage (cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_delete_savepoint, (gpointer) &data, NULL, NULL, error);
if (context)
g_main_context_unref (context);
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_IDLE);
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
gda_worker_unref (worker);
@@ -3758,14 +3768,14 @@ _gda_server_provider_xa (GdaServerProvider *provider, GdaConnection *cnc, const
data.trx = trx;
data.type = type;
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_BUSY);
+ gda_connection_increase_usage (cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_xa, (gpointer) &data, NULL, NULL, error);
if (context)
g_main_context_unref (context);
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_IDLE);
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
gda_worker_unref (worker);
@@ -3803,14 +3813,14 @@ _gda_server_provider_xa_recover (GdaServerProvider *provider, GdaConnection *cnc
data.trx = NULL;
data.type = GDA_XA_RECOVER;
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_BUSY);
+ gda_connection_increase_usage (cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_xa, (gpointer) &data, NULL, NULL, error);
if (context)
g_main_context_unref (context);
- gda_connection_set_status (cnc, GDA_CONNECTION_STATUS_IDLE);
+ gda_connection_decrease_usage (cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
gda_worker_unref (worker);
diff --git a/libgda/libgda.symbols b/libgda/libgda.symbols
index a1a4647..6928f42 100644
--- a/libgda/libgda.symbols
+++ b/libgda/libgda.symbols
@@ -98,6 +98,7 @@
gda_connection_commit_transaction
gda_connection_create_operation
gda_connection_create_parser
+ gda_connection_decrease_usage
gda_connection_delete_savepoint
gda_connection_del_prepared_statement
gda_connection_delete_row_from_table
@@ -135,6 +136,7 @@
gda_connection_get_status
gda_connection_get_transaction_status
gda_connection_get_type
+ gda_connection_increase_usage
gda_connection_insert_row_into_table
gda_connection_insert_row_into_table_v
gda_connection_internal_change_transaction_state
@@ -167,7 +169,6 @@
gda_connection_rollback_savepoint
gda_connection_rollback_transaction
gda_connection_set_main_context
- gda_connection_set_status
gda_connection_statement_execute
gda_connection_statement_execute_non_select
gda_connection_statement_execute_select
diff --git a/providers/ldap/gda-ldap-provider.c b/providers/ldap/gda-ldap-provider.c
index 6fe14c2..69919b0 100644
--- a/providers/ldap/gda-ldap-provider.c
+++ b/providers/ldap/gda-ldap-provider.c
@@ -38,7 +38,7 @@
#include "gdaprov-data-model-ldap.h"
#include "gda-ldap-util.h"
#include <libgda/gda-server-provider-private.h> /* for gda_server_provider_get_real_main_context () */
-#include <libgda/gda-connection-internal.h> /* for gda_connection_set_status() */
+#include <libgda/gda-connection-internal.h> /* for gda_connection_increase/decrease_usage() */
static void gda_ldap_provider_class_init (GdaLdapProviderClass *klass);
static void gda_ldap_provider_init (GdaLdapProvider *provider,
diff --git a/providers/ldap/gda-ldap-util.c b/providers/ldap/gda-ldap-util.c
index d78bde7..78b3db2 100644
--- a/providers/ldap/gda-ldap-util.c
+++ b/providers/ldap/gda-ldap-util.c
@@ -25,7 +25,7 @@
#include <gda-util.h>
#include <libgda/gda-debug-macros.h>
#include <libgda/gda-server-provider-private.h> /* for gda_server_provider_get_real_main_context () */
-#include <libgda/gda-connection-internal.h> /* for gda_connection_set_status() */
+#include <libgda/gda-connection-internal.h> /* for gda_connection_increase/decrease_usage() */
static void
ldap_attribute_free (LdapAttribute *lat)
@@ -558,14 +558,14 @@ gda_ldap_get_attr_info (GdaLdapConnection *cnc, LdapConnectionData *cdata, const
data.cdata = cdata;
data.attribute = attribute;
- gda_connection_set_status ((GdaConnection*) cnc, GDA_CONNECTION_STATUS_BUSY);
+ gda_connection_increase_usage ((GdaConnection*) cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_gda_ldap_get_attr_info, (gpointer) &data, NULL, NULL, NULL);
if (context)
g_main_context_unref (context);
- gda_connection_set_status ((GdaConnection*) cnc, GDA_CONNECTION_STATUS_IDLE);
+ gda_connection_decrease_usage ((GdaConnection*) cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
gda_worker_unref (worker);
@@ -819,14 +819,14 @@ gdaprov_ldap_get_class_info (GdaLdapConnection *cnc, const gchar *classname)
data.cdata = cdata;
data.classname = classname;
- gda_connection_set_status ((GdaConnection*) cnc, GDA_CONNECTION_STATUS_BUSY);
+ gda_connection_increase_usage ((GdaConnection*) cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_gdaprov_ldap_get_class_info, (gpointer) &data, NULL, NULL,
NULL);
if (context)
g_main_context_unref (context);
- gda_connection_set_status ((GdaConnection*) cnc, GDA_CONNECTION_STATUS_IDLE);
+ gda_connection_decrease_usage ((GdaConnection*) cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
gda_worker_unref (worker);
@@ -1448,14 +1448,14 @@ gdaprov_ldap_describe_entry (GdaLdapConnection *cnc, const gchar *dn, GError **e
data.cdata = cdata;
data.dn = dn;
- gda_connection_set_status ((GdaConnection*) cnc, GDA_CONNECTION_STATUS_BUSY);
+ gda_connection_increase_usage ((GdaConnection*) cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_gdaprov_ldap_describe_entry, (gpointer) &data, NULL, NULL,
error);
if (context)
g_main_context_unref (context);
- gda_connection_set_status ((GdaConnection*) cnc, GDA_CONNECTION_STATUS_IDLE);
+ gda_connection_decrease_usage ((GdaConnection*) cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
gda_worker_unref (worker);
@@ -1647,14 +1647,14 @@ gdaprov_ldap_get_entry_children (GdaLdapConnection *cnc, const gchar *dn, gchar
data.dn = dn;
data.attributes = attributes;
- gda_connection_set_status ((GdaConnection*) cnc, GDA_CONNECTION_STATUS_BUSY);
+ gda_connection_increase_usage ((GdaConnection*) cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_gdaprov_ldap_get_entry_children, (gpointer) &data, NULL,
NULL, error);
if (context)
g_main_context_unref (context);
- gda_connection_set_status ((GdaConnection*) cnc, GDA_CONNECTION_STATUS_IDLE);
+ gda_connection_decrease_usage ((GdaConnection*) cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
gda_worker_unref (worker);
diff --git a/providers/ldap/gdaprov-data-model-ldap.c b/providers/ldap/gdaprov-data-model-ldap.c
index bb37fb0..36c5cea 100644
--- a/providers/ldap/gdaprov-data-model-ldap.c
+++ b/providers/ldap/gdaprov-data-model-ldap.c
@@ -31,7 +31,7 @@
#include "gdaprov-data-model-ldap.h"
#include <libgda/gda-debug-macros.h>
#include <libgda/gda-server-provider-private.h> /* for gda_server_provider_get_real_main_context () */
-#include <libgda/gda-connection-internal.h> /* for gda_connection_set_status() */
+#include <libgda/gda-connection-internal.h> /* for gda_connection_increase/decrease_usage() */
#define GDA_DEBUG_SUBSEARCHES
#undef GDA_DEBUG_SUBSEARCHES
@@ -959,14 +959,14 @@ update_iter_from_ldap_row (GdaDataModelLdap *imodel, GdaDataModelIter *iter)
data.imodel = imodel;
data.iter = iter;
- gda_connection_set_status ((GdaConnection*) cnc, GDA_CONNECTION_STATUS_BUSY);
+ gda_connection_increase_usage ((GdaConnection*) cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_update_iter_from_ldap_row, (gpointer) &data, NULL, NULL,
NULL);
if (context)
g_main_context_unref (context);
- gda_connection_set_status ((GdaConnection*) cnc, GDA_CONNECTION_STATUS_IDLE);
+ gda_connection_decrease_usage ((GdaConnection*) cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
gda_worker_unref (worker);
@@ -1208,14 +1208,14 @@ execute_ldap_search (GdaDataModelLdap *model)
data.cdata = cdata;
data.model = model;
- gda_connection_set_status ((GdaConnection*) cnc, GDA_CONNECTION_STATUS_BUSY);
+ gda_connection_increase_usage ((GdaConnection*) cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_execute_ldap_search, (gpointer) &data, NULL, NULL, NULL);
if (context)
g_main_context_unref (context);
- gda_connection_set_status ((GdaConnection*) cnc, GDA_CONNECTION_STATUS_IDLE);
+ gda_connection_decrease_usage ((GdaConnection*) cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
gda_worker_unref (worker);
@@ -1348,14 +1348,14 @@ gda_data_model_ldap_iter_next (GdaDataModel *model, GdaDataModelIter *iter)
data.imodel = imodel;
data.iter = iter;
- gda_connection_set_status ((GdaConnection*) cnc, GDA_CONNECTION_STATUS_BUSY);
+ gda_connection_increase_usage ((GdaConnection*) cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_gda_data_model_ldap_iter_next, (gpointer) &data, NULL,
NULL, NULL);
if (context)
g_main_context_unref (context);
- gda_connection_set_status ((GdaConnection*) cnc, GDA_CONNECTION_STATUS_IDLE);
+ gda_connection_decrease_usage ((GdaConnection*) cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
gda_worker_unref (worker);
@@ -1479,14 +1479,14 @@ ldap_part_free (LdapPart *part, GdaLdapConnection *cnc)
data.cdata = cdata;
data.part = part;
- gda_connection_set_status ((GdaConnection*) cnc, GDA_CONNECTION_STATUS_BUSY);
+ gda_connection_increase_usage ((GdaConnection*) cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_ldap_part_free, (gpointer) &data, NULL, NULL, NULL);
if (context)
g_main_context_unref (context);
- gda_connection_set_status ((GdaConnection*) cnc, GDA_CONNECTION_STATUS_IDLE);
+ gda_connection_decrease_usage ((GdaConnection*) cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
gda_worker_unref (worker);
@@ -1956,14 +1956,14 @@ gdaprov_ldap_modify (GdaLdapConnection *cnc, GdaLdapModificationType modtype,
data.entry = entry;
data.ref_entry = ref_entry;
- gda_connection_set_status ((GdaConnection*) cnc, GDA_CONNECTION_STATUS_BUSY);
+ gda_connection_increase_usage ((GdaConnection*) cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_gdaprov_ldap_modify, (gpointer) &data, NULL, NULL, error);
if (context)
g_main_context_unref (context);
- gda_connection_set_status ((GdaConnection*) cnc, GDA_CONNECTION_STATUS_IDLE);
+ gda_connection_decrease_usage ((GdaConnection*) cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
gda_worker_unref (worker);
@@ -2062,14 +2062,14 @@ gdaprov_ldap_rename_entry (GdaLdapConnection *cnc, const gchar *current_dn, cons
data.current_dn = current_dn;
data.new_dn = new_dn;
- gda_connection_set_status ((GdaConnection*) cnc, GDA_CONNECTION_STATUS_BUSY);
+ gda_connection_increase_usage ((GdaConnection*) cnc); /* USAGE ++ */
gpointer retval;
gda_worker_do_job (worker, context, 0, &retval, NULL,
(GdaWorkerFunc) worker_gdaprov_ldap_rename_entry, (gpointer) &data, NULL, NULL,
error);
if (context)
g_main_context_unref (context);
- gda_connection_set_status ((GdaConnection*) cnc, GDA_CONNECTION_STATUS_IDLE);
+ gda_connection_decrease_usage ((GdaConnection*) cnc); /* USAGE -- */
gda_lockable_unlock ((GdaLockable*) cnc); /* CNC UNLOCK */
gda_worker_unref (worker);
diff --git a/tools/common/t-config-info.c b/tools/common/t-config-info.c
index 8e6193a..3265a56 100644
--- a/tools/common/t-config-info.c
+++ b/tools/common/t-config-info.c
@@ -20,6 +20,7 @@
#include "t-errors.h"
#include <glib/gi18n-lib.h>
#include <glib/gstdio.h>
+#include <libgda/gda-connection-internal.h> /* for gda_connection_increase/decrease_usage() */
/*
* Replace @argvi's contents with the connection name
@@ -731,11 +732,19 @@ t_config_info_update_meta_store_properties (GdaMetaStore *mstore, GdaConnection
g_value_take_boxed ((dvalue = gda_value_new (G_TYPE_DATE)), date);
tmp = gda_value_stringify (dvalue);
gda_value_free (dvalue);
+
+ GdaConnection *icnc;
+ icnc = gda_meta_store_get_internal_connection (mstore);
+ gda_lockable_lock (GDA_LOCKABLE (icnc));
+ gda_connection_increase_usage (icnc); /* USAGE ++ */
+
gda_meta_store_set_attribute_value (mstore, "last-used", tmp, NULL);
g_free (tmp);
-
gda_meta_store_set_attribute_value (mstore, "cnc-string",
gda_connection_get_cnc_string (rel_cnc), NULL);
gda_meta_store_set_attribute_value (mstore, "cnc-provider",
gda_connection_get_provider_name (rel_cnc), NULL);
+
+ gda_connection_decrease_usage (icnc); /* USAGE -- */
+ gda_lockable_unlock (GDA_LOCKABLE (icnc));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]