summaryrefslogtreecommitdiffstats
path: root/plugins/alsa/alsa-api-mixer.c
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2019-10-15 16:37:10 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2019-10-15 21:18:21 +0200
commitbdc65085fa6f979008b4c748d46eb7eff0a725cb (patch)
treeecd8eded105077e4d0e4a194adeea865c89fe3aa /plugins/alsa/alsa-api-mixer.c
parentf833c3a7fbaadea747933fdaf3d3b4fa72637a3b (diff)
Prevent errors when receiving the same 'attach' transaction multiple times. Necessary when using a hal with mulitple dependencies. BUG-AGL: SPEC-2895 Change-Id: I7e8650dcdd93a5518b29acb786cca07ba6d9b59f Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to 'plugins/alsa/alsa-api-mixer.c')
-rw-r--r--plugins/alsa/alsa-api-mixer.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/plugins/alsa/alsa-api-mixer.c b/plugins/alsa/alsa-api-mixer.c
index f0e8b78..f2f3f57 100644
--- a/plugins/alsa/alsa-api-mixer.c
+++ b/plugins/alsa/alsa-api-mixer.c
@@ -548,7 +548,7 @@ STATIC void MixerAttachVerb(afb_req_t request) {
json_object *argsJ = afb_req_json(request);
json_object *responseJ = json_object_new_object();
int error;
- AlsaMixerTransaction * transaction = NULL;
+ AlsaMixerTransaction *transaction = NULL, *existingTransaction;
AFB_API_INFO(mixer->api, "%s: %s", __func__, json_object_get_string(argsJ));
@@ -572,6 +572,17 @@ STATIC void MixerAttachVerb(afb_req_t request) {
goto fail;
}
+ cds_list_for_each_entry(existingTransaction, &mixer->transactionList, transaction_node) {
+ if(! strcmp(uid, existingTransaction->uid)) {
+ AFB_API_INFO(mixer->api,
+ "'attach' call with json '%s' will be ignored because json 'uid' "
+ "has already been used in a previous transaction",
+ json_object_get_string(argsJ));
+ afb_req_success(request, NULL, NULL);
+ return;
+ }
+ }
+
transaction = AlsaMixerTransactionNew(mixer, uid);
if (transaction == NULL) {
SOFTMIXER_NOMEM(mixer->api);