MCPcopy Create free account
hub / github.com/Haivision/srt / OnINT_SetInterrupted

Function OnINT_SetInterrupted

testing/srt-test-relay.cpp:62–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60thread::id g_root_thread = std::this_thread::get_id();
61
62static void OnINT_SetInterrupted(int)
63{
64 Verb() << VerbLock << "SIGINT: Setting interrupt state.";
65 ::transmit_int_state = true;
66
67 // Just for a case, forcefully close all active SRT sockets.
68 SrtModel* pm = ::g_pending_model;
69 if (pm)
70 {
71 // The program is hanged on accepting a new SRT connection.
72 // We need to check which thread we've fallen into.
73 if (this_thread::get_id() == g_root_thread)
74 {
75 // Throw an exception, it will be caught in a predicted place.
76 throw std::runtime_error("Interrupted on request");
77 }
78 else
79 {
80 // This is some other thread, so close the listener socket.
81 // This will cause the accept block to be interrupted.
82 for (SRTSOCKET i: { pm->Socket(), pm->Listener() })
83 if (i != SRT_INVALID_SOCK)
84 srt_close(i);
85 }
86 }
87
88}
89
90using namespace std;
91

Callers

nothing calls this directly

Calls 5

VerbFunction · 0.85
get_idFunction · 0.85
srt_closeFunction · 0.85
SocketMethod · 0.45
ListenerMethod · 0.45

Tested by

no test coverage detected