Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sfu
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
Alain Takoudjou
sfu
Commits
bd5cd7c1
Commit
bd5cd7c1
authored
Oct 01, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid calling pc.Close under a lock.
Apparently Close can take unbounded amounts of time.
parent
13d6b7ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
16 deletions
+32
-16
rtpconn/webclient.go
rtpconn/webclient.go
+32
-16
No files found.
rtpconn/webclient.go
View file @
bd5cd7c1
...
...
@@ -284,53 +284,70 @@ func addDownConn(c *webClient, id string, remote conn.Up) (*rtpDownConnection, e
return
nil
,
err
}
err
=
addDownConnHelper
(
c
,
conn
,
remote
)
if
err
!=
nil
{
conn
.
pc
.
Close
()
return
nil
,
err
}
return
conn
,
err
}
func
addDownConnHelper
(
c
*
webClient
,
conn
*
rtpDownConnection
,
remote
conn
.
Up
)
(
error
)
{
c
.
mu
.
Lock
()
defer
c
.
mu
.
Unlock
()
if
c
.
up
!=
nil
&&
c
.
up
[
id
]
!=
nil
{
conn
.
pc
.
Close
()
return
nil
,
errors
.
New
(
"Adding duplicate connection"
)
if
c
.
up
!=
nil
&&
c
.
up
[
conn
.
id
]
!=
nil
{
return
errors
.
New
(
"Adding duplicate connection"
)
}
if
c
.
down
==
nil
{
c
.
down
=
make
(
map
[
string
]
*
rtpDownConnection
)
}
old
:=
c
.
down
[
id
]
old
:=
c
.
down
[
conn
.
id
]
if
old
!=
nil
{
old
.
pc
.
Close
()
// Avoid calling Close under a lock
go
old
.
pc
.
Close
()
}
conn
.
pc
.
OnICECandidate
(
func
(
candidate
*
webrtc
.
ICECandidate
)
{
sendICE
(
c
,
id
,
candidate
)
sendICE
(
c
,
conn
.
id
,
candidate
)
})
conn
.
pc
.
OnICEConnectionStateChange
(
func
(
state
webrtc
.
ICEConnectionState
)
{
if
state
==
webrtc
.
ICEConnectionStateFailed
{
c
.
action
(
connectionFailedAction
{
id
:
id
})
c
.
action
(
connectionFailedAction
{
id
:
conn
.
id
})
}
})
err
=
remote
.
AddLocal
(
conn
)
err
:
=
remote
.
AddLocal
(
conn
)
if
err
!=
nil
{
conn
.
pc
.
Close
()
return
nil
,
err
return
err
}
c
.
down
[
id
]
=
conn
return
conn
,
nil
c
.
down
[
conn
.
id
]
=
conn
return
nil
}
func
delDownConn
(
c
*
webClient
,
id
string
)
bool
{
conn
:=
delDownConnHelper
(
c
,
id
)
if
conn
!=
nil
{
conn
.
pc
.
Close
()
return
true
}
return
false
}
func
delDownConnHelper
(
c
*
webClient
,
id
string
)
*
rtpDownConnection
{
c
.
mu
.
Lock
()
defer
c
.
mu
.
Unlock
()
if
c
.
down
==
nil
{
return
false
return
nil
}
conn
:=
c
.
down
[
id
]
if
conn
==
nil
{
return
false
return
nil
}
conn
.
remote
.
DelLocal
(
conn
)
...
...
@@ -339,9 +356,8 @@ func delDownConn(c *webClient, id string) bool {
// ignore errors here.
track
.
remote
.
DelLocal
(
track
)
}
conn
.
pc
.
Close
()
delete
(
c
.
down
,
id
)
return
true
return
conn
}
func
addDownTrack
(
c
*
webClient
,
conn
*
rtpDownConnection
,
remoteTrack
conn
.
UpTrack
,
remoteConn
conn
.
Up
)
(
*
webrtc
.
RTPSender
,
error
)
{
...
...
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