summaryrefslogtreecommitdiff
path: root/libjack
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2013-10-02 00:38:59 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2013-10-02 00:38:59 -0400
commit70a24bceffdd539df3fab3c7b649279732926185 (patch)
tree85f8dd5a9c384f83711d8c7ce4c0e1139769e5c9 /libjack
parent03e8c06e1ca9a41fe81851c452327f1e567ae546 (diff)
downloadjack1-70a24bceffdd539df3fab3c7b649279732926185.tar.gz
add code to remove metadata for ports and clients when ports and clients are deleted/cleaned up
Diffstat (limited to 'libjack')
-rw-r--r--libjack/metadata.c40
1 files changed, 35 insertions, 5 deletions
diff --git a/libjack/metadata.c b/libjack/metadata.c
index df460d9..5fc6f7b 100644
--- a/libjack/metadata.c
+++ b/libjack/metadata.c
@@ -27,6 +27,7 @@
#include "local.h"
static DB* db = NULL;
+static DB_ENV* db_env = NULL;
static int
jack_property_init (const char* server_name)
@@ -37,11 +38,21 @@ jack_property_init (const char* server_name)
/* idempotent */
- if (db) {
+ if (db_env) {
return 0;
}
- if ((ret = db_create (&db, NULL, 0)) != 0) {
+ if ((ret = db_env_create(&db_env, 0)) != 0) {
+ jack_error ("cannot initialize DB environment: %s\n", db_strerror(ret));
+ return -1;
+ }
+
+ if ((ret = db_env->open(db_env, jack_server_dir (server_name, server_dir), DB_CREATE | DB_INIT_LOCK | DB_INIT_MPOOL | DB_THREAD, 0)) != 0) {
+ jack_error ("cannot open DB environment: %s", db_strerror (ret));
+ return -1;
+ }
+
+ if ((ret = db_create (&db, db_env, 0)) != 0) {
jack_error ("Cannot initialize metadata DB (%s)", db_strerror (ret));
return -1;
}
@@ -67,6 +78,10 @@ jack_properties_uninit ()
db->close (db, 0);
db = NULL;
}
+ if (db_env) {
+ db_env->close (db_env, 0);
+ db_env = 0;
+ }
}
void
@@ -93,6 +108,14 @@ static int
jack_property_change_notify (jack_client_t* client, jack_uuid_t uuid, const char* key, jack_property_change_t change)
{
jack_request_t req;
+
+ /* the engine passes in a NULL client when it removes metadata during port or client removal
+ */
+
+ if (client == NULL) {
+ return 0;
+ }
+
req.type = PropertyChangeNotify;
req.x.property.change = change;
jack_uuid_copy (req.x.property.uuid, uuid);
@@ -562,6 +585,7 @@ jack_remove_properties (jack_client_t* client, jack_uuid_t subject)
int ret;
char ustr[JACK_UUID_STRING_SIZE];
int retval = 0;
+ uint32_t cnt = 0;
jack_uuid_unparse (subject, ustr);
@@ -569,7 +593,6 @@ jack_remove_properties (jack_client_t* client, jack_uuid_t subject)
return -1;
}
-
if ((ret = db->cursor (db, NULL, &cursor, 0)) != 0) {
jack_error ("Cannot create cursor for metadata search (%s)", db_strerror (ret));
return -1;
@@ -607,13 +630,20 @@ jack_remove_properties (jack_client_t* client, jack_uuid_t subject)
*/
retval = -1;
}
+ cnt++;
}
cursor->close (cursor);
- jack_property_change_notify (client, subject, NULL, PropertyDeleted);
+ if (cnt) {
+ jack_property_change_notify (client, subject, NULL, PropertyDeleted);
+ }
+
+ if (retval) {
+ return -1;
+ }
- return retval;
+ return cnt;
}
int