Merge pull request #1410 from teawater/vmcache_endpoint

VMCache: check if vm_cache_endpoint file exists before VMCache server…
This commit is contained in:
Peng Tao
2019-04-03 11:21:42 +08:00
committed by GitHub

View File

@@ -79,7 +79,10 @@ func getUnixListener(path string) (net.Listener, error) {
if err != nil {
return nil, err
}
if err = unix.Unlink(path); err != nil && !os.IsNotExist(err) {
_, err = os.Stat(path)
if err == nil {
return nil, fmt.Errorf("%s already exist. Please stop running VMCache server and remove %s", path, path)
} else if !os.IsNotExist(err) {
return nil, err
}
l, err := net.Listen("unix", path)