Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
galene
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
galene
Commits
36d6845d
Commit
36d6845d
authored
Feb 01, 2021
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix closing of replaced connections.
parent
f63ecb30
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
26 deletions
+22
-26
rtpconn/webclient.go
rtpconn/webclient.go
+22
-26
No files found.
rtpconn/webclient.go
View file @
36d6845d
...
...
@@ -249,43 +249,44 @@ func addUpConn(c *webClient, id string, labels map[string]string, offer string)
var
ErrUserMismatch
=
errors
.
New
(
"user id mismatch"
)
func
delUpConn
(
c
*
webClient
,
id
string
,
userId
string
)
(
string
,
error
)
{
// delUpConn deletes an up connection. If push is closed, the close is
// pushed to all corresponding down connections.
func
delUpConn
(
c
*
webClient
,
id
string
,
userId
string
,
push
bool
)
error
{
c
.
mu
.
Lock
()
if
c
.
up
==
nil
{
c
.
mu
.
Unlock
()
return
""
,
os
.
ErrNotExist
return
os
.
ErrNotExist
}
conn
:=
c
.
up
[
id
]
if
conn
==
nil
{
c
.
mu
.
Unlock
()
return
""
,
os
.
ErrNotExist
return
os
.
ErrNotExist
}
if
userId
!=
""
&&
conn
.
userId
!=
userId
{
c
.
mu
.
Unlock
()
return
""
,
ErrUserMismatch
return
ErrUserMismatch
}
replace
:=
conn
.
getReplace
(
true
)
delete
(
c
.
up
,
id
)
g
:=
c
.
group
c
.
mu
.
Unlock
()
g
:=
c
.
group
if
g
!=
nil
{
conn
.
pc
.
Close
()
if
push
&&
g
!=
nil
{
go
func
(
clients
[]
group
.
Client
)
{
for
_
,
c
:=
range
clients
{
err
:=
c
.
PushConn
(
g
,
conn
.
id
,
nil
,
nil
,
replace
)
err
:=
c
.
PushConn
(
g
,
id
,
nil
,
nil
,
replace
)
if
err
!=
nil
{
log
.
Printf
(
"PushConn: %v"
,
err
)
}
}
}(
g
.
GetClients
(
c
))
}
else
{
log
.
Printf
(
"Deleting connection for client with no group"
)
}
conn
.
pc
.
Close
()
return
conn
.
replace
,
nil
return
nil
}
func
getDownConn
(
c
*
webClient
,
id
string
)
*
rtpDownConnection
{
...
...
@@ -513,7 +514,10 @@ func gotOffer(c *webClient, id string, sdp string, labels map[string]string, rep
up
.
userId
=
c
.
Id
()
up
.
username
=
c
.
Username
()
up
.
replace
=
replace
if
replace
!=
""
{
up
.
replace
=
replace
delUpConn
(
c
,
replace
,
c
.
Id
(),
false
)
}
err
=
up
.
pc
.
SetRemoteDescription
(
webrtc
.
SessionDescription
{
Type
:
webrtc
.
SDPTypeOffer
,
...
...
@@ -922,12 +926,10 @@ func clientLoop(c *webClient, ws *websocket.Conn) error {
if
!
c
.
permissions
.
Present
{
up
:=
getUpConns
(
c
)
for
_
,
u
:=
range
up
{
replace
,
err
:=
delUpConn
(
c
,
u
.
id
,
c
.
id
)
err
:=
delUpConn
(
c
,
u
.
id
,
c
.
id
,
true
,
)
if
err
==
nil
{
if
replace
!=
""
{
delUpConn
(
c
,
replace
,
c
.
id
)
}
failUpConnection
(
c
,
u
.
id
,
"permission denied"
,
...
...
@@ -989,7 +991,7 @@ func leaveGroup(c *webClient) {
c
.
setRequested
(
map
[
string
]
uint32
{})
if
c
.
up
!=
nil
{
for
id
:=
range
c
.
up
{
delUpConn
(
c
,
id
,
c
.
id
)
delUpConn
(
c
,
id
,
c
.
id
,
true
)
}
}
...
...
@@ -1173,7 +1175,7 @@ func handleClientMessage(c *webClient, m clientMessage) error {
case
"offer"
:
if
!
c
.
permissions
.
Present
{
if
m
.
Replace
!=
""
{
delUpConn
(
c
,
m
.
Replace
,
c
.
id
)
delUpConn
(
c
,
m
.
Replace
,
c
.
id
,
true
)
}
c
.
write
(
clientMessage
{
Type
:
"abort"
,
...
...
@@ -1222,18 +1224,12 @@ func handleClientMessage(c *webClient, m clientMessage) error {
log
.
Printf
(
"Trying to renegotiate unknown connection"
)
}
case
"close"
:
replace
,
err
:=
delUpConn
(
c
,
m
.
Id
,
c
.
id
)
err
:=
delUpConn
(
c
,
m
.
Id
,
c
.
id
,
true
)
if
err
!=
nil
{
log
.
Printf
(
"Deleting up connection %v: %v"
,
m
.
Id
,
err
)
return
nil
}
if
replace
!=
""
{
_
,
err
:=
delUpConn
(
c
,
replace
,
c
.
id
)
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
log
.
Printf
(
"Replace up connection: %v"
,
err
)
}
}
case
"abort"
:
err
:=
delDownConn
(
c
,
m
.
Id
)
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment