Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
a53079e3
Commit
a53079e3
authored
Mar 29, 2022
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change the OS/X workaround for pthread_cond_timedwait() returning EINVAL
parent
5424da94
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
28 deletions
+28
-28
cache_lck.c
bin/varnishd/cache/cache_lck.c
+28
-28
No files found.
bin/varnishd/cache/cache_lck.c
View file @
a53079e3
...
@@ -229,47 +229,47 @@ Lck_CondWaitUntil(pthread_cond_t *cond, struct lock *lck, vtim_real when)
...
@@ -229,47 +229,47 @@ Lck_CondWaitUntil(pthread_cond_t *cond, struct lock *lck, vtim_real when)
struct
ilck
*
ilck
;
struct
ilck
*
ilck
;
struct
timespec
ts
;
struct
timespec
ts
;
AN
(
lck
);
CAST_OBJ_NOTNULL
(
ilck
,
lck
->
priv
,
ILCK_MAGIC
);
AN
(
ilck
->
held
);
assert
(
pthread_equal
(
ilck
->
owner
,
pthread_self
()));
ilck
->
held
=
0
;
if
(
when
==
0
)
{
errno
=
pthread_cond_wait
(
cond
,
&
ilck
->
mtx
);
AZ
(
errno
);
}
else
{
assert
(
when
>
1e9
);
ts
=
VTIM_timespec
(
when
);
assert
(
ts
.
tv_nsec
>=
0
&&
ts
.
tv_nsec
<=
999999999
);
errno
=
pthread_cond_timedwait
(
cond
,
&
ilck
->
mtx
,
&
ts
);
#if defined (__APPLE__)
#if defined (__APPLE__)
/*
/*
* I hate woo-doo programming in all it's forms and all it's
* I hate woo-doo programming in all it's forms and all it's
* manifestations, but for reasons I utterly fail to isolate
* manifestations, but for reasons I utterly fail to isolate,
* yielding here is stops OSX from throwing a EINVAL to the
* OSX sometimes throws an EINVAL.
* pthread_cond_wait(3) call.
*
*
* I have tried very hard to determine if any of the three
* I have tried very hard to determine if any of the three
* arguments are in fact invalid, and found nothing which
* arguments are in fact invalid, and found nothing which
* even hints that it might be the case, and with high probability
* even hints that it might be the case.
* repeating the failed call with the exact same arguments
* will succeed.
*
*
* If you want to dive into this you can trigger the situation
* So far I have yet to see a failure if the exact same
* approx 30% of the time with:
* call is repeated after a very short sleep.
*
*
* cd .../vmods && make -j check
* Calling pthread_yield_np() instead of sleaping /mostly/
* works as well, but still fails sometimes.
*
*
* Env:
* Env:
* Darwin Kernel Version 20.5.0:
* Darwin Kernel Version 20.5.0:
* Sat May 8 05:10:31 PDT 2021;
* Sat May 8 05:10:31 PDT 2021;
* root:xnu-7195.121.3~9/RELEASE_ARM64_T8101 arm64
* root:xnu-7195.121.3~9/RELEASE_ARM64_T8101 arm64
*
*
* 20211027
/phk
* 20220329
/phk
*/
*/
pthread_yield_np
();
if
(
errno
==
EINVAL
)
{
#endif
usleep
(
100
);
AN
(
lck
);
CAST_OBJ_NOTNULL
(
ilck
,
lck
->
priv
,
ILCK_MAGIC
);
AN
(
ilck
->
held
);
assert
(
pthread_equal
(
ilck
->
owner
,
pthread_self
()));
ilck
->
held
=
0
;
if
(
when
==
0
)
{
errno
=
pthread_cond_wait
(
cond
,
&
ilck
->
mtx
);
AZ
(
errno
);
}
else
{
assert
(
when
>
1e9
);
ts
=
VTIM_timespec
(
when
);
assert
(
ts
.
tv_nsec
>=
0
&&
ts
.
tv_nsec
<=
999999999
);
errno
=
pthread_cond_timedwait
(
cond
,
&
ilck
->
mtx
,
&
ts
);
errno
=
pthread_cond_timedwait
(
cond
,
&
ilck
->
mtx
,
&
ts
);
}
#endif
assert
(
errno
==
0
||
assert
(
errno
==
0
||
errno
==
ETIMEDOUT
||
errno
==
ETIMEDOUT
||
errno
==
EINTR
);
errno
==
EINTR
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment