regression in libc resolver since 2.9.0

2024-05-05 Thread Bertrand Jacquin
Hi,

Since c886fb58eb56 ("MINOR: server/ip: centralize server ip updates"),
there is a regression with server address resolution made against libc
with getaddrinfo(), specifically when returned address are IPv6 address
with % notation which specifies which interface index to
access given address (useful when destination is link local).

  $ getent ahosts test.lan
  fe80::e742:b272:73e:d652%10 STREAM test.lan
  fe80::e742:b272:73e:d652%10 DGRAM
  fe80::e742:b272:73e:d652%10 RAW
  192.168.115.237 STREAM
  192.168.115.237 DGRAM
  192.168.115.237 RAW

Health check sent to selected destination are failing with the following
error:

  [WARNING]  (97685) : Health check for server backend/test.lan failed, reason: 
Layer4 connection problem, info: "General socket error (Invalid argument)", 
check duration: 0ms, status: 0/2 DOWN.

This happens as now call to connect() no longer include sin6_scope_id
field. Diff between the 2.8.7 and 2.9.7

  -connect(9, {sa_family=AF_INET6, sin6_port=htons(80), sin6_flowinfo=htonl(0), 
inet_pton(AF_INET6, "fe80::e742:b272:73e:d652", _addr), 
sin6_scope_id=if_nametoindex("ve-test.ja3nLv")}, 28) = -1 EINPROGRESS 
(Operation now in progress)
  +connect(9, {sa_family=AF_INET6, sin6_port=htons(80), sin6_flowinfo=htonl(0), 
inet_pton(AF_INET6, "fe80::e742:b272:73e:d652", _addr), sin6_scope_id=0}, 
28) = -1 EINVAL (Invalid argument)

Before c886fb58eb56, srv.addr.__ss_padding contains %10, but not after:

-__ss_padding = 
"\000\000\000\000\000\000\376\200\000\000\000\000\000\000\347B\262r\a>\326R\n", 
'\000' ,
+__ss_padding = 
"\000\000\000\000\000\000\376\200\000\000\000\000\000\000\347B\262r\a>\326R", 
'\000' ,

Note that this particular issue does not happen when USE_GETADDRINFO is
disabled.

Reverting the change made in srv_set_addr_via_libc to original state
(see below) does restore original behaviour.

  int srv_set_addr_via_libc(struct server *srv, int *err_code)
  {
if (str2ip2(srv->hostname, >addr, 1) == NULL) {
  if (err_code)
*err_code |= ERR_WARN;
  return 1;
}
return 0;
  }

It not clear to me why c886fb58eb56 broke previous behaviour only when
USE_GETADDRINFO is enabled as str2ip2() code handling getaddrinfo() has
not been touched for very long time, however it seems changes made in
srv_set_addr_via_libc() should not be necessary as str2ip2() does
in-place update of server address.

Cheers,

-- 
Bertrand


signature.asc
Description: PGP signature


Re: [PATCH 1/3] BUILD: illumos: pthread_getcpuclockid is not available

2024-05-05 Thread Илья Шипицин
updated patches.

I'll address reorg to "compat.h" a bit later, once it is settled in my head

вс, 5 мая 2024 г. в 12:48, Илья Шипицин :

