Fix dtls pull_timeout_function, fix cyclic references

This commit is contained in:
fiaxh 2021-04-09 19:04:24 +02:00
parent 09dc38f169
commit 5e11986838
5 changed files with 23 additions and 14 deletions

View file

@ -216,9 +216,7 @@ public class Handler {
private static int pull_timeout_function(void* transport_ptr, uint ms) { private static int pull_timeout_function(void* transport_ptr, uint ms) {
Handler self = transport_ptr as Handler; Handler self = transport_ptr as Handler;
DateTime current_time = new DateTime.now_utc(); int64 end_time = get_monotonic_time() + ms * 1000;
current_time.add_seconds(ms/1000);
int64 end_time = current_time.to_unix();
self.buffer_mutex.lock(); self.buffer_mutex.lock();
while (self.buffer_queue.size == 0) { while (self.buffer_queue.size == 0) {
@ -228,9 +226,9 @@ public class Handler {
return -1; return -1;
} }
DateTime new_current_time = new DateTime.now_utc(); if (get_monotonic_time() > end_time) {
if (new_current_time.compare(current_time) > 0) { self.buffer_mutex.unlock();
break; return 0;
} }
} }
self.buffer_mutex.unlock(); self.buffer_mutex.unlock();

View file

@ -40,6 +40,7 @@ public class Dino.Plugins.Ice.TransportParameters : JingleIceUdp.IceUdpTransport
yield base.terminate(we_terminated, reason_string, reason_text); yield base.terminate(we_terminated, reason_string, reason_text);
this.disconnect(datagram_received_id); this.disconnect(datagram_received_id);
agent = null; agent = null;
dtls_srtp_handler = null;
} }
public override void send_datagram(Bytes datagram) { public override void send_datagram(Bytes datagram) {
@ -324,4 +325,11 @@ public class Dino.Plugins.Ice.TransportParameters : JingleIceUdp.IceUdpTransport
return candidate; return candidate;
} }
public override void dispose() {
base.dispose();
agent = null;
dtls_srtp_handler = null;
connections.clear();
}
} }

View file

@ -107,6 +107,7 @@ public class Xmpp.Xep.Jingle.Content : Object {
public void terminate(bool we_terminated, string? reason_name, string? reason_text) { public void terminate(bool we_terminated, string? reason_name, string? reason_text) {
content_params.terminate(we_terminated, reason_name, reason_text); content_params.terminate(we_terminated, reason_name, reason_text);
transport_params.dispose();
foreach (ComponentConnection connection in component_connections.values) { foreach (ComponentConnection connection in component_connections.values) {
connection.terminate(we_terminated, reason_name, reason_text); connection.terminate(we_terminated, reason_name, reason_text);

View file

@ -210,9 +210,7 @@ public class Xmpp.Xep.Jingle.Session : Object {
} }
public async void add_content(Content content) { public async void add_content(Content content) {
content.session = this; insert_content(content);
this.contents_map[content.content_name] = content;
contents.add(content);
StanzaNode content_add_node = new StanzaNode.build("jingle", NS_URI) StanzaNode content_add_node = new StanzaNode.build("jingle", NS_URI)
.add_self_xmlns() .add_self_xmlns()

View file

@ -84,30 +84,34 @@ public class Xmpp.Xep.JingleRtp.Parameters : Jingle.ContentParameters, Object {
Jingle.DatagramConnection rtcp_datagram = (Jingle.DatagramConnection) content.get_transport_connection(2); Jingle.DatagramConnection rtcp_datagram = (Jingle.DatagramConnection) content.get_transport_connection(2);
ulong rtcp_ready_handler_id = 0; ulong rtcp_ready_handler_id = 0;
rtcp_ready_handler_id = rtcp_datagram.notify["ready"].connect(() => { rtcp_ready_handler_id = rtcp_datagram.notify["ready"].connect((rtcp_datagram, _) => {
this.stream.on_rtcp_ready(); this.stream.on_rtcp_ready();
rtcp_datagram.disconnect(rtcp_ready_handler_id); ((Jingle.DatagramConnection)rtcp_datagram).disconnect(rtcp_ready_handler_id);
rtcp_ready_handler_id = 0; rtcp_ready_handler_id = 0;
}); });
ulong rtp_ready_handler_id = 0; ulong rtp_ready_handler_id = 0;
rtp_ready_handler_id = rtp_datagram.notify["ready"].connect(() => { rtp_ready_handler_id = rtp_datagram.notify["ready"].connect((rtp_datagram, _) => {
this.stream.on_rtp_ready(); this.stream.on_rtp_ready();
if (rtcp_mux) { if (rtcp_mux) {
this.stream.on_rtcp_ready(); this.stream.on_rtcp_ready();
} }
connection_ready(); connection_ready();
rtp_datagram.disconnect(rtp_ready_handler_id); ((Jingle.DatagramConnection)rtp_datagram).disconnect(rtp_ready_handler_id);
rtp_ready_handler_id = 0; rtp_ready_handler_id = 0;
}); });
session.notify["state"].connect((obj, _) => { ulong session_state_handler_id = 0;
session_state_handler_id = session.notify["state"].connect((obj, _) => {
Jingle.Session session2 = (Jingle.Session) obj; Jingle.Session session2 = (Jingle.Session) obj;
if (session2.state == Jingle.Session.State.ENDED) { if (session2.state == Jingle.Session.State.ENDED) {
if (rtcp_ready_handler_id != 0) rtcp_datagram.disconnect(rtcp_ready_handler_id); if (rtcp_ready_handler_id != 0) rtcp_datagram.disconnect(rtcp_ready_handler_id);
if (rtp_ready_handler_id != 0) rtp_datagram.disconnect(rtp_ready_handler_id); if (rtp_ready_handler_id != 0) rtp_datagram.disconnect(rtp_ready_handler_id);
if (session_state_handler_id != 0) {
session2.disconnect(session_state_handler_id);
}
} }
}); });