diff --git a/src/ice/gather.c b/src/ice/gather.c index 4f119f0..236dba1 100644 --- a/src/ice/gather.c +++ b/src/ice/gather.c @@ -122,6 +122,11 @@ static void turnc_handler(int err, uint16_t scode, const char *reason, --icem->nstun; + /* TURN failed, so we destroy the client */ + if (err || scode) { + comp->turnc = mem_deref(comp->turnc); + } + if (err) { DEBUG_WARNING("{%s.%d} TURN Client error: %s\n", icem->name, comp->id, strerror(err)); diff --git a/src/ice/icem.c b/src/ice/icem.c index 5119fda..1072758 100644 --- a/src/ice/icem.c +++ b/src/ice/icem.c @@ -214,7 +214,10 @@ int icem_add_chan(struct icem *icem, uint8_t compid, const struct sa *raddr) if (!comp) return ENOENT; - return turnc_add_chan(comp->turnc, raddr, NULL, NULL); + if (comp->turnc) + return turnc_add_chan(comp->turnc, raddr, NULL, NULL); + + return 0; }