Sending a notification to the main nginx thread

Eran Kornblau eran.kornblau at kaltura.com
Thu Oct 7 15:16:37 UTC 2021


> -----Original Message-----
> From: nginx-devel <nginx-devel-bounces at nginx.org> On Behalf Of Maxim Dounin
> Sent: Thursday, 7 October 2021 16:07
> To: nginx-devel at nginx.org
> Subject: Re: Sending a notification to the main nginx thread
> 
> Hello!
> 
> To re-iterate: inside a "side thread" you are not allowed to call any non-thread-safe libc functions.  It is reasonable to assume this excludes all 3rd party libraries with their own even loops.

This is a valid point. 

I checked it out, with the specific build options I'm using on Linux, these are the non-thread-safe libc functions used by nginx -
(list of all non-thread-safe functions taken from https://man7.org/linux/man-pages/man7/pthreads.7.html, assuming POSIX.1-2008) -

$ (objdump -T /usr/local/nginx/sbin/nginx | grep GLIBC | awk '{print $NF}' ; cat /tmp/libc-non-thread-safe) | sort | uniq -c | grep -vw 1
      2 dlerror
      2 getenv
      2 getgrnam
      2 getpwnam
      2 localtime
      2 strerror

First 4 functions are called only early on nginx startup from what I see, so not relevant in this context.
That leaves me only with strerror & localtime. 

I verified these 2 functions are not used by the specific library I'm linking against.
So, assuming I don't use any nginx functions on the side thread (other than ngx_notify), it feels quite safe to me...

Thanks,

Eran

> --
> Maxim Dounin
> https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmdounin.ru%2F&data=04%7C01%7C%7C90afff8c33b442f4d52808d989936e28%7C0c503748de3f4e2597e26819d53a42b6%7C1%7C0%7C637692088574018462%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=lXE%2FhlbsINRDQkC722mGPme0ChawmmJp%2FVa6IPm2jrg%3D&reserved=0
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmailman.nginx.org%2Fmailman%2Flistinfo%2Fnginx-devel&data=04%7C01%7C%7C90afff8c33b442f4d52808d989936e28%7C0c503748de3f4e2597e26819d53a42b6%7C1%7C0%7C637692088574018462%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=OxEoMCuekC9H3MrYRAF2ZCxYWm%2BrLAs3R45BpQJsZ6w%3D&reserved=0
>


More information about the nginx-devel mailing list