Add_remote_publisher and room destroy

We got the situation then ports are not freed by janus if remote publishers were added to room but remove_remote_publisher were not called if room is already destroyed.
Is it a bug or we should call remove_remote_publisher even if room already doesn’t exist?

udp               UNCONN                 0                   0                                                                                                *:20002
                  *:*
udp               UNCONN                 0                   0                                                                                                *:20003
                  *:*
udp               UNCONN                 0                   0                                                                                                *:20005
                  *:*
udp               UNCONN                 0                   0                                                                                                *:20006

udp ports are listening, but no rooms in janus exist.

I guess it’s because of this check here in the remote publisher thread:

Since you never called remove_remote_publisher, the remote_leaving property is never set to 1. The publisher is not set to destroyed either because they didn’t hangup (which regular participant do when notified about the room destruction).

I guess the easiest (and cleanest) approach is sending the remove_remote_publisher before destroying the room. You can also try adding a check on videoroom->destroyed in the line I mentioned, which should cause a cleanup when a room is destroyed too, but I’m not 100% sure that wouldn’t cause a leak. It’s worth a try, though: in case that works for you we can push it upstream.

added check for videoroom->destroyed and it fixes problem - ports cleaned. I’ll monitor janus with this fix and build it with asan and check if it causes any leaks.

1 Like