Index: uspace/lib/ipcgfx/test/ipcgfx.c
===================================================================
--- uspace/lib/ipcgfx/test/ipcgfx.c	(revision 7470d97aaec04abd08ce2ad450cda9e6ff912bd4)
+++ uspace/lib/ipcgfx/test/ipcgfx.c	(revision 4c6fd56b8079778d8d40e0d5ffc6a1e8e8ad2b5b)
@@ -1,4 +1,4 @@
 /*
- * Copyright (c) 2021 Jiri Svoboda
+ * Copyright (c) 2023 Jiri Svoboda
  * All rights reserved.
  *
@@ -120,12 +120,13 @@
 	async_sess_t *sess;
 	ipc_gc_t *ipcgc;
-
-	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
-
-	// FIXME This causes this test to be non-reentrant!
-	rc = loc_server_register(test_ipcgfx_server);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = loc_service_register(test_ipcgfx_svc, &sid);
+	loc_srv_t *srv;
+
+	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
+
+	// FIXME This causes this test to be non-reentrant!
+	rc = loc_server_register(test_ipcgfx_server, &srv);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = loc_service_register(srv, test_ipcgfx_svc, &sid);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -156,6 +157,7 @@
 	async_hangup(sess);
 
-	rc = loc_service_unregister(sid);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	rc = loc_service_unregister(srv, sid);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	loc_server_unregister(srv);
 }
 
@@ -170,12 +172,13 @@
 	async_sess_t *sess;
 	ipc_gc_t *ipcgc;
-
-	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
-
-	// FIXME This causes this test to be non-reentrant!
-	rc = loc_server_register(test_ipcgfx_server);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = loc_service_register(test_ipcgfx_svc, &sid);
+	loc_srv_t *srv;
+
+	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
+
+	// FIXME This causes this test to be non-reentrant!
+	rc = loc_server_register(test_ipcgfx_server, &srv);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = loc_service_register(srv, test_ipcgfx_svc, &sid);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -207,6 +210,7 @@
 	async_hangup(sess);
 
-	rc = loc_service_unregister(sid);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	rc = loc_service_unregister(srv, sid);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	loc_server_unregister(srv);
 }
 
@@ -220,12 +224,13 @@
 	async_sess_t *sess;
 	ipc_gc_t *ipcgc;
-
-	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
-
-	// FIXME This causes this test to be non-reentrant!
-	rc = loc_server_register(test_ipcgfx_server);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = loc_service_register(test_ipcgfx_svc, &sid);
+	loc_srv_t *srv;
+
+	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
+
+	// FIXME This causes this test to be non-reentrant!
+	rc = loc_server_register(test_ipcgfx_server, &srv);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = loc_service_register(srv, test_ipcgfx_svc, &sid);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -250,6 +255,7 @@
 	async_hangup(sess);
 
-	rc = loc_service_unregister(sid);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	rc = loc_service_unregister(srv, sid);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	loc_server_unregister(srv);
 }
 
@@ -264,12 +270,13 @@
 	async_sess_t *sess;
 	ipc_gc_t *ipcgc;
-
-	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
-
-	// FIXME This causes this test to be non-reentrant!
-	rc = loc_server_register(test_ipcgfx_server);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = loc_service_register(test_ipcgfx_svc, &sid);
+	loc_srv_t *srv;
+
+	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
+
+	// FIXME This causes this test to be non-reentrant!
+	rc = loc_server_register(test_ipcgfx_server, &srv);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = loc_service_register(srv, test_ipcgfx_svc, &sid);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -300,6 +307,7 @@
 	async_hangup(sess);
 
-	rc = loc_service_unregister(sid);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	rc = loc_service_unregister(srv, sid);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	loc_server_unregister(srv);
 }
 
@@ -314,12 +322,13 @@
 	async_sess_t *sess;
 	ipc_gc_t *ipcgc;
-
-	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
-
-	// FIXME This causes this test to be non-reentrant!
-	rc = loc_server_register(test_ipcgfx_server);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = loc_service_register(test_ipcgfx_svc, &sid);
+	loc_srv_t *srv;
+
+	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
+
+	// FIXME This causes this test to be non-reentrant!
+	rc = loc_server_register(test_ipcgfx_server, &srv);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = loc_service_register(srv, test_ipcgfx_svc, &sid);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -350,6 +359,7 @@
 	async_hangup(sess);
 
-	rc = loc_service_unregister(sid);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	rc = loc_service_unregister(srv, sid);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	loc_server_unregister(srv);
 }
 
@@ -364,12 +374,13 @@
 	async_sess_t *sess;
 	ipc_gc_t *ipcgc;
-
-	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
-
-	// FIXME This causes this test to be non-reentrant!
-	rc = loc_server_register(test_ipcgfx_server);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = loc_service_register(test_ipcgfx_svc, &sid);
+	loc_srv_t *srv;
+
+	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
+
+	// FIXME This causes this test to be non-reentrant!
+	rc = loc_server_register(test_ipcgfx_server, &srv);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = loc_service_register(srv, test_ipcgfx_svc, &sid);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -400,6 +411,7 @@
 	async_hangup(sess);
 
-	rc = loc_service_unregister(sid);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	rc = loc_service_unregister(srv, sid);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	loc_server_unregister(srv);
 }
 
@@ -414,12 +426,13 @@
 	async_sess_t *sess;
 	ipc_gc_t *ipcgc;
-
-	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
-
-	// FIXME This causes this test to be non-reentrant!
-	rc = loc_server_register(test_ipcgfx_server);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = loc_service_register(test_ipcgfx_svc, &sid);
+	loc_srv_t *srv;
+
+	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
+
+	// FIXME This causes this test to be non-reentrant!
+	rc = loc_server_register(test_ipcgfx_server, &srv);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = loc_service_register(srv, test_ipcgfx_svc, &sid);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -450,6 +463,7 @@
 	async_hangup(sess);
 
-	rc = loc_service_unregister(sid);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	rc = loc_service_unregister(srv, sid);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	loc_server_unregister(srv);
 }
 
@@ -463,12 +477,13 @@
 	async_sess_t *sess;
 	ipc_gc_t *ipcgc;
-
-	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
-
-	// FIXME This causes this test to be non-reentrant!
-	rc = loc_server_register(test_ipcgfx_server);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = loc_service_register(test_ipcgfx_svc, &sid);
+	loc_srv_t *srv;
+
+	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
+
+	// FIXME This causes this test to be non-reentrant!
+	rc = loc_server_register(test_ipcgfx_server, &srv);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = loc_service_register(srv, test_ipcgfx_svc, &sid);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -491,6 +506,7 @@
 	async_hangup(sess);
 
-	rc = loc_service_unregister(sid);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	rc = loc_service_unregister(srv, sid);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	loc_server_unregister(srv);
 }
 
@@ -504,12 +520,13 @@
 	async_sess_t *sess;
 	ipc_gc_t *ipcgc;
-
-	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
-
-	// FIXME This causes this test to be non-reentrant!
-	rc = loc_server_register(test_ipcgfx_server);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = loc_service_register(test_ipcgfx_svc, &sid);
+	loc_srv_t *srv;
+
+	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
+
+	// FIXME This causes this test to be non-reentrant!
+	rc = loc_server_register(test_ipcgfx_server, &srv);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = loc_service_register(srv, test_ipcgfx_svc, &sid);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -532,6 +549,7 @@
 	async_hangup(sess);
 
-	rc = loc_service_unregister(sid);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	rc = loc_service_unregister(srv, sid);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	loc_server_unregister(srv);
 }
 
@@ -547,12 +565,13 @@
 	async_sess_t *sess;
 	ipc_gc_t *ipcgc;
-
-	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
-
-	// FIXME This causes this test to be non-reentrant!
-	rc = loc_server_register(test_ipcgfx_server);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = loc_service_register(test_ipcgfx_svc, &sid);
+	loc_srv_t *srv;
+
+	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
+
+	// FIXME This causes this test to be non-reentrant!
+	rc = loc_server_register(test_ipcgfx_server, &srv);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = loc_service_register(srv, test_ipcgfx_svc, &sid);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -591,6 +610,7 @@
 	async_hangup(sess);
 
-	rc = loc_service_unregister(sid);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	rc = loc_service_unregister(srv, sid);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	loc_server_unregister(srv);
 }
 
@@ -606,12 +626,13 @@
 	async_sess_t *sess;
 	ipc_gc_t *ipcgc;
-
-	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
-
-	// FIXME This causes this test to be non-reentrant!
-	rc = loc_server_register(test_ipcgfx_server);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = loc_service_register(test_ipcgfx_svc, &sid);
+	loc_srv_t *srv;
+
+	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
+
+	// FIXME This causes this test to be non-reentrant!
+	rc = loc_server_register(test_ipcgfx_server, &srv);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = loc_service_register(srv, test_ipcgfx_svc, &sid);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -655,6 +676,7 @@
 	async_hangup(sess);
 
-	rc = loc_service_unregister(sid);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	rc = loc_service_unregister(srv, sid);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	loc_server_unregister(srv);
 }
 
@@ -670,12 +692,13 @@
 	async_sess_t *sess;
 	ipc_gc_t *ipcgc;
-
-	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
-
-	// FIXME This causes this test to be non-reentrant!
-	rc = loc_server_register(test_ipcgfx_server);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = loc_service_register(test_ipcgfx_svc, &sid);
+	loc_srv_t *srv;
+
+	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
+
+	// FIXME This causes this test to be non-reentrant!
+	rc = loc_server_register(test_ipcgfx_server, &srv);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = loc_service_register(srv, test_ipcgfx_svc, &sid);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -708,6 +731,7 @@
 	async_hangup(sess);
 
-	rc = loc_service_unregister(sid);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	rc = loc_service_unregister(srv, sid);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	loc_server_unregister(srv);
 }
 
@@ -723,12 +747,13 @@
 	async_sess_t *sess;
 	ipc_gc_t *ipcgc;
-
-	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
-
-	// FIXME This causes this test to be non-reentrant!
-	rc = loc_server_register(test_ipcgfx_server);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = loc_service_register(test_ipcgfx_svc, &sid);
+	loc_srv_t *srv;
+
+	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
+
+	// FIXME This causes this test to be non-reentrant!
+	rc = loc_server_register(test_ipcgfx_server, &srv);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = loc_service_register(srv, test_ipcgfx_svc, &sid);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -768,6 +793,7 @@
 	async_hangup(sess);
 
-	rc = loc_service_unregister(sid);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	rc = loc_service_unregister(srv, sid);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	loc_server_unregister(srv);
 }
 
@@ -783,12 +809,13 @@
 	async_sess_t *sess;
 	ipc_gc_t *ipcgc;
-
-	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
-
-	// FIXME This causes this test to be non-reentrant!
-	rc = loc_server_register(test_ipcgfx_server);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = loc_service_register(test_ipcgfx_svc, &sid);
+	loc_srv_t *srv;
+
+	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
+
+	// FIXME This causes this test to be non-reentrant!
+	rc = loc_server_register(test_ipcgfx_server, &srv);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = loc_service_register(srv, test_ipcgfx_svc, &sid);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -833,6 +860,7 @@
 	async_hangup(sess);
 
-	rc = loc_service_unregister(sid);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	rc = loc_service_unregister(srv, sid);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	loc_server_unregister(srv);
 }
 
@@ -850,12 +878,13 @@
 	async_sess_t *sess;
 	ipc_gc_t *ipcgc;
-
-	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
-
-	// FIXME This causes this test to be non-reentrant!
-	rc = loc_server_register(test_ipcgfx_server);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = loc_service_register(test_ipcgfx_svc, &sid);
+	loc_srv_t *srv;
+
+	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
+
+	// FIXME This causes this test to be non-reentrant!
+	rc = loc_server_register(test_ipcgfx_server, &srv);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = loc_service_register(srv, test_ipcgfx_svc, &sid);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -901,6 +930,7 @@
 	async_hangup(sess);
 
-	rc = loc_service_unregister(sid);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	rc = loc_service_unregister(srv, sid);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	loc_server_unregister(srv);
 }
 
@@ -918,12 +948,13 @@
 	async_sess_t *sess;
 	ipc_gc_t *ipcgc;
-
-	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
-
-	// FIXME This causes this test to be non-reentrant!
-	rc = loc_server_register(test_ipcgfx_server);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = loc_service_register(test_ipcgfx_svc, &sid);
+	loc_srv_t *srv;
+
+	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
+
+	// FIXME This causes this test to be non-reentrant!
+	rc = loc_server_register(test_ipcgfx_server, &srv);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = loc_service_register(srv, test_ipcgfx_svc, &sid);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -969,6 +1000,7 @@
 	async_hangup(sess);
 
-	rc = loc_service_unregister(sid);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	rc = loc_service_unregister(srv, sid);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	loc_server_unregister(srv);
 }
 
@@ -985,12 +1017,13 @@
 	async_sess_t *sess;
 	ipc_gc_t *ipcgc;
-
-	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
-
-	// FIXME This causes this test to be non-reentrant!
-	rc = loc_server_register(test_ipcgfx_server);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = loc_service_register(test_ipcgfx_svc, &sid);
+	loc_srv_t *srv;
+
+	async_set_fallback_port_handler(test_ipcgc_conn, &resp);
+
+	// FIXME This causes this test to be non-reentrant!
+	rc = loc_server_register(test_ipcgfx_server, &srv);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = loc_service_register(srv, test_ipcgfx_svc, &sid);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -1029,6 +1062,7 @@
 	async_hangup(sess);
 
-	rc = loc_service_unregister(sid);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	rc = loc_service_unregister(srv, sid);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	loc_server_unregister(srv);
 }
 
