param: grab the shutdown lock while writing params to the file

This commit is contained in:
Beat Küng
2017-07-29 23:10:47 +02:00
committed by Lorenz Meier
parent 898a8dcd57
commit 931ef189b5
3 changed files with 38 additions and 8 deletions
@@ -44,6 +44,7 @@
#include <px4_defines.h>
#include <px4_posix.h>
#include <px4_shutdown.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
@@ -158,6 +159,12 @@ out:
size_t buf_size = bson_encoder_buf_size(&encoder);
int shutdown_lock_ret = px4_shutdown_lock();
if (shutdown_lock_ret) {
PX4_ERR("px4_shutdown_lock() failed (%i)", shutdown_lock_ret);
}
/* Get a buffer from the flash driver with enough space */
uint8_t *buffer;
@@ -186,6 +193,11 @@ out:
free(enc_buff);
parameter_flashfs_free();
}
if (shutdown_lock_ret == 0) {
px4_shutdown_unlock();
}
}
return result;