Download raw body.
[PATCH] tog: fix usage of deprecated pthread_yield
On Sun, Sep 19, 2021 at 04:05:59PM +0200, Quentin Rameau wrote:
> The pthread_yield isn't portable, let's use the POSIX equivalent
> instead.
> ---
> Indeed, I had forgotten to add the correct header for sched_yield(),
> that is fixed in this second revision of the patch.
> ---
> tog/tog.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
This change is a no-op on OpenBSD since pthread_yield() is effectively
an alias for sched_yield():
void
pthread_yield(void)
{
sched_yield();
}
Given that, and given that this change helps -portable, I think we should
apply your patch to got.git and let it flow to got-portable.git from there.
Does anyone have concerns about using the sched_yield interface directly?
There's a separate question of whether tog should be using _yield().
See these commits in got.git for more information:
commit 6b8a2b8fcd99c4365b1aa9513c0f0149beac2491
commit 82954512f323c8a2d4f89d51be1e6b0f707b6c3a
Somehow this code depends on yielding. In the long term this code should
probably be rewritten such that yielding isn't necessary in the first place.
> diff --git a/tog/tog.c b/tog/tog.c
> index 5af8f69f..c805748e 100644
> --- a/tog/tog.c
> +++ b/tog/tog.c
> @@ -38,6 +38,7 @@
> #include <pthread.h>
> #include <libgen.h>
> #include <regex.h>
> +#include <sched.h>
>
> #include "got_compat.h"
>
> @@ -848,7 +849,7 @@ view_input(struct tog_view **new, int *done, struct tog_view *view,
> if (errcode)
> return got_error_set_errno(errcode,
> "pthread_mutex_unlock");
> - pthread_yield();
> + sched_yield();
> errcode = pthread_mutex_lock(&tog_mutex);
> if (errcode)
> return got_error_set_errno(errcode,
> --
> 2.33.0
>
>
[PATCH] tog: fix usage of deprecated pthread_yield