diff options
author | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2019-10-15 16:37:10 +0200 |
---|---|---|
committer | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2019-10-15 21:18:21 +0200 |
commit | bdc65085fa6f979008b4c748d46eb7eff0a725cb (patch) | |
tree | ecd8eded105077e4d0e4a194adeea865c89fe3aa | |
parent | f833c3a7fbaadea747933fdaf3d3b4fa72637a3b (diff) |
Prevent errors when receiving 'attach' callicefish_8.99.5icefish_8.99.4icefish_8.99.3icefish_8.99.2icefish_8.99.1icefish/8.99.5icefish/8.99.4icefish/8.99.3icefish/8.99.2icefish/8.99.18.99.58.99.48.99.38.99.28.99.1
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>
-rw-r--r-- | plugins/alsa/alsa-api-mixer.c | 13 |
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); |