diff options
author | Sergey Bugaev <bugaevc@gmail.com> | 2021-08-05 16:47:08 +0300 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2022-08-10 22:12:09 +0200 |
commit | cbe5af61970052429388737de19dbc7ad03ffa96 (patch) | |
tree | 6593266852426d9aa6306414044d902e16b8a230 /libports/create-bucket.c | |
parent | 8db6b70ab6a64ea9b0ac313f2816131a046fbd76 (diff) | |
download | hurd-cbe5af61970052429388737de19dbc7ad03ffa96.tar.gz hurd-cbe5af61970052429388737de19dbc7ad03ffa96.tar.bz2 hurd-cbe5af61970052429388737de19dbc7ad03ffa96.zip |
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 ().
Diffstat (limited to 'libports/create-bucket.c')
-rw-r--r-- | libports/create-bucket.c | 23 |
1 files changed, 23 insertions, 0 deletions
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 <stdlib.h> #include <hurd/ihash.h> +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; } |