Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] A code mistaken found in janus_videoroom_subscriber_stream_remove() of videoroom.c #2965

Closed
jamken opened this issue May 1, 2022 · 2 comments
Labels
multistream Related to Janus 1.x

Comments

@jamken
Copy link

jamken commented May 1, 2022

What version of Janus is this happening on?
v1.0.1

Have you tested a more recent version of Janus too?
Yes,

Was this working before?
It's a minor mistaken which is not visable

Is there a gdb or libasan trace of the issue?
I's found in my code review for janus-cloud coding with multisream version

Additional context
janus_videoroom_subscriber_stream_remove() :

static void janus_videoroom_subscriber_stream_remove(janus_videoroom_subscriber_stream *s,
		janus_videoroom_publisher_stream *ps, gboolean lock_ps) {
	janus_videoroom_subscriber *subscriber = s->subscriber;
	if(subscriber && subscriber->pvt_id > 0 && subscriber->room != NULL) {
		janus_mutex_lock(&subscriber->room->mutex);
		janus_videoroom_publisher *owner = g_hash_table_lookup(subscriber->room->private_ids, GUINT_TO_POINTER(subscriber->pvt_id));
		if(owner != NULL) {
			janus_mutex_lock(&owner->subscribers_mutex);
			/* Note: we should refcount these subscription-publisher mappings as well */
			owner->subscriptions = g_slist_remove(owner->subscriptions, s);  //jamken: owner->subscriptions  should be linke with janus_videoroom_subscriber not janus_videoroom_subscriber_stream
			janus_mutex_unlock(&owner->subscribers_mutex);
		}
		janus_mutex_unlock(&subscriber->room->mutex);
		//~ if(subscriber->room)
			//~ g_clear_pointer(&subscriber->room, janus_videoroom_room_dereference);
		//~ /* If the subscriber itself has no more active active subscriptions, should we close it? */
		//~ if(subscriber->streams == NULL && subscriber->session && subscriber->close_pc)
			//~ gateway->close_pc(subscriber->session->handle);
	}

from above code, owner->subscriptions should be linke with janus_videoroom_subscriber but it's remove with a janus_videoroom_subscriber_stream by mistaken
Also, when remove a stream from a subscriber, it make no sense to remove the subsrciber from it's owner

@jamken jamken added the multistream Related to Janus 1.x label May 1, 2022
@lminiero
Copy link
Member

lminiero commented May 3, 2022

That's a good catch, but I don't think the fix is as simple as that. If we're just removing a stream, but are still subscribed to other streams, then we should not remove the subscription from that list. I'll need some time to figure out what the right way to handle this.

@lminiero
Copy link
Member

lminiero commented May 9, 2022

The commit above fixes the problem: this was only an issue when forcing require_pvtid: true in a room, but now should be fine in that case as well. Thanks again for spotting this problem!

mwalbeck pushed a commit to mwalbeck/docker-janus-gateway that referenced this issue May 25, 2022
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [meetecho/janus-gateway](https://github.com/meetecho/janus-gateway) | patch | `v1.0.1` -> `v1.0.2` |

---

### Release Notes

<details>
<summary>meetecho/janus-gateway</summary>

### [`v1.0.2`](https://github.com/meetecho/janus-gateway/blob/HEAD/CHANGELOG.md#v102---2022-05-23)

[Compare Source](meetecho/janus-gateway@v1.0.1...v1.0.2)

-   Abort DTLS handshake if DTLSv1\_handle_timeout returns an error
-   Fixed rtx not being offered on Janus originated PeerConnections
-   Added configurable property to put a cap to task threads \[[Issue-2964](meetecho/janus-gateway#2964)]
-   Fixed build issue with libressl >= 3.5.0 (thanks [@&#8203;ffontaine](https://github.com/ffontaine)!) \[[PR-2980](meetecho/janus-gateway#2980)]
-   Link to -lresolv explicitly when building websockets transport
-   Fixed RED parsing not returning blocks when only primary data is available
-   Fixed typo in stereo support in EchoTest plugin
-   Added support for dummy publishers in VideoRoom \[[PR-2958](meetecho/janus-gateway#2958)]
-   Added new VideoRoom request to combine subscribe and unsubscribe operations \[[PR-2962](meetecho/janus-gateway#2962)]
-   Fixed incorrect removal of owner/subscriptions mapping in VideoRoom plugin \[[Issue-2965](meetecho/janus-gateway#2965)]
-   Explicitly return list of IDs VideoRoom users are subscribed to for data \[[Issue-2967](meetecho/janus-gateway#2967)]
-   Fixed data port not being returned when creating Streaming mountpoints with the legacy API
-   Fix address size in Streaming plugin RTCP sendto call (thanks [@&#8203;sjkummer](https://github.com/sjkummer)!) \[[PR-2976](meetecho/janus-gateway#2976)]
-   Added custom headers for SIP SUBSCRIBE requests (thanks [@&#8203;oriol-c](https://github.com/oriol-c)!) \[[PR-2971](meetecho/janus-gateway#2971)]
-   Make SIP timer T1X64 configurable (thanks [@&#8203;oriol-c](https://github.com/oriol-c)!) \[[PR-2972](meetecho/janus-gateway#2972)]
-   Disable IPv6 in WebSockets transport if binding to IPv4 address explicitly \[[Issue-2969](meetecho/janus-gateway#2969)]
-   Other smaller fixes and improvements (thanks to all who contributed pull requests and reported issues!)

</details>

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).

Reviewed-on: https://git.walbeck.it/walbeck-it/docker-janus-gateway/pulls/79
Co-authored-by: renovate-bot <bot@walbeck.it>
Co-committed-by: renovate-bot <bot@walbeck.it>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
multistream Related to Janus 1.x
Projects
None yet
Development

No branches or pull requests

2 participants