MT#11357 fix race condition during call teardown

Streams are removed from kernel forwarding at the "Final packet stats"
stage, which also stops the packet handler. But if a packet has already
been received at this point, with the packet handler already running,
only waiting to acquire the mutex, then the handler will run after the
streams have been removed from kernel and will promptly push them back
into kernel, where they will remain forever after.
2.3
Richard Fuchs 10 years ago
parent f77395f9ec
commit 9b019a357c

@ -566,6 +566,9 @@ static int stream_packet(struct streamrelay *sr_incoming, str *s, struct sockadd
m = c->callmaster;
smart_ntop_port(addr, fsin, sizeof(addr));
if (p_incoming->shutdown || p_outgoing->shutdown)
return 0;
if (sr_incoming->stun && is_stun(s)) {
stun_ret = stun(s, sr_incoming, fsin);
if (!stun_ret)
@ -1800,6 +1803,7 @@ static void kill_callstream(struct callstream *s) {
for (i = 0; i < 2; i++) {
p = &s->peers[i];
p->shutdown = 1;
unkernelize(p);
for (j = 0; j < 2; j++) {

@ -132,6 +132,7 @@ struct peer {
int kernelized:1;
int filled:1;
int confirmed:1;
int shutdown:1;
};
struct callstream {
struct obj obj;

Loading…
Cancel
Save