File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -765,14 +765,28 @@ resource_listener_down_callback(__unused_parm__ ErlNifEnv *env,
765
765
{
766
766
QuicerListenerCTX * l_ctx = (QuicerListenerCTX * )ctx ;
767
767
TP_CB_3 (start , (uintptr_t )l_ctx -> Listener , 0 );
768
- if (l_ctx -> Listener )
769
- {
770
- MsQuic -> ListenerStop (l_ctx -> Listener );
771
- }
772
-
768
+ BOOLEAN to_stop = FALSE;
769
+ enif_mutex_lock (l_ctx -> lock );
770
+ if (!l_ctx -> is_closed && !l_ctx -> is_stopped && l_ctx -> Listener )
771
+ {
772
+ to_stop = TRUE;
773
+ l_ctx -> is_stopped = TRUE;
774
+ }
775
+ enif_mutex_unlock (l_ctx -> lock );
776
+ if (to_stop )
777
+ {
778
+ // We only stop here, but not close it, because we want to
779
+ // close it in resource_listener_dealloc_callback
780
+ // Or some pid could still start the stopped listener with nif handle
781
+ MsQuic -> ListenerStop (l_ctx -> Listener );
782
+ }
773
783
TP_CB_3 (end , (uintptr_t )l_ctx -> Listener , 0 );
774
784
}
775
785
786
+
787
+ /*
788
+ ** Listener NIF handle, end of world...
789
+ */
776
790
void
777
791
resource_listener_dealloc_callback (__unused_parm__ ErlNifEnv * env , void * obj )
778
792
{
You can’t perform that action at this time.
0 commit comments