summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Brand <tom@trellis.ch>2019-02-07 12:31:36 +0100
committerThomas Brand <tom@trellis.ch>2019-02-07 12:31:36 +0100
commita7f93c7eebe41fb9e22e05840a5192ac82d86832 (patch)
tree6ee2b77f55e0879483c1f151e0edb8c4624c3cff
parent205e0d7b968a41ac3c8081e922cf76978b6ca166 (diff)
downloadjack2-a7f93c7eebe41fb9e22e05840a5192ac82d86832.tar.gz
Allow JackMetadata::GetProperty(ies) to return single char values
Problem: #set two properties for UUID 4294967296 $ jack_property -s 4294967296 "a" 1 $ jack_property -s 4294967296 b "2" #-l lists them $ jack_property -l 4294967296 key: b value: 2 key: a value: 1 #-l for UUID doesn't list them <<<<<< $ jack_property -l 4294967296 $ jack_property -l 4294967296 a Value not found for a of 4294967296 $ jack_property -l 4294967296 b Value not found for b of 4294967296 #it seems that 3 chars is the minimum length for value when querying for UUID $ jack_property -s 4294967296 a 123 $ jack_property -l 4294967296 key: a value: 123 $ jack_property -l 4294967296 a 123 In example-clients/property.c: /* list all properties for a given UUID */ if ((cnt = jack_get_properties (uuid, &description)) < 0) { fprintf (stderr, "could not retrieve properties for %s\n", subject); exit (1); } cnt is always 0 for values < 3 chars. Why? In common/JackMetadata.cpp: int JackMetadata::GetProperty(jack_uuid_t subject, const char* key, char** value, char** type) int JackMetadata::GetProperties(jack_uuid_t subject, jack_description_t* desc) This loop gets results: while ((ret = cursor->get (cursor, &key, &data, DB_NEXT)) == 0) { but are dropped because of this check: /* result must have at least 2 chars plus 2 nulls to be valid if (data.size < 4) { This rule isn't understood. Explanations are welcome! Reducing the check to 2 (1 char + null) will consider single char values. This makes listing properties for a given UUID the same keys as when listing all UUIDs and keys. No side-effects of lowering the value has been detected (yet). Note: there is no problem getting "short" values in this method: int JackMetadata::GetAllProperties(jack_description_t** descriptions) (as used by jack_property -l without UUID) jack_property output after change to (data.size < 2): $ jack_property -s 4294967296 "a" 1 $ jack_property -s 4294967296 b "2" $ jack_property -l 4294967296 key: b value: 2 key: a value: 1 $ jack_property -l 4294967296 key: b value: 2 key: a value: 1 $ jack_property -l 4294967296 a 1 $ jack_property -l 4294967296 b 2 Note: This change should be considered also for JACK1 (libjack/metadata.c) to keep implementations in sync.
-rw-r--r--common/JackMetadata.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/common/JackMetadata.cpp b/common/JackMetadata.cpp
index 4d7df2f0..b690a01a 100644
--- a/common/JackMetadata.cpp
+++ b/common/JackMetadata.cpp
@@ -247,10 +247,13 @@ int JackMetadata::GetProperty(jack_uuid_t subject, const char* key, char** value
return -1;
}
- /* result must have at least 2 chars plus 2 nulls to be valid
+ /* result must have at least 1 char plus 1 null to be valid
+ (old rule was:
+ result must have at least 2 chars plus 2 nulls to be valid
+ )
*/
- if (data.size < 4) {
+ if (data.size < 2) {
if (d_key.size > 0) {
free (d_key.data);
}
@@ -345,10 +348,13 @@ int JackMetadata::GetProperties(jack_uuid_t subject, jack_description_t* desc)
continue;
}
- /* result must have at least 2 chars plus 2 nulls to be valid
- */
+ /* result must have at least 1 char plus 1 null to be valid
+ (old rule was:
+ result must have at least 2 chars plus 2 nulls to be valid
+ )
+ */
- if (data.size < 4) {
+ if (data.size < 2) {
/* if (key.size > 0) free(key.data); */
if (data.size > 0) {
free (data.data);