Skip to content

Commit

Permalink
Explicit mutex attributs settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfdelnero committed Nov 8, 2023
1 parent 2b23436 commit 7eda07b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions inc/mtp.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ typedef struct mtp_ctx_

int inotify_fd;
pthread_t inotify_thread;
pthread_mutexattr_t inotify_mutex_attr;
pthread_mutex_t inotify_mutex;

int msgqueue_id;
Expand Down
11 changes: 9 additions & 2 deletions src/mtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,14 @@ mtp_ctx * mtp_init_responder()

ctx->SetObjectPropValue_Handle = 0xFFFFFFFF;

pthread_mutex_init ( &ctx->inotify_mutex, NULL);
if( pthread_mutexattr_init( &ctx->inotify_mutex_attr ) )
goto init_error;

if( pthread_mutexattr_settype( &ctx->inotify_mutex_attr, PTHREAD_MUTEX_NORMAL ) )
goto init_error;

if( pthread_mutex_init (&ctx->inotify_mutex, &ctx->inotify_mutex_attr ) )
goto init_error;

inotify_handler_init( ctx );
msgqueue_handler_init( ctx );
Expand Down Expand Up @@ -117,7 +124,7 @@ mtp_ctx * mtp_init_responder()

PRINT_ERROR("init_mtp_responder : Failed !");

return 0;
return NULL;
}

void mtp_deinit_responder(mtp_ctx * ctx)
Expand Down

0 comments on commit 7eda07b

Please sign in to comment.