summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Dickson <steved@redhat.com>2016-01-18 09:12:41 -0500
committerSteve Dickson <steved@redhat.com>2016-01-18 09:12:41 -0500
commitb493ff0b2497a3b01409ef603189e65a6f36eea3 (patch)
treed9dca97c4ccded4da5b106f6ab5a6029388851fa
parent18b2357b6d65425018dcc9c1059965d7daf12c30 (diff)
downloadnfs-utils-b493ff0b2497a3b01409ef603189e65a6f36eea3.tar.gz
gssd: Try to join a terminated thread after a short wait.
Use pthread_timedjoin_np() to try to join to a terminated thread. If successful return 0 otherwise return 1 which tells the caller it should do the join Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r--utils/gssd/gssd.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/utils/gssd/gssd.c b/utils/gssd/gssd.c
index 3c425ce..844a7ae 100644
--- a/utils/gssd/gssd.c
+++ b/utils/gssd/gssd.c
@@ -65,6 +65,7 @@
#include <dirent.h>
#include <netdb.h>
#include <event.h>
+#include <time.h>
#include "gssd.h"
#include "err_util.h"
@@ -361,6 +362,28 @@ gssd_destroy_client(struct clnt_info *clp)
static void gssd_scan(void);
+#define JOIN_TIMOUT 1
+
+/*
+ * Try to join a terminated thread after a short wait.
+ * If successful return 0 otherwise return 1 which
+ * tells the caller it should do the join.
+ */
+static int gssd_try_join(pthread_t th)
+{
+ struct timespec ts;
+
+ if (clock_gettime(CLOCK_REALTIME, &ts) < 0) {
+ printerr(1, "clock_gettime failed: %s\n", strerror(errno));
+ return 1;
+ }
+ ts.tv_sec += JOIN_TIMOUT;
+ if (pthread_timedjoin_np(th, NULL, &ts) == 0)
+ return 0;
+
+ printerr(2, "gssd_try_join: no join\n");
+ return 1;
+}
static void
gssd_clnt_gssd_cb(int UNUSED(fd), short UNUSED(which), void *data)
{
@@ -373,7 +396,8 @@ gssd_clnt_gssd_cb(int UNUSED(fd), short UNUSED(which), void *data)
printerr(0, "pthread_create failed: ret %d: %s\n", ret, strerror(errno));
return;
}
- pthread_join(th, NULL);
+ if (gssd_try_join(th))
+ pthread_join(th, NULL);
}
static void
@@ -388,7 +412,8 @@ gssd_clnt_krb5_cb(int UNUSED(fd), short UNUSED(which), void *data)
printerr(0, "pthread_create failed: ret %d: %s\n", ret, strerror(errno));
}
- pthread_join(th, NULL);
+ if (gssd_try_join(th))
+ pthread_join(th, NULL);
}
static struct clnt_info *