Skip to content

Commit

Permalink
Fix race condition with stream existence check (#3309)
Browse files Browse the repository at this point in the history
* Fix race condition with stream existence check

* Simplify, just call startControlPublish first
  • Loading branch information
mjh1 authored Dec 12, 2024
1 parent a367c90 commit 77711d4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion server/ai_live_video.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ func copySegment(segment *http.Response, w io.Writer) error {
}

func startControlPublish(control *url.URL, params aiRequestParams) {
controlPub, err := trickle.NewTricklePublisher(control.String())
stream := params.liveParams.stream
controlPub, err := trickle.NewTricklePublisher(control.String())
if err != nil {
slog.Info("error starting control publisher", "stream", stream, "err", err)
return
Expand Down
5 changes: 2 additions & 3 deletions server/ai_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -1048,16 +1048,15 @@ func submitLiveVideoToVideo(ctx context.Context, params aiRequestParams, sess *A
if err != nil {
return nil, fmt.Errorf("invalid control URL: %w", err)
}
// TODO any errors from these funcs should we kill the input stream?

events, err := common.AppendHostname(*resp.JSON200.EventsUrl, host)
if err != nil {
return nil, fmt.Errorf("invalid events URL: %w", err)
}
clog.V(common.VERBOSE).Infof(ctx, "pub %s sub %s control %s events %s", pub, sub, control, events)

startControlPublish(control, params)
startTricklePublish(ctx, pub, params, sess)
startTrickleSubscribe(ctx, sub, params)
startControlPublish(control, params)
startEventsSubscribe(ctx, events, params)
}
return resp, nil
Expand Down

0 comments on commit 77711d4

Please sign in to comment.