> I will test and send simplified patch, i.e. I'll patch directly clock.c
>
> if we want to move that macro to compat.h, I'd postpone that for some
> investigation
>
> 1) we will need to include "pthread.h" from compat.h (currently it's not
> true)
> 2) we will need to make sure compat.h is included everywhere (I do not see
> that include in clock.c)
>
> вс, 5 мая 2024 г. в 12:24, Willy Tarreau :
>
>> On Sun, May 05, 2024 at 11:15:24AM +0200,  ??? wrote:
>> > ??, 5 ??? 2024 ?. ? 10:42, Willy Tarreau :
>> >
>> > > On Sun, May 05, 2024 at 09:12:41AM +0200, Miroslav Zagorac wrote:
>> > > > On 05. 05. 2024. 08:32, Willy Tarreau wrote:
>> > > > > On Sun, May 05, 2024 at 07:49:55AM +0200,  ??? wrote:
>> > > > >> ??, 5 ??? 2024 ?. ? 02:05, Miroslav Zagorac :
>> > > > >>> I think that this patch is not satisfactory because, for
>> example,
>> > > Solaris
>> > > > >>> 11.4.0.0.1.15.0 (from 2018) has _POSIX_TIMERS and
>> > > _POSIX_THREAD_CPUTIME
>> > > > >>> defined, but does not have the pthread_getcpuclockid() function;
>> > > while
>> > > > >>> solaris
>> > > > >>> 11.4.42.0.0.111.0 (from 2022) has that function.
>> > > > >>>
>> > > > >>
>> > > > >> I'm trying to build on this vmactions/solaris-vm: Use Solaris in
>> > > github
>> > > > >> actions 
>> > > > >> it does not have pthread_getcpuclockid()
>> > > > >
>> > > > > I'm wondering what the point of defining _POSIX_THREAD_CPUTIME
>> can be
>> > > > > then :-/
>> > > > >
>> > > >
>> > > > The pthread_getcpuclockid() function is declared in the include file
>> > > > /usr/include/pthread.h.  The only difference between the two
>> "versions"
>> > > of
>> > > > Solaris 11.4 is that the newer version has a declaration and the
>> older
>> > > one
>> > > > does not.
>> > > >
>> > > > However, _POSIX_THREAD_CPUTIME is defined in the
>> /usr/include/unistd.h
>> > > file as
>> > > > -1 in the UNIX 03 block of options that are not supported in Solaris
>> > > 11.4.
>> > > >
>> > > > /* Unsupported UNIX 03 options */
>> > > > #if defined(_XPG6)
>> > > > ..
>> > > > #define _POSIX_THREAD_CPUTIME (-1)
>> > > > ..
>> > > > #endif
>> > > >
>> > > >
>> > > > An explanation of that definition can be found here:
>> > > >
>> > > > https://docs.oracle.com/cd/E88353_01/html/E37842/unistd-3head.html
>> > > >
>> > > > "If a symbolic constant is defined with the value -1, the option is
>> not
>> > > > supported. Headers, data types, and function interfaces required
>> only
>> > > for the
>> > > > option need not be supplied. An application that attempts to use
>> anything
>> > > > associated only with the option is considered to be requiring an
>> > > extension.
>> > > (...)
>> > >
>> > > Ah excellent, that's quite useful! We're already doing that with
>> > > _POSIX_TIMERS. So I guess one just needs to try this instead:
>> > >
>> > > -#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) &&
>> > > defined(_POSIX_THREAD_CPUTIME
>> > > +#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) &&
>> > > defined(_POSIX_THREAD_CPUTIME && (_POSIX_THREAD_CPUTIME >= 0)
>> > >
>> >
>> > that worked (I added closing bracket after second "defined")
>>
>> Ah yes indeed. Thanks for the test. Do you want to update you patch maybe,
>> since you can test it ?
>>
>> Thanks,
>> Willy
>>
>
From 3cc9c51ae6b22beeaaee89d1e5f69b99c6874f39 Mon Sep 17 00:00:00 2001
From: Ilia Shipitsin 
Date: Sun, 5 May 2024 13:41:32 +0200
Subject: [PATCH 3/3] CI: netbsd: limit scheduled workflow to parent repo only

it is not very useful for most of forks.
---
 .github/workflows/netbsd.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.github/workflows/netbsd.yml b/.github/workflows/netbsd.yml
index ea0345954..6514725e1 100644
--- a/.github/workflows/netbsd.yml
+++ b/.github/workflows/netbsd.yml
@@ -7,6 +7,7 @@ on:
 jobs:
   gcc:
 runs-on: ubuntu-latest
+if: ${{ github.repository_owner == 'haproxy' }}
 permissions:
   contents: read
 steps:
-- 
2.43.0.windows.1

From 3c6b1a9dadfcefad4d94a1ee3a288a2e36865a52 Mon Sep 17 00:00:00 2001
From: Ilia Shipitsin 
Date: Sun, 5 May 2024 13:39:33 +0200
Subject: [PATCH 2/3] CI: add Illumos scheduled workflow

this is very initial build only implementation.
---
 .github/workflows/illumos.yml | 24 
 1 file changed, 24 insertions(+)
 create mode 100644 .github/workflows/illumos.yml

diff --git a/.github/workflows/illumos.yml b/.github/workflows/illumos.yml
new file mode 100644
index 0..b0b5e4852
--- /dev/null
+++ b/.github/workflows/illumos.yml
@@ -0,0 +1,24 @@
+name: Illumos
+
+on:
+  schedule:
+- cron: "0 0 25 * *"
+
+jobs:
+  gcc:
+runs-on: ubuntu-latest
+if: ${{ github.repository_owner == 'haproxy' }}
+permissions:
+  contents: read
+steps:
+  - name: "Checkout repository"
+uses: actions/checkout@v4
+
+  - 

Re: [PATCH 1/3] BUILD: illumos: pthread_getcpuclockid is not available

2024-05-05 Thread Илья Шипицин
I will test and send simplified patch, i.e. I'll patch directly clock.c

if we want to move that macro to compat.h, I'd postpone that for some
investigation

1) we will need to include "pthread.h" from compat.h (currently it's not
true)
2) we will need to make sure compat.h is included everywhere (I do not see
that include in clock.c)

