diff options
author | Jose Bollo <jose.bollo@iot.bzh> | 2019-12-20 17:06:40 +0100 |
---|---|---|
committer | Jose Bollo <jose.bollo@iot.bzh> | 2019-12-20 18:03:21 +0100 |
commit | c98333b595beb7858a4d3c17cd405dde2f79ce2e (patch) | |
tree | 41c444d91afb287a66a4292c433cbc4bdfb03add | |
parent | e847f14c7688f43b5f74e7362dcd5d4714e98bd3 (diff) |
wgtpkg-install: Fix allocation of IDsicefish_8.99.4icefish/8.99.48.99.4
The framework wasn't correctly attributing application ids
because scanning existing applications was broken.
Bug-AGL: SPEC-3068
Change-Id: I01aa736c0ea072b5e4141fb5faa1981be81048ce
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
-rw-r--r-- | src/wgtpkg-install.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/wgtpkg-install.c b/src/wgtpkg-install.c index 9c148c7..33c4299 100644 --- a/src/wgtpkg-install.c +++ b/src/wgtpkg-install.c @@ -53,7 +53,7 @@ static const char* exec_type_strings[] = { }; static const char key_afm_prefix[] = "X-AFM-"; -static const char key_afid[] = "-ID"; +static const char key_afid[] = "ID"; #define HTTP_PORT_BASE 30000 @@ -62,8 +62,8 @@ static const char key_afid[] = "-ID"; #define AFID_IS_VALID(afid) (AFID_MIN <= (afid) && (afid) <= AFID_MAX) #define AFID_COUNT (AFID_MAX - AFID_MIN + 1) #define AFID_ACNT ((AFID_COUNT + 31) >> 5) -#define AFID_ASFT(afid) (((afid) - AFID_MIN) & 31) -#define AFID_AIDX(afid) (((afid) - AFID_MIN) >> 5) +#define AFID_ASFT(afid) (((afid) - AFID_MIN) & 31) +#define AFID_AIDX(afid) (((afid) - AFID_MIN) >> 5) #define AFID_TEST(array,afid) ((((array)[AFID_AIDX(afid)]) >> AFID_ASFT(afid)) & 1) #define AFID_SET(array,afid) (((array)[AFID_AIDX(afid)]) |= (((uint32_t)1) << AFID_ASFT(afid))) @@ -186,6 +186,12 @@ static int get_new_afid() /* allocates the afid */ afid = first_free_afid(afids_array); + if (afid < 0 && errno == EADDRNOTAVAIL) { + /* no more ids, try to rescan */ + memset(afids_array, 0, AFID_ACNT * sizeof(uint32_t)); + if (update_afids(afids_array) >= 0) + afid = first_free_afid(afids_array); + } if (afid >= 0) AFID_SET(afids_array, afid); |