Hi Clement,
On 10/9/25 11:50, Clément Ramirez wrote:
> Hi Stefano,
>
> Thanks for you answer,
>
>> SWUpdate maintains and updates each internal structures for the time of
>> an update. At the end of each transaction (failed or successful), this
>> structures are freed.
>>
>> The structures related to the versions (installed_sw_list ) are not
>> freed after an update. This is done in cleanup_files(), where temporary
>> lists are iterated and each element is freed. The right solution (I
>> confirm from code that this bug exists) is to release the allocated list
>> inside the cleanup function.
>
> So If I understand correctly a solution could be to free the entire
> installed_sw_list
> structure and then maybe re-create it from the sw-versions file (for
> what I see from code this
> is done once during startup).
> Or maybe do this operation in 2 steps. First free the structure in the
> cleanup_files()
> function as you mentioned it and then re-read the sw-versions contents when a
> new update will be started over.
The issue was created by adding the feature because it was not split
between configuration (read from /etc/sw-versions or /etc/swupdate.cfg)
and runtime. Runtime is overwriting the configuration and this leads to
the problem.
IMHO it should be better solved in another way. Rereading the file is
dummy, SWUpdate has already the list. So the whole list shouldn't be
erased, just the runtime part (that doesn't currently exist).
So the struct sw_version should be extended, and it should have twice
name/version pair, one for the configuration (that does not change) and
one for the runtime (added after each successful installation of an
artifact), and in cleanup the runtime values are erased without changing
the configuration values.
> In this case reading the sw-versions file can be done in the network_thread()
> function (under the REQ_INSTALL case).
>
> If we don't re-read the list, any artifacts might be installed
> regardless of their installation
> status, registered within sw-versions file.
>
Best regards,
Stefano Babic