protect cellular http api calls by mutex
Issue by ChiefGokhlayehBosch
Friday Aug 09, 2019 at 13:50 GMT
Originally opened as https://github.com/Bosch-AE-SW/cddk-oss/issues/198
I noticed a potential hazard in the HTTP service-layer.
The Cellular driver API promises to be thread-safe. To achieve this we simply lock the entire driver API with a mutex. We do this via the helper function Engine_Dispatch(). The idea is to put everything that should be under the mutex' protection into a function and then dispatch said function via this little helper. Note that in-between consecutive Engine_Dispatch() calls we are not protected.
This is what's bugging me about HttpService.c. There we call Engine_Dispatch() multiple times for a single request. Given that HTTP works with intermediate files on the modem's own flash, it is highly recommended to protect the entire request under a single mutex lock (basically just get rid of the individual Engine_Dispatch() calls and stuff everything into a single one).