Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graduate 3rd party device monitoring plugins to beta! #77274

Changes from 1 commit
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.


Just for now


Fix improper cleanup when creating a unix socket

  • Loading branch information...
RenaudWasTaken committed May 30, 2019
commit a03d2d4d4e5109cdeae362a1540b3a80ea44985a
@@ -20,6 +20,7 @@ package util

import (
@@ -51,7 +52,30 @@ func CreateListener(endpoint string) (net.Listener, error) {
return nil, fmt.Errorf("failed to unlink socket file %q: %v", addr, err)

return net.Listen(protocol, addr)
if err := os.MkdirAll(filepath.Dir(addr), 0750); err != nil {
return nil, fmt.Errorf("error creating socket directory %q: %v", filepath.Dir(addr), err)

// Create the socket on a tempfile and move it to the destination socket to handle improprer cleanup
file, err := ioutil.TempFile(filepath.Dir(addr), "")
if err != nil {
return nil, fmt.Errorf("failed to create temporary file: %v", err)

if err := os.Remove(file.Name()); err != nil {
return nil, fmt.Errorf("failed to remove temporary file: %v", err)

l, err := net.Listen(protocol, file.Name())
if err != nil {
return nil, err

if err = os.Rename(file.Name(), addr); err != nil {
return nil, fmt.Errorf("failed to move temporary file to addr %q: %v", addr, err)

return l, nil

// GetAddressAndDialer returns the address parsed from the given endpoint and a dialer.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.