From cbe5af61970052429388737de19dbc7ad03ffa96 Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Thu, 5 Aug 2021 16:47:08 +0300 Subject: libports: Create a notify_port in each bucket This notify port will be used to request & receive Mach notifications. While it is present in the bucket much like any other port, it is not counted in ports_count_bucket () and is not exposed to the user callback in ports_bucket_iterate (). --- libports/create-bucket.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'libports/create-bucket.c') diff --git a/libports/create-bucket.c b/libports/create-bucket.c index 82c00a4b..81fe044c 100644 --- a/libports/create-bucket.c +++ b/libports/create-bucket.c @@ -24,6 +24,15 @@ #include #include +static struct port_class *notify_port_class; +static pthread_once_t init_notify_port_class_once = PTHREAD_ONCE_INIT; + +static void +init_notify_port_class () +{ + notify_port_class = ports_create_class (NULL, NULL); +} + struct port_bucket * ports_create_bucket () { @@ -49,5 +58,19 @@ ports_create_bucket () hurd_ihash_init (&ret->htable, offsetof (struct port_info, hentry)); ret->rpcs = ret->flags = ret->count = 0; _ports_threadpool_init (&ret->threadpool); + + /* Create the notify_port for this bucket. */ + pthread_once (&init_notify_port_class_once, init_notify_port_class); + err = ports_create_port (notify_port_class, ret, + sizeof (struct port_info), + &ret->notify_port); + if (err) + { + hurd_ihash_destroy (&ret->htable); + free (ret); + errno = err; + return NULL; + } + return ret; } -- cgit v1.2.3