summaryrefslogtreecommitdiff
path: root/src/Erebos/ICE.chs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2025-03-27 21:48:40 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2025-03-27 21:48:40 +0100
commitc536547d742cde13042792e60f28893578adc331 (patch)
tree37c899ecf83b8d839caa6bb02abf3e69ba28d0e6 /src/Erebos/ICE.chs
parent0bfa9e3d79f0b6760346258672b61721bbdbf9ef (diff)
parent63e1b79f48e31da10e93169444c3426b631247b2 (diff)
Merge branch 'release-0.1'
Diffstat (limited to 'src/Erebos/ICE.chs')
-rw-r--r--src/Erebos/ICE.chs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Erebos/ICE.chs b/src/Erebos/ICE.chs
index 06edecf..2c6f500 100644
--- a/src/Erebos/ICE.chs
+++ b/src/Erebos/ICE.chs
@@ -19,7 +19,7 @@ module Erebos.ICE (
) where
import Control.Arrow
-import Control.Concurrent.MVar
+import Control.Concurrent
import Control.Monad
import Control.Monad.Identity
@@ -144,7 +144,11 @@ iceCreateConfig stun turn =
iceCreateSession :: IceConfig -> IceSessionRole -> (IceSession -> IO ()) -> IO IceSession
iceCreateSession icfg@(IceConfig fcfg) role cb = do
rec sptr <- newStablePtr sess
- cbptr <- newStablePtr $ cb sess
+ cbptr <- newStablePtr $ do
+ -- The callback may be called directly from pj_ice_strans_create or later
+ -- from a different thread; make sure we use a different thread here
+ -- to avoid deadlock on accessing 'sess'.
+ forkIO $ cb sess
sess <- IceSession
<$> (withForeignPtr fcfg $ \cfg ->
{#call ice_create #} (castPtr cfg) (fromIntegral $ fromEnum role) (castStablePtrToPtr sptr) (castStablePtrToPtr cbptr)