diff options
author | Barak Sason Rofman <bsasonro@redhat.com> | 2020-12-23 14:58:40 +0200 |
---|---|---|
committer | Xavi Hernandez <xhernandez@users.noreply.github.com> | 2021-01-21 15:49:37 +0100 |
commit | 15e111418d5854db8b328e2273c91d60912a83c3 (patch) | |
tree | dc78a6335152b5c157b2837717e4e688d7513f4d /xlators | |
parent | 6cece6e03239f7e68cd0cb89e5bdff569802cda7 (diff) | |
download | glusterfs-15e111418d5854db8b328e2273c91d60912a83c3.tar.gz glusterfs-15e111418d5854db8b328e2273c91d60912a83c3.tar.xz glusterfs-15e111418d5854db8b328e2273c91d60912a83c3.zip |
posix - fix coverity issue (Unchecked return value)
CID 1291733
The return value of the method pthread_cancel was not being checked.
Added a retun value check and proper error handling.
Change-Id: I8c52b0e462461fc59718deb3b7c2f1b4e55613c7
updates: #1060
Signed-off-by: Barak Sason Rofman <bsasonro@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/storage/posix/src/posix-helpers.c | 8 | ||||
-rw-r--r-- | xlators/storage/posix/src/posix-messages.h | 3 |
2 files changed, 9 insertions, 2 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c index be7b71c52c..3575bbc8b4 100644 --- a/xlators/storage/posix/src/posix-helpers.c +++ b/xlators/storage/posix/src/posix-helpers.c @@ -2276,7 +2276,13 @@ posix_spawn_health_check_thread(xlator_t *xl) { /* cancel the running thread */ if (priv->health_check_active == _gf_true) { - pthread_cancel(priv->health_check); + ret = pthread_cancel(priv->health_check); + if (ret != 0) { + gf_msg(xl->name, GF_LOG_ERROR, ret, P_MSG_PTHREAD_CANCEL_FAILED, + "Failed to send cancellation to health-check thread"); + ret = -1; + goto unlock; + } priv->health_check_active = _gf_false; } diff --git a/xlators/storage/posix/src/posix-messages.h b/xlators/storage/posix/src/posix-messages.h index 46518eb616..ca5b074161 100644 --- a/xlators/storage/posix/src/posix-messages.h +++ b/xlators/storage/posix/src/posix-messages.h @@ -69,6 +69,7 @@ GLFS_MSGID(POSIX, P_MSG_XATTR_FAILED, P_MSG_NULL_GFID, P_MSG_FCNTL_FAILED, P_MSG_FETCHMDATA_FAILED, P_MSG_GETMDATA_FAILED, P_MSG_SETMDATA_FAILED, P_MSG_FRESHFILE, P_MSG_MUTEX_FAILED, P_MSG_COPY_FILE_RANGE_FAILED, P_MSG_TIMER_DELETE_FAILED, P_MSG_NOMEM, - P_MSG_PSTAT_FAILED, P_MSG_FDSTAT_FAILED, P_MSG_POSIX_IO_URING); + P_MSG_PSTAT_FAILED, P_MSG_FDSTAT_FAILED, P_MSG_POSIX_IO_URING, + P_MSG_PTHREAD_CANCEL_FAILED); #endif /* !_GLUSTERD_MESSAGES_H_ */ |