From 712f37af29962aeb55dc45a94e5959a9177e6b06 Mon Sep 17 00:00:00 2001
From: Jens Nolte <git@queezle.net>
Date: Tue, 7 Dec 2021 21:12:58 +0100
Subject: [PATCH] Update quasar

---
 example/Main.hs                  |  2 +-
 flake.lock                       | 12 ++++++------
 src/Quasar/Wayland/Connection.hs | 21 ++++++++-------------
 3 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/example/Main.hs b/example/Main.hs
index 71d5d44..d0612ac 100644
--- a/example/Main.hs
+++ b/example/Main.hs
@@ -7,7 +7,7 @@ import Quasar.Wayland.Client
 
 main :: IO ()
 main = do
-  withResourceManagerM do
+  withRootResourceManager do
     traceIO "Connecting"
     client <- connectWaylandClient
     traceIO "Connected"
diff --git a/flake.lock b/flake.lock
index cd0a41f..599e5db 100644
--- a/flake.lock
+++ b/flake.lock
@@ -23,11 +23,11 @@
       },
       "locked": {
         "host": "git.c3pb.de",
-        "lastModified": 1631852696,
-        "narHash": "sha256-sM5h2IHVyB0kKMNz44042D6QVvsTyUhaOCYkdcEjabQ=",
+        "lastModified": 1638315058,
+        "narHash": "sha256-SA99IShGlTc3IkcqG5YP/lnSyTWWHFIdvci5pWR8BrI=",
         "owner": "jens",
         "repo": "quasar",
-        "rev": "862976c067cc41435e1087def16dfb86c57b317b",
+        "rev": "7f163062fd2dc98041b5149c5ab23fd8cedde7e6",
         "type": "gitlab"
       },
       "original": {
@@ -46,11 +46,11 @@
       },
       "locked": {
         "host": "git.c3pb.de",
-        "lastModified": 1631899417,
-        "narHash": "sha256-qSD1O3x/oCgrm6v1GGSO2d+rO0jMs2zi8yASXhPyHN0=",
+        "lastModified": 1638330205,
+        "narHash": "sha256-vVdNLDtS7mmj5FLJ7/lL0mJ9r05ZLhJQoRAlmDa7OC4=",
         "owner": "jens",
         "repo": "quasar-network",
-        "rev": "fda985686d4003c85c53bbb1654cf5324ae4e7c2",
+        "rev": "12c98e410f4a6d96b9ea2390da1edc6d026ad7ae",
         "type": "gitlab"
       },
       "original": {
diff --git a/src/Quasar/Wayland/Connection.hs b/src/Quasar/Wayland/Connection.hs
index 5b5f1db..4c91fb1 100644
--- a/src/Quasar/Wayland/Connection.hs
+++ b/src/Quasar/Wayland/Connection.hs
@@ -51,18 +51,16 @@ newWaylandConnection initializeProtocolAction socket = do
 
     registerDisposeAction $ closeConnection connection
 
-    runUnlimitedAsync do
-      connectionThread connection $ sendThread connection
-      connectionThread connection $ receiveThread connection
+    connectionThread connection $ sendThread connection
+    connectionThread connection $ receiveThread connection
 
     pure (result, connection)
 
-connectionThread :: MonadAsync m => WaylandConnection s -> IO () -> m ()
-connectionThread connection work = async_ $ liftIO $ work `catches` [ignoreCancelTask, traceAndDisposeConnection]
+connectionThread :: MonadResourceManager m => WaylandConnection s -> IO () -> m ()
+connectionThread connection work = asyncWithHandler_ traceAndDisposeConnection $ liftIO $ work
   where
-    ignoreCancelTask :: Handler IO a
-    ignoreCancelTask = Handler (throwM :: CancelTask -> IO a)
-    traceAndDisposeConnection = Handler (\(ex :: SomeException) -> traceIO (displayException ex) >> void (dispose connection))
+    traceAndDisposeConnection :: SomeException -> IO ()
+    traceAndDisposeConnection ex = traceIO (displayException ex) >> void (dispose connection)
 
 sendThread :: WaylandConnection s -> IO ()
 sendThread connection = forever do
@@ -83,8 +81,5 @@ receiveThread connection = forever do
 
   feedInput connection.protocolHandle bytes
 
-closeConnection :: WaylandConnection s -> IO (Awaitable ())
-closeConnection connection = do
-  -- gracefulClose may fail but guarantees that the socket is deallocated
-  Socket.close connection.socket `catch` \(_ :: SomeException) -> pure ()
-  pure $ pure ()
+closeConnection :: WaylandConnection s -> IO ()
+closeConnection connection = Socket.close connection.socket
-- 
GitLab