libnetconf2 icon indicating copy to clipboard operation
libnetconf2 copied to clipboard

if return EPERM,no need to release the mutex_lock ?

Open duoyanbi opened this issue 5 years ago • 3 comments

https://github.com/CESNET/libnetconf2/blob/a7c8a81988adc9e1be7491788a67b71542a06116/src/session_server.c#L899 pthread_cond_timedwait: EPERM The mutex was not owned by the current thread at the time of the call. if return EPERM,no need to release the mutex_lock ? At this time, the nc_ps_queue_remove_id( ) operation has no concurrency protection.

duoyanbi avatar Mar 16 '20 09:03 duoyanbi

Hi, how would it be possible for pthread_cond_timedwait() to return EPERM?

Regards, Michal

michalvasko avatar Mar 16 '20 09:03 michalvasko

Hi, how would it be possible for pthread_cond_timedwait() to return EPERM?

Regards, Michal

Sorry, the return value is caused by human error call, such as pthread_cond_timedwait without lock。

I need to check the information to confirm that after calling pthread_cond_timedwait (), it needs to be unlocked, regardless of whether the call is successful。

Thank you very much !

duoyanbi avatar Mar 16 '20 10:03 duoyanbi

Hi, it is uniform, excerpt from the man page:

Except in the case of [ETIMEDOUT], all these error checks shall act as if they were performed immediately at the beginning of processing for the function and shall cause an error return, in effect, prior to modifying the state of the mutex specified by mutex or the condition variable specified by cond.

Regards, Michal

michalvasko avatar Mar 16 '20 10:03 michalvasko