Mailing List Archive

[master] e1da1915e Attempt to use `pthread_condattr_setclock(&ca, CLOCK_MONOTONIC)`
commit e1da1915e8966ad38dd327b8728fd3f00557b83a
Author: Poul-Henning Kamp <phk@FreeBSD.org>
Date: Mon Oct 11 21:40:22 2021 +0000

Attempt to use `pthread_condattr_setclock(&ca, CLOCK_MONOTONIC)`

diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c
index 539245305..365ac2a84 100644
--- a/bin/varnishhist/varnishhist.c
+++ b/bin/varnishhist/varnishhist.c
@@ -366,9 +366,8 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[],
vsl_to = vsl_t0 + (t - t0) * timebend;

if (vsl_ts > vsl_to) {
- double when = VTIM_real() + vsl_ts - vsl_to;
struct timespec ts;
- ts.tv_nsec = (long)(modf(when, &t) * 1e9);
+ ts.tv_nsec = (long)(modf(vsl_ts - vsl_to, &t) * 1e9);
ts.tv_sec = (long)t;
i = pthread_cond_timedwait(&timebend_cv, &mtx, &ts);
assert(i == 0 || i == ETIMEDOUT);
@@ -487,9 +486,12 @@ main(int argc, char **argv)
pthread_t thr;
int fnum;
struct profile cli_p = {0};
+ pthread_condattr_t ca;

vut = VUT_InitProg(argc, argv, &vopt_spec);
AN(vut);
+ AZ(pthread_condattr_init(&ca));
+ AZ(pthread_condattr_setclock(&ca, CLOCK_MONOTONIC));
AZ(pthread_cond_init(&timebend_cv, NULL));

while ((i = getopt(argc, argv, vopt_spec.vopt_optstring)) != -1) {
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit
Re: [master] e1da1915e Attempt to use `pthread_condattr_setclock(&ca, CLOCK_MONOTONIC)` [ In reply to ]
On Mon, Oct 11, 2021 at 9:41 PM Poul-Henning Kamp <phk@freebsd.org> wrote:
>
>
> commit e1da1915e8966ad38dd327b8728fd3f00557b83a
> Author: Poul-Henning Kamp <phk@FreeBSD.org>
> Date: Mon Oct 11 21:40:22 2021 +0000
>
> Attempt to use `pthread_condattr_setclock(&ca, CLOCK_MONOTONIC)`
>
> diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c
> index 539245305..365ac2a84 100644
> --- a/bin/varnishhist/varnishhist.c
> +++ b/bin/varnishhist/varnishhist.c
> @@ -366,9 +366,8 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[],
> vsl_to = vsl_t0 + (t - t0) * timebend;
>
> if (vsl_ts > vsl_to) {
> - double when = VTIM_real() + vsl_ts - vsl_to;
> struct timespec ts;
> - ts.tv_nsec = (long)(modf(when, &t) * 1e9);
> + ts.tv_nsec = (long)(modf(vsl_ts - vsl_to, &t) * 1e9);
> ts.tv_sec = (long)t;
> i = pthread_cond_timedwait(&timebend_cv, &mtx, &ts);
> assert(i == 0 || i == ETIMEDOUT);
> @@ -487,9 +486,12 @@ main(int argc, char **argv)
> pthread_t thr;
> int fnum;
> struct profile cli_p = {0};
> + pthread_condattr_t ca;
>
> vut = VUT_InitProg(argc, argv, &vopt_spec);
> AN(vut);
> + AZ(pthread_condattr_init(&ca));
> + AZ(pthread_condattr_setclock(&ca, CLOCK_MONOTONIC));
> AZ(pthread_cond_init(&timebend_cv, NULL));

Did you forget to pass ca to pthread_cond_init() ?
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit
Re: [master] e1da1915e Attempt to use `pthread_condattr_setclock(&ca, CLOCK_MONOTONIC)` [ In reply to ]
--------
Dridi Boukelmoune writes:

> > + AZ(pthread_condattr_init(&ca));
> > + AZ(pthread_condattr_setclock(&ca, CLOCK_MONOTONIC));
> > AZ(pthread_cond_init(&timebend_cv, NULL));
>
> Did you forget to pass ca to pthread_cond_init() ?

I guess I did...

--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit