From bdc65085fa6f979008b4c748d46eb7eff0a725cb Mon Sep 17 00:00:00 2001 From: Jonathan Aillet Date: Tue, 15 Oct 2019 16:37:10 +0200 Subject: Prevent errors when receiving 'attach' call 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 --- plugins/alsa/alsa-api-mixer.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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); -- cgit 1.2.3-korg