diff -pruN 1:3.24-1.1/debian/changelog 1:3.24-1.1ubuntu1/debian/changelog
--- 1:3.24-1.1/debian/changelog	2023-05-23 00:06:05.000000000 +0000
+++ 1:3.24-1.1ubuntu1/debian/changelog	2023-05-23 00:06:05.000000000 +0000
@@ -1,3 +1,11 @@
+nbd (1:3.24-1.1ubuntu1) mantic; urgency=medium
+
+  * cherry-pick patches 3cb679f4a97e1a54a7285ee1f22e2888c9d3b900 and
+    a10d07b43fe5169cd295604632faf6a08c52f75b from upstream git HEAD to
+    fix operation with glib >= 2.76.0. LP: #2019852.
+
+ -- Wouter Verhelst <wouter@debian.org>  Fri, 19 May 2023 10:38:13 +0200
+
 nbd (1:3.24-1.1) unstable; urgency=medium
 
   * Non-maintainer upload with maintainer permission.
diff -pruN 1:3.24-1.1/debian/control 1:3.24-1.1ubuntu1/debian/control
--- 1:3.24-1.1/debian/control	2023-05-23 00:06:05.000000000 +0000
+++ 1:3.24-1.1ubuntu1/debian/control	2023-05-23 00:06:05.000000000 +0000
@@ -1,7 +1,8 @@
 Source: nbd
 Section: admin
 Priority: optional
-Maintainer: Wouter Verhelst <wouter@debian.org>
+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
+XSBC-Original-Maintainer: Wouter Verhelst <wouter@debian.org>
 Build-Depends: debhelper-compat (= 12), libglib2.0-dev (>= 2.26.0), libgnutls28-dev, libnl-genl-3-dev [linux-any], docbook-utils, autoconf-archive, bison, flex
 Standards-Version: 4.1.3
 Vcs-Git: https://salsa.debian.org/wouter/nbd.git
diff -pruN 1:3.24-1.1/nbd-server.c 1:3.24-1.1ubuntu1/nbd-server.c
--- 1:3.24-1.1/nbd-server.c	2022-03-07 08:37:11.000000000 +0000
+++ 1:3.24-1.1ubuntu1/nbd-server.c	2023-05-23 00:06:05.000000000 +0000
@@ -200,7 +200,7 @@ char default_authname[] = SYSCONFDIR "/n
 #include <nbdsrv.h>
 
 /* Our thread pool */
-GThreadPool *tpool;
+GThreadPool *tpool = NULL;
 
 /* A work package for the thread pool functions */
 struct work_package {
@@ -2895,7 +2895,6 @@ static int mainloop_threaded(CLIENT* cli
 		req->type = ntohl(req->type);
 		req->len = ntohl(req->len);
 
-
 		if(req->magic != htonl(NBD_REQUEST_MAGIC))
 			err("Protocol error: not enough magic.");
 
@@ -2934,9 +2933,7 @@ void destroy_pid_t(gpointer data) {
 	g_free(data);
 }
 
-static pid_t
-spawn_child(int* socket)
-{
+static pid_t spawn_child(int* socket) {
         pid_t pid;
         sigset_t newset;
         sigset_t oldset;
@@ -3019,6 +3016,7 @@ handle_modern_connection(GArray *const s
                 }
                 /* Child just continues. */
         }
+	tpool = g_thread_pool_new(handle_request, NULL, genconf->threads, FALSE, NULL);
 
         sock_flags_old = fcntl(net, F_GETFL, 0);
         if (sock_flags_old == -1) {
@@ -3151,11 +3149,11 @@ static int append_new_servers(GArray *co
         int retval = -1;
 
         new_servers = parse_cfile(config_file_pos, genconf, true, gerror);
-        g_thread_pool_set_max_threads(tpool, genconf->threads, NULL);
-        if (!new_servers)
+        if(tpool) g_thread_pool_set_max_threads(tpool, genconf->threads, NULL);
+        if(!new_servers)
                 goto out;
 
-        for (i = 0; i < new_servers->len; ++i) {
+        for(i = 0; i < new_servers->len; ++i) {
                 SERVER *new_server = g_array_index(new_servers, SERVER*, i);
 
                 if (new_server->servename
@@ -3704,7 +3702,6 @@ int main(int argc, char *argv[]) {
 #if HAVE_OLD_GLIB
 	g_thread_init(NULL);
 #endif
-	tpool = g_thread_pool_new(handle_request, NULL, genconf.threads, FALSE, NULL);
 
 	setup_servers(servers, genconf.modernaddr, genconf.modernport,
 			genconf.unixsock, genconf.flags);
@@ -3733,6 +3730,7 @@ int main(int argc, char *argv[]) {
 		if(!client) {
 			exit(EXIT_FAILURE);
 		}
+		tpool = g_thread_pool_new(handle_request, NULL, genconf.threads, FALSE, NULL);
 		mainloop_threaded(client);
 		return 0;
 	}
