Skip to content

Commit

Permalink
grpcreplay: stop server in Replayer.Close (#53)
Browse files Browse the repository at this point in the history
We were getting a panic when we stopped it early.
  • Loading branch information
jba authored Jul 29, 2024
1 parent f70c552 commit af2830b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions grpcreplay/grpcreplay.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ type Replayer struct {
r reader
initial []byte // initial state
conn *grpc.ClientConn
srv *grpc.Server

mu sync.Mutex
calls []*call
Expand Down Expand Up @@ -431,10 +432,10 @@ func (rep *Replayer) Connection() (*grpc.ClientConn, error) {
if err != nil {
return nil, err
}
// Save the connection to close it later.
// Save the connection and server to close them later.
// Closing it now causes an error if the caller closes the client during the replay.
rep.conn = conn
srv.Stop()
rep.srv = srv
return conn, nil
}

Expand All @@ -446,6 +447,9 @@ func (rep *Replayer) Close() error {
if rep.conn != nil {
rep.conn.Close()
}
if rep.srv != nil {
rep.srv.Stop()
}
return nil
}

Expand Down

0 comments on commit af2830b

Please sign in to comment.