summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-helpers.c
diff options
context:
space:
mode:
authorMohit Agrawal <moagrawal@redhat.com>2019-01-02 16:25:35 +0530
committerAmar Tumballi <amarts@redhat.com>2019-01-11 06:02:52 +0000
commit1e28c54c5ec8d84ec8a22493161314010992918e (patch)
tree9c94618a500e7c841b4f69c4c559834cc61a9c41 /xlators/storage/posix/src/posix-helpers.c
parentfa7ae128706062afefcb0a3117527b8bef21f396 (diff)
core: brick process is crashed at the time of spawn thread
Problem: brick is getting crashed at the time of calling pthread_detach after just call gf_thread_create.If sufficient resources are not available on the system pthread_create returns EAGAIN (non-negative) but the caller function expects negative error code in case of failure Solution: Change the condition in caller function to avoid the crash Change-Id: Ifeaa49f809957eb6c33aa9792f5af1b55566756d fixes: bz#1662906
Diffstat (limited to 'xlators/storage/posix/src/posix-helpers.c')
-rw-r--r--xlators/storage/posix/src/posix-helpers.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index 874b0a0171b..193afc5f3fa 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -1597,7 +1597,7 @@ posix_ctx_janitor_thread_proc(void *data)
return NULL;
}
-void
+int
posix_spawn_ctx_janitor_thread(xlator_t *this)
{
struct posix_private *priv = NULL;
@@ -1618,7 +1618,7 @@ posix_spawn_ctx_janitor_thread(xlator_t *this)
posix_ctx_janitor_thread_proc, this,
"posixctxjan");
- if (ret < 0) {
+ if (ret) {
gf_msg(this->name, GF_LOG_ERROR, errno, P_MSG_THREAD_FAILED,
"spawning janitor "
"thread failed");
@@ -1628,6 +1628,7 @@ posix_spawn_ctx_janitor_thread(xlator_t *this)
}
unlock:
UNLOCK(&priv->lock);
+ return ret;
}
static int
@@ -2193,7 +2194,7 @@ abort:
return NULL;
}
-void
+int
posix_spawn_health_check_thread(xlator_t *xl)
{
struct posix_private *priv = NULL;
@@ -2215,7 +2216,7 @@ posix_spawn_health_check_thread(xlator_t *xl)
ret = gf_thread_create(&priv->health_check, NULL,
posix_health_check_thread_proc, xl, "posixhc");
- if (ret < 0) {
+ if (ret) {
priv->health_check_interval = 0;
priv->health_check_active = _gf_false;
gf_msg(xl->name, GF_LOG_ERROR, errno, P_MSG_HEALTHCHECK_FAILED,
@@ -2227,6 +2228,7 @@ posix_spawn_health_check_thread(xlator_t *xl)
}
unlock:
UNLOCK(&priv->lock);
+ return ret;
}
void
@@ -2309,7 +2311,7 @@ out:
return NULL;
}
-void
+int
posix_spawn_disk_space_check_thread(xlator_t *xl)
{
struct posix_private *priv = NULL;
@@ -2328,7 +2330,7 @@ posix_spawn_disk_space_check_thread(xlator_t *xl)
ret = gf_thread_create(&priv->disk_space_check, NULL,
posix_disk_space_check_thread_proc, xl,
"posix_reserve");
- if (ret < 0) {
+ if (ret) {
priv->disk_space_check_active = _gf_false;
gf_msg(xl->name, GF_LOG_ERROR, errno, P_MSG_DISK_SPACE_CHECK_FAILED,
"unable to setup disk space check thread");
@@ -2339,6 +2341,7 @@ posix_spawn_disk_space_check_thread(xlator_t *xl)
}
unlock:
UNLOCK(&priv->lock);
+ return ret;
}
int