Skip to content

Commit

Permalink
Merge pull request #158 from piotras/ratatoskr
Browse files Browse the repository at this point in the history
GDA connection thread safe flag
  • Loading branch information
piotras committed Mar 19, 2012
2 parents d85f597 + 7dee9b8 commit 77f7399
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
19 changes: 18 additions & 1 deletion src/midgard_config.c
Expand Up @@ -62,7 +62,8 @@ enum {
MIDGARD_CONFIG_BLOBDIR,
MIDGARD_CONFIG_SHAREDIR,
MIDGARD_CONFIG_VARDIR,
MIDGARD_CONFIG_CACHEDIR
MIDGARD_CONFIG_CACHEDIR,
MIDGARD_CONFIG_GDATHREADS
};

static MidgardConfigPrivate *midgard_config_private_new(void)
Expand Down Expand Up @@ -1576,6 +1577,10 @@ _midgard_config_set_property (GObject *object, guint property_id,
self->cachedir = g_value_dup_string (value);
break;

case MIDGARD_CONFIG_GDATHREADS:
self->gdathreads = g_value_get_boolean(value);
break;

default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
break;
Expand Down Expand Up @@ -1671,6 +1676,10 @@ _midgard_config_get_property (GObject *object, guint property_id,
g_value_set_string (value, self->cachedir);
break;

case MIDGARD_CONFIG_GDATHREADS:
g_value_set_boolean (value, self->gdathreads);
break;

default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
break;
Expand Down Expand Up @@ -1838,6 +1847,14 @@ _midgard_config_class_init (gpointer g_class, gpointer g_class_data)
MIDGARD_CONFIG_AUTHTYPE,
pspec);

pspec = g_param_spec_boolean("gdathreads",
"GdaThreads",
"GDA connection thread safe flag",
FALSE, G_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
MIDGARD_CONFIG_GDATHREADS,
pspec);

/* MidgardDir */
pspec = g_param_spec_string ("blobdir",
"BlobDir",
Expand Down
5 changes: 4 additions & 1 deletion src/midgard_connection.c
Expand Up @@ -560,7 +560,10 @@ __midgard_connection_open(MidgardConnection *mgd, gboolean init_schema, GError *

GError *err = NULL;
GdaConnection *connection = gda_connection_open_from_string(
config->dbtype, tmpstr, auth, GDA_CONNECTION_OPTIONS_NONE, &err);
config->dbtype,
tmpstr, auth,
enable_threads ? GDA_CONNECTION_OPTIONS_THREAD_SAFE : GDA_CONNECTION_OPTIONS_NONE,
&err);
g_free(auth);

if(connection == NULL) {
Expand Down
10 changes: 10 additions & 0 deletions tests/GIR/test_000_config.py
Expand Up @@ -38,6 +38,16 @@ def testProperties(self):
self.assertNotEqual(config.get_property("dbdir"), "/tmp/test")
self.assertFalse(hasattr(config.props, "notexists"))

def testBooleanProperties(self):
config = Midgard.Config()
boolean_properties = { "tablecreate", "tableupdate", "gdathreads" }
for prop in boolean_properties:
self.assertTrue(hasattr(config.props, prop))
config.set_property(prop, True)
self.assertTrue(config.get_property(prop))
config.set_property(prop, False)
self.assertFalse(config.get_property(prop))

def testReadFileAtPath(self):
config = Midgard.Config()
self.assertTrue(config.read_file_at_path("./test_SQLITE.conf"))
Expand Down

0 comments on commit 77f7399

Please sign in to comment.