Skip to content
This repository has been archived by the owner on Sep 22, 2020. It is now read-only.

Commit

Permalink
Merge pull request #316 from nak3/nbd-clear
Browse files Browse the repository at this point in the history
nbd: don't return error during clean up process
  • Loading branch information
barakmich committed Sep 8, 2016
2 parents 3852502 + 76db8d6 commit e449e89
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions internal/nbd/nbd.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ func (nbd *NBD) Serve() error {
}
}(nbd)
}
if err := waitDisconnect(nbd.nbd); err != nil {
return err
}

waitDisconnect(nbd.nbd)

wg.Wait()
return nil
}
Expand Down Expand Up @@ -247,33 +247,23 @@ func (nbd *NBD) Disconnect() error {
return nil
}

func waitDisconnect(f *os.File) error {
func waitDisconnect(f *os.File) {
runtime.LockOSThread()
defer runtime.UnlockOSThread()

// NBD_DO_IT does not return until disconnect
if err := ioctl(f.Fd(), ioctlDoIt, 0); err != nil {
return &os.PathError{
Path: f.Name(),
Op: "ioctl NBD_DO_IT",
Err: err,
}
clog.Errorf("error %s: ioctl returned %v", f.Name(), err)
}

clog.Debugf("Running disconnection to %s", f.Name())

if err := ioctl(f.Fd(), ioctlClearQueue, 0); err != nil {
return &os.PathError{
Path: f.Name(),
Op: "ioctl NBD_CLEAR_QUEUE",
Err: err,
}
clog.Errorf("error clear queue for %s. ioctl returned: %v", f.Name(), err)
}
if err := ioctl(f.Fd(), ioctlClearSock, 0); err != nil {
return &os.PathError{
Path: f.Name(),
Op: "ioctl NBD_CLEAR_SOCK",
Err: err,
}
clog.Errorf("error clear socket for %s. ioctl returned: %v", f.Name(), err)
}
return nil
}

type serverConn struct {
Expand Down

0 comments on commit e449e89

Please sign in to comment.