[master] a2a17a1b2 Use pthread_equal(3) as POSIX intended.
Poul-Henning Kamp
phk at FreeBSD.org
Mon Feb 22 13:27:07 UTC 2021
commit a2a17a1b2647cbc710899bfe1e9851fd55bae359
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Feb 22 13:23:15 2021 +0000
Use pthread_equal(3) as POSIX intended.
Spotted by: Rasmus Villemoes
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 952dc03ab..7fba1e6f2 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -591,7 +591,7 @@ void BAN_Abandon(struct ban_proto *b);
/* cache_cli.c [CLI] */
extern pthread_t cli_thread;
-#define ASSERT_CLI() do {assert(pthread_self() == cli_thread);} while (0)
+#define ASSERT_CLI() do {assert(pthread_equal(pthread_self(), cli_thread));} while (0)
/* cache_http.c */
unsigned HTTP_estimate(unsigned nhttp);
diff --git a/bin/varnishtest/vtc_barrier.c b/bin/varnishtest/vtc_barrier.c
index 5600401fa..3a83b771d 100644
--- a/bin/varnishtest/vtc_barrier.c
+++ b/bin/varnishtest/vtc_barrier.c
@@ -77,7 +77,7 @@ barrier_new(const char *name, struct vtclog *vl)
ALLOC_OBJ(b, BARRIER_MAGIC);
AN(b);
- if (pthread_self() != vtc_thread)
+ if (!pthread_equal(pthread_self(), vtc_thread))
vtc_fatal(vl,
"Barrier %s can only be created on the top thread", name);
REPLACE(b->name, name);
diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c
index ec4dbda0c..15c1a7371 100644
--- a/bin/varnishtest/vtc_log.c
+++ b/bin/varnishtest/vtc_log.c
@@ -114,7 +114,7 @@ vtc_logfail(void)
{
vtc_error = 2;
- if (pthread_self() != vtc_thread)
+ if (!pthread_equal(pthread_self(), vtc_thread))
pthread_exit(NULL);
else
exit(fail_out());
diff --git a/lib/libvarnish/vev.c b/lib/libvarnish/vev.c
index f6359d38f..f83832c6f 100644
--- a/lib/libvarnish/vev.c
+++ b/lib/libvarnish/vev.c
@@ -221,7 +221,7 @@ VEV_Destroy(struct vev_root **evbp)
struct vev_root *evb;
TAKE_OBJ_NOTNULL(evb, evbp, VEV_BASE_MAGIC);
- assert(evb->thread == pthread_self());
+ assert(pthread_equal(evb->thread, pthread_self()));
free(evb->pfd);
free(evb->pev);
/* XXX: destroy evb->binheap */
@@ -255,7 +255,7 @@ VEV_Start(struct vev_root *evb, struct vev *e)
assert(e->sig >= 0);
assert(e->timeout >= 0.0);
assert(e->fd < 0 || e->fd_flags);
- assert(evb->thread == pthread_self());
+ assert(pthread_equal(evb->thread, pthread_self()));
DBG(evb, "ev_add(%p) fd = %d\n", e, e->fd);
if (vev_get_pfd(evb))
@@ -311,7 +311,7 @@ VEV_Stop(struct vev_root *evb, struct vev *e)
CHECK_OBJ_NOTNULL(e, VEV_MAGIC);
DBG(evb, "ev_del(%p) fd = %d i=%u L=%d\n", e, e->fd, e->__binheap_idx, evb->lpfd);
assert(evb == e->__vevb);
- assert(evb->thread == pthread_self());
+ assert(pthread_equal(evb->thread, pthread_self()));
assert(evb->pev[e->__binheap_idx] == e);
assert(e->__binheap_idx != VBH_NOIDX);
@@ -344,7 +344,7 @@ VEV_Loop(struct vev_root *evb)
int i;
CHECK_OBJ_NOTNULL(evb, VEV_BASE_MAGIC);
- assert(evb->thread == pthread_self());
+ assert(pthread_equal(evb->thread, pthread_self()));
do
i = VEV_Once(evb);
while (i == 1);
@@ -406,7 +406,7 @@ VEV_Once(struct vev_root *evb)
unsigned u;
CHECK_OBJ_NOTNULL(evb, VEV_BASE_MAGIC);
- assert(evb->thread == pthread_self());
+ assert(pthread_equal(evb->thread, pthread_self()));
assert(evb->lpfd < evb->npfd);
if (evb->psig)
More information about the varnish-commit
mailing list