Skip to content

Commit

Permalink
xrootd: do not segfault sending data with nil clients
Browse files Browse the repository at this point in the history
Updates #758
  • Loading branch information
sbinet committed Jun 23, 2020
1 parent aa37c69 commit 234a493
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion xrootd/client.go
Expand Up @@ -99,10 +99,11 @@ func (client *Client) Close() error {
if client == nil {
return os.ErrInvalid
}

defer client.cancel()

client.mu.Lock()
defer client.mu.Unlock()

var errs []error
for _, session := range client.sessions {
err := session.Close()
Expand All @@ -120,6 +121,10 @@ func (client *Client) Close() error {
// If the resp is nil, then no response is stored.
// Send returns a session id which identifies the server that provided response.
func (client *Client) Send(ctx context.Context, resp xrdproto.Response, req xrdproto.Request) (string, error) {
if client == nil {
return "", os.ErrInvalid
}

return client.sendSession(ctx, client.initialSessionID, resp, req)
}

Expand Down

0 comments on commit 234a493

Please sign in to comment.