вс, 5 мая 2024 г. в 12:24, Willy Tarreau :

> On Sun, May 05, 2024 at 11:15:24AM +0200,  ??? wrote:
> > ??, 5 ??? 2024 ?. ? 10:42, Willy Tarreau :
> >
> > > On Sun, May 05, 2024 at 09:12:41AM +0200, Miroslav Zagorac wrote:
> > > > On 05. 05. 2024. 08:32, Willy Tarreau wrote:
> > > > > On Sun, May 05, 2024 at 07:49:55AM +0200,  ??? wrote:
> > > > >> ??, 5 ??? 2024 ?. ? 02:05, Miroslav Zagorac :
> > > > >>> I think that this patch is not satisfactory because, for example,
> > > Solaris
> > > > >>> 11.4.0.0.1.15.0 (from 2018) has _POSIX_TIMERS and
> > > _POSIX_THREAD_CPUTIME
> > > > >>> defined, but does not have the pthread_getcpuclockid() function;
> > > while
> > > > >>> solaris
> > > > >>> 11.4.42.0.0.111.0 (from 2022) has that function.
> > > > >>>
> > > > >>
> > > > >> I'm trying to build on this vmactions/solaris-vm: Use Solaris in
> > > github
> > > > >> actions 
> > > > >> it does not have pthread_getcpuclockid()
> > > > >
> > > > > I'm wondering what the point of defining _POSIX_THREAD_CPUTIME can
> be
> > > > > then :-/
> > > > >
> > > >
> > > > The pthread_getcpuclockid() function is declared in the include file
> > > > /usr/include/pthread.h.  The only difference between the two
> "versions"
> > > of
> > > > Solaris 11.4 is that the newer version has a declaration and the
> older
> > > one
> > > > does not.
> > > >
> > > > However, _POSIX_THREAD_CPUTIME is defined in the
> /usr/include/unistd.h
> > > file as
> > > > -1 in the UNIX 03 block of options that are not supported in Solaris
> > > 11.4.
> > > >
> > > > /* Unsupported UNIX 03 options */
> > > > #if defined(_XPG6)
> > > > ..
> > > > #define _POSIX_THREAD_CPUTIME (-1)
> > > > ..
> > > > #endif
> > > >
> > > >
> > > > An explanation of that definition can be found here:
> > > >
> > > > https://docs.oracle.com/cd/E88353_01/html/E37842/unistd-3head.html
> > > >
> > > > "If a symbolic constant is defined with the value -1, the option is
> not
> > > > supported. Headers, data types, and function interfaces required only
> > > for the
> > > > option need not be supplied. An application that attempts to use
> anything
> > > > associated only with the option is considered to be requiring an
> > > extension.
> > > (...)
> > >
> > > Ah excellent, that's quite useful! We're already doing that with
> > > _POSIX_TIMERS. So I guess one just needs to try this instead:
> > >
> > > -#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) &&
> > > defined(_POSIX_THREAD_CPUTIME
> > > +#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) &&
> > > defined(_POSIX_THREAD_CPUTIME && (_POSIX_THREAD_CPUTIME >= 0)
> > >
> >
> > that worked (I added closing bracket after second "defined")
>
> Ah yes indeed. Thanks for the test. Do you want to update you patch maybe,
> since you can test it ?
>
> Thanks,
> Willy
>


Re: [PATCH 1/3] BUILD: illumos: pthread_getcpuclockid is not available

2024-05-05 Thread Willy Tarreau
On Sun, May 05, 2024 at 11:15:24AM +0200,  ??? wrote:
> ??, 5 ??? 2024 ?. ? 10:42, Willy Tarreau :
> 
> > On Sun, May 05, 2024 at 09:12:41AM +0200, Miroslav Zagorac wrote:
> > > On 05. 05. 2024. 08:32, Willy Tarreau wrote:
> > > > On Sun, May 05, 2024 at 07:49:55AM +0200,  ??? wrote:
> > > >> ??, 5 ??? 2024 ?. ? 02:05, Miroslav Zagorac :
> > > >>> I think that this patch is not satisfactory because, for example,
> > Solaris
> > > >>> 11.4.0.0.1.15.0 (from 2018) has _POSIX_TIMERS and
> > _POSIX_THREAD_CPUTIME
> > > >>> defined, but does not have the pthread_getcpuclockid() function;
> > while
> > > >>> solaris
> > > >>> 11.4.42.0.0.111.0 (from 2022) has that function.
> > > >>>
> > > >>
> > > >> I'm trying to build on this vmactions/solaris-vm: Use Solaris in
> > github
> > > >> actions 
> > > >> it does not have pthread_getcpuclockid()
> > > >
> > > > I'm wondering what the point of defining _POSIX_THREAD_CPUTIME can be
> > > > then :-/
> > > >
> > >
> > > The pthread_getcpuclockid() function is declared in the include file
> > > /usr/include/pthread.h.  The only difference between the two "versions"
> > of
> > > Solaris 11.4 is that the newer version has a declaration and the older
> > one
> > > does not.
> > >
> > > However, _POSIX_THREAD_CPUTIME is defined in the /usr/include/unistd.h
> > file as
> > > -1 in the UNIX 03 block of options that are not supported in Solaris
> > 11.4.
> > >
> > > /* Unsupported UNIX 03 options */
> > > #if defined(_XPG6)
> > > ..
> > > #define _POSIX_THREAD_CPUTIME (-1)
> > > ..
> > > #endif
> > >
> > >
> > > An explanation of that definition can be found here:
> > >
> > > https://docs.oracle.com/cd/E88353_01/html/E37842/unistd-3head.html
> > >
> > > "If a symbolic constant is defined with the value -1, the option is not
> > > supported. Headers, data types, and function interfaces required only
> > for the
> > > option need not be supplied. An application that attempts to use anything
> > > associated only with the option is considered to be requiring an
> > extension.
> > (...)
> >
> > Ah excellent, that's quite useful! We're already doing that with
> > _POSIX_TIMERS. So I guess one just needs to try this instead:
> >
> > -#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) &&
> > defined(_POSIX_THREAD_CPUTIME
> > +#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) &&
> > defined(_POSIX_THREAD_CPUTIME && (_POSIX_THREAD_CPUTIME >= 0)
> >
> 
> that worked (I added closing bracket after second "defined")

Ah yes indeed. Thanks for the test. Do you want to update you patch maybe,
since you can test it ?

Thanks,
Willy



Re: [PATCH 1/3] BUILD: illumos: pthread_getcpuclockid is not available

2024-05-05 Thread Илья Шипицин
вс, 5 мая 2024 г. в 10:42, Willy Tarreau :

> On Sun, May 05, 2024 at 09:12:41AM +0200, Miroslav Zagorac wrote:
> > On 05. 05. 2024. 08:32, Willy Tarreau wrote:
> > > On Sun, May 05, 2024 at 07:49:55AM +0200,  ??? wrote:
> > >> ??, 5 ??? 2024 ?. ? 02:05, Miroslav Zagorac :
> > >>> I think that this patch is not satisfactory because, for example,
> Solaris
> > >>> 11.4.0.0.1.15.0 (from 2018) has _POSIX_TIMERS and
> _POSIX_THREAD_CPUTIME
> > >>> defined, but does not have the pthread_getcpuclockid() function;
> while
> > >>> solaris
> > >>> 11.4.42.0.0.111.0 (from 2022) has that function.
> > >>>
> > >>
> > >> I'm trying to build on this vmactions/solaris-vm: Use Solaris in
> github
> > >> actions 
> > >> it does not have pthread_getcpuclockid()
> > >
> > > I'm wondering what the point of defining _POSIX_THREAD_CPUTIME can be
> > > then :-/
> > >
> >
> > The pthread_getcpuclockid() function is declared in the include file
> > /usr/include/pthread.h.  The only difference between the two "versions"
> of
> > Solaris 11.4 is that the newer version has a declaration and the older
> one
> > does not.
> >
> > However, _POSIX_THREAD_CPUTIME is defined in the /usr/include/unistd.h
> file as
> > -1 in the UNIX 03 block of options that are not supported in Solaris
> 11.4.
> >
> > /* Unsupported UNIX 03 options */
> > #if defined(_XPG6)
> > ..
> > #define _POSIX_THREAD_CPUTIME (-1)
> > ..
> > #endif
> >
> >
> > An explanation of that definition can be found here:
> >
> > https://docs.oracle.com/cd/E88353_01/html/E37842/unistd-3head.html
> >
> > "If a symbolic constant is defined with the value -1, the option is not
> > supported. Headers, data types, and function interfaces required only
> for the
> > option need not be supplied. An application that attempts to use anything
> > associated only with the option is considered to be requiring an
> extension.
> (...)
>
> Ah excellent, that's quite useful! We're already doing that with
> _POSIX_TIMERS. So I guess one just needs to try this instead:
>
> -#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) &&
> defined(_POSIX_THREAD_CPUTIME
> +#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) &&
> defined(_POSIX_THREAD_CPUTIME && (_POSIX_THREAD_CPUTIME >= 0)
>

that worked (I added closing bracket after second "defined")


>
> Please note that it appears at a few places, so we'll probably have to
> move that painful definition in compat.h I think.
>


that makes sense


>
> Willy
>


Re: [PATCH 1/3] BUILD: illumos: pthread_getcpuclockid is not available

2024-05-05 Thread Willy Tarreau
On Sun, May 05, 2024 at 09:12:41AM +0200, Miroslav Zagorac wrote:
> On 05. 05. 2024. 08:32, Willy Tarreau wrote:
> > On Sun, May 05, 2024 at 07:49:55AM +0200,  ??? wrote:
> >> ??, 5 ??? 2024 ?. ? 02:05, Miroslav Zagorac :
> >>> I think that this patch is not satisfactory because, for example, Solaris
> >>> 11.4.0.0.1.15.0 (from 2018) has _POSIX_TIMERS and _POSIX_THREAD_CPUTIME
> >>> defined, but does not have the pthread_getcpuclockid() function; while
> >>> solaris
> >>> 11.4.42.0.0.111.0 (from 2022) has that function.
> >>>
> >>
> >> I'm trying to build on this vmactions/solaris-vm: Use Solaris in github
> >> actions 
> >> it does not have pthread_getcpuclockid()
> > 
> > I'm wondering what the point of defining _POSIX_THREAD_CPUTIME can be
> > then :-/
> > 
> 
> The pthread_getcpuclockid() function is declared in the include file
> /usr/include/pthread.h.  The only difference between the two "versions" of
> Solaris 11.4 is that the newer version has a declaration and the older one
> does not.
> 
> However, _POSIX_THREAD_CPUTIME is defined in the /usr/include/unistd.h file as
> -1 in the UNIX 03 block of options that are not supported in Solaris 11.4.
> 
> /* Unsupported UNIX 03 options */
> #if defined(_XPG6)
> ..
> #define _POSIX_THREAD_CPUTIME (-1)
> ..
> #endif
> 
> 
> An explanation of that definition can be found here:
> 
> https://docs.oracle.com/cd/E88353_01/html/E37842/unistd-3head.html
> 
> "If a symbolic constant is defined with the value -1, the option is not
> supported. Headers, data types, and function interfaces required only for the
> option need not be supplied. An application that attempts to use anything
> associated only with the option is considered to be requiring an extension.
(...)

Ah excellent, that's quite useful! We're already doing that with
_POSIX_TIMERS. So I guess one just needs to try this instead:

-#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) && 
defined(_POSIX_THREAD_CPUTIME
+#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) && 
defined(_POSIX_THREAD_CPUTIME && (_POSIX_THREAD_CPUTIME >= 0)

Please note that it appears at a few places, so we'll probably have to
move that painful definition in compat.h I think.

Willy



Re: [PATCH 1/3] BUILD: illumos: pthread_getcpuclockid is not available

2024-05-05 Thread Willy Tarreau
On Sun, May 05, 2024 at 08:52:08AM +0200,  ??? wrote:
> > I'm wondering what the point of defining _POSIX_THREAD_CPUTIME can be
> > then :-/
> >
> > Just guessing, are you sure you're building with -pthread -lrt ? Just in
> > case, please double-check with V=1. Solaris sets USE_RT, but maybe
> > something
> > else is needed.
> >
> 
> I did "find / -name pthread.h -exec cat {} ';' -print"
> and there was not declaration of pthread_getcpuclockid()
> 
> chances are that it is shipped in a lib, but the prototype is missing ...

Ah I had the impression based on your error output that the definition
was there and it was only the lib that was missing. Maybe I misread
but it looked like a link error.

Willy



Re: [PATCH 1/3] BUILD: illumos: pthread_getcpuclockid is not available

2024-05-05 Thread Miroslav Zagorac
On 05. 05. 2024. 08:32, Willy Tarreau wrote:
> On Sun, May 05, 2024 at 07:49:55AM +0200,  ??? wrote:
>> ??, 5 ??? 2024 ?. ? 02:05, Miroslav Zagorac :
>>> I think that this patch is not satisfactory because, for example, Solaris
>>> 11.4.0.0.1.15.0 (from 2018) has _POSIX_TIMERS and _POSIX_THREAD_CPUTIME
>>> defined, but does not have the pthread_getcpuclockid() function; while
>>> solaris
>>> 11.4.42.0.0.111.0 (from 2022) has that function.
>>>
>>
>> I'm trying to build on this vmactions/solaris-vm: Use Solaris in github
>> actions 
>> it does not have pthread_getcpuclockid()
> 
> I'm wondering what the point of defining _POSIX_THREAD_CPUTIME can be
> then :-/
> 

The pthread_getcpuclockid() function is declared in the include file
/usr/include/pthread.h.  The only difference between the two "versions" of
Solaris 11.4 is that the newer version has a declaration and the older one
does not.

However, _POSIX_THREAD_CPUTIME is defined in the /usr/include/unistd.h file as
-1 in the UNIX 03 block of options that are not supported in Solaris 11.4.

/* Unsupported UNIX 03 options */
#if defined(_XPG6)
..
#define _POSIX_THREAD_CPUTIME (-1)
..
#endif


An explanation of that definition can be found here:

https://docs.oracle.com/cd/E88353_01/html/E37842/unistd-3head.html

"If a symbolic constant is defined with the value -1, the option is not
supported. Headers, data types, and function interfaces required only for the
option need not be supplied. An application that attempts to use anything
associated only with the option is considered to be requiring an extension.

If a symbolic constant is defined with a value greater than zero, the option
is always supported when the application is executed. All headers, data types,
and functions are present and operate as specified.

If a symbolic constant is defined with the value zero, all headers, data
types, and functions are present. The application can check at runtime to see
whether the option is supported by calling fpathconf(), pathconf(), or
sysconf() with the indicated name parameter."

-- 
Miroslav Zagorac

What can change the nature of a man?



Re: [PATCH 1/3] BUILD: illumos: pthread_getcpuclockid is not available

2024-05-05 Thread Илья Шипицин
вс, 5 мая 2024 г. в 08:32, Willy Tarreau :

> On Sun, May 05, 2024 at 07:49:55AM +0200,  ??? wrote:
> > ??, 5 ??? 2024 ?. ? 02:05, Miroslav Zagorac :
> >
> > > On 04. 05. 2024. 17:36, Ilya Shipitsin wrote:
> > > > this function is considered optional for POSIX and not implemented
> > > > on Illumos
> > > >
> > > > Reference:
> > >
> https://www.gnu.org/software/gnulib/manual/html_node/pthread_005fgetcpuclockid.html
> > > > According to
> > > https://github.com/cpredef/predef/blob/master/OperatingSystems.md
> Illumos
> > > > is identified by __illumos__ macro available since gcc-11
> > > > ---
> > > >  src/clock.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/src/clock.c b/src/clock.c
> > > > index ec2133c8b..f484c2d9c 100644
> > > > --- a/src/clock.c
> > > > +++ b/src/clock.c
> > > > @@ -135,7 +135,7 @@ uint64_t now_cpu_time_thread(int thr)
> > > >  /* set the clock source for the local thread */
> > > >  void clock_set_local_source(void)
> > > >  {
> > > > -#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) &&
> > > defined(_POSIX_THREAD_CPUTIME)
> > > > +#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) &&
> > > defined(_POSIX_THREAD_CPUTIME) && !defined(__illumos__)
> > > >  #ifdef USE_THREAD
> > > >   pthread_getcpuclockid(pthread_self(),
> _thread_clock_id[tid]);
> > > >  #else
> > >
> > > Hello Ilya,
> > >
> > > I think that this patch is not satisfactory because, for example,
> Solaris
> > > 11.4.0.0.1.15.0 (from 2018) has _POSIX_TIMERS and _POSIX_THREAD_CPUTIME
> > > defined, but does not have the pthread_getcpuclockid() function; while
> > > solaris
> > > 11.4.42.0.0.111.0 (from 2022) has that function.
> > >
> >
> > I'm trying to build on this vmactions/solaris-vm: Use Solaris in github
> > actions 
> > it does not have pthread_getcpuclockid()
>
> I'm wondering what the point of defining _POSIX_THREAD_CPUTIME can be
> then :-/
>
> Just guessing, are you sure you're building with -pthread -lrt ? Just in
> case, please double-check with V=1. Solaris sets USE_RT, but maybe
> something
> else is needed.
>

I did "find / -name pthread.h -exec cat {} ';' -print"
and there was not declaration of pthread_getcpuclockid()

chances are that it is shipped in a lib, but the prototype is missing ...


>
> Willy
>


Re: [PATCH 1/3] BUILD: illumos: pthread_getcpuclockid is not available

2024-05-05 Thread Willy Tarreau
On Sun, May 05, 2024 at 07:49:55AM +0200,  ??? wrote:
> ??, 5 ??? 2024 ?. ? 02:05, Miroslav Zagorac :
> 
> > On 04. 05. 2024. 17:36, Ilya Shipitsin wrote:
> > > this function is considered optional for POSIX and not implemented
> > > on Illumos
> > >
> > > Reference:
> > https://www.gnu.org/software/gnulib/manual/html_node/pthread_005fgetcpuclockid.html
> > > According to
> > https://github.com/cpredef/predef/blob/master/OperatingSystems.md Illumos
> > > is identified by __illumos__ macro available since gcc-11
> > > ---
> > >  src/clock.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/src/clock.c b/src/clock.c
> > > index ec2133c8b..f484c2d9c 100644
> > > --- a/src/clock.c
> > > +++ b/src/clock.c
> > > @@ -135,7 +135,7 @@ uint64_t now_cpu_time_thread(int thr)
> > >  /* set the clock source for the local thread */
> > >  void clock_set_local_source(void)
> > >  {
> > > -#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) &&
> > defined(_POSIX_THREAD_CPUTIME)
> > > +#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) &&
> > defined(_POSIX_THREAD_CPUTIME) && !defined(__illumos__)
> > >  #ifdef USE_THREAD
> > >   pthread_getcpuclockid(pthread_self(), _thread_clock_id[tid]);
> > >  #else
> >
> > Hello Ilya,
> >
> > I think that this patch is not satisfactory because, for example, Solaris
> > 11.4.0.0.1.15.0 (from 2018) has _POSIX_TIMERS and _POSIX_THREAD_CPUTIME
> > defined, but does not have the pthread_getcpuclockid() function; while
> > solaris
> > 11.4.42.0.0.111.0 (from 2022) has that function.
> >
> 
> I'm trying to build on this vmactions/solaris-vm: Use Solaris in github
> actions 
> it does not have pthread_getcpuclockid()

I'm wondering what the point of defining _POSIX_THREAD_CPUTIME can be
then :-/

Just guessing, are you sure you're building with -pthread -lrt ? Just in
case, please double-check with V=1. Solaris sets USE_RT, but maybe something
else is needed.

Willy