measure_queue_stop() 무한 대기 방지

This commit is contained in:
2026-07-10 17:34:59 +09:00
parent 4c9a89463d
commit 67b539a47a
+10 -4
View File
@@ -15,6 +15,7 @@
#define MEASURE_QUEUE_PERIOD_MS 100U #define MEASURE_QUEUE_PERIOD_MS 100U
#define MEASURE_QUEUE_THREAD_STACK_SIZE 2048 #define MEASURE_QUEUE_THREAD_STACK_SIZE 2048
#define MEASURE_QUEUE_THREAD_PRIORITY 7 #define MEASURE_QUEUE_THREAD_PRIORITY 7
#define MEASURE_QUEUE_STOP_JOIN_TIMEOUT_MS 3000U
/* data_storage flash partition handle, opened once and reused */ /* data_storage flash partition handle, opened once and reused */
static const struct flash_area *queue_area; static const struct flash_area *queue_area;
@@ -305,10 +306,15 @@ int measure_queue_stop(uint32_t *tick_end, uint8_t *session, uint16_t *total_fra
queue_recording = false; queue_recording = false;
k_mutex_unlock(&queue_lock); k_mutex_unlock(&queue_lock);
int join_err = 0;
if (was_running) if (was_running)
{ {
// rfe: 응답 시 측정 중인 경우 측정 완료될 때까지 기다림 // Wait for the recording thread, but never block the BLE command path forever.
(void)k_thread_join(&queue_thread, K_FOREVER); join_err = k_thread_join(&queue_thread, K_MSEC(MEASURE_QUEUE_STOP_JOIN_TIMEOUT_MS));
if (join_err)
{
DBG_ERR("[MFE] record thread join timeout err=%d\r\n", join_err);
}
} }
k_mutex_lock(&queue_lock, K_FOREVER); k_mutex_lock(&queue_lock, K_FOREVER);
@@ -324,7 +330,7 @@ int measure_queue_stop(uint32_t *tick_end, uint8_t *session, uint16_t *total_fra
{ {
*total_frames = queue_total_frames; *total_frames = queue_total_frames;
} }
int status = queue_status; int status = (join_err != 0) ? -ETIMEDOUT : queue_status;
uint8_t stop_session = queue_session; uint8_t stop_session = queue_session;
uint16_t stop_frames = queue_total_frames; uint16_t stop_frames = queue_total_frames;
uint16_t num_samples = queue_num_samples; uint16_t num_samples = queue_num_samples;
@@ -446,4 +452,4 @@ int measure_queue_read_frame(uint16_t frame_idx, measure_queue_frame_header_t *h
} }
return 0; return 0;
} }