Correct dfu thread state 02/200102/3
authorDongwoo Lee <dwoo08.lee@samsung.com>
Fri, 1 Feb 2019 05:57:35 +0000 (14:57 +0900)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Wed, 20 Feb 2019 00:51:51 +0000 (00:51 +0000)
There is no need to unlock to change dfu state, this patch removes
lock/unlock between dfu state change. Also, some missing state change
is applied either.

Change-Id: I15215504bc4c2d7ca407285822d2508fe09b5a25
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
src/dfu.c

index c7048f6587667fb0dd534ea6f84bbabbee834162..beb7aca9bc59b6b88ecc0c185bc74ddd21639000 100644 (file)
--- a/src/dfu.c
+++ b/src/dfu.c
@@ -307,14 +307,13 @@ static void *dfu_thread_main(void *ptr)
 
                while (TAILQ_EMPTY(&ctx->dfu_ioq_head)) {
                        pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
+                       state = DFU_THREAD_STATE_IDLE;
                        pthread_cond_wait(&ctx->dfu_data_arrive, &ctx->dfu_mutex);
                }
 
                if (state == DFU_THREAD_STATE_IDLE) {
-                       pthread_mutex_unlock(&ctx->dfu_mutex);
                        state = DFU_THREAD_STATE_FLASHING;
                        pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
-                       pthread_mutex_lock(&ctx->dfu_mutex);
                }
 
                frame = TAILQ_FIRST(&ctx->dfu_ioq_head);