Revision 227647ac

b/daemons/ganeti-masterd
445 445
        raise errors.GenericError("Cannot create socket directory"
446 446
          " '%s': %s" % (constants.SOCKET_DIR, err))
447 447

  
448
    # This is safe to do as the pid file guarantees against
449
    # concurrent execution.
450
    utils.RemoveFile(constants.MASTER_SOCKET)
451

  
448 452
    master = IOServer(constants.MASTER_SOCKET, ClientRqHandler)
449 453
  finally:
450 454
    rpc.Shutdown()
......
477 481
      rpc.Shutdown()
478 482
  finally:
479 483
    utils.RemovePidFile(constants.MASTERD_PID)
484
    utils.RemoveFile(constants.MASTER_SOCKET)
480 485

  
481 486

  
482 487
if __name__ == "__main__":
b/lib/constants.py
99 99
ETC_HOSTS = "/etc/hosts"
100 100
DEFAULT_FILE_STORAGE_DIR = _autoconf.FILE_STORAGE_DIR
101 101

  
102
# Quoting unix(7) on Linux:
103
#   Linux also supports an abstract namespace which is independent of the file
104
#   system. [...] If sun_path starts with a null byte ('\0'), then it refers to
105
#   the abstract namespace maintained by the Unix protocol module. The socket's
106
#   address in this namespace is given by the rest of the bytes in sun_path.
107
#
108
# By using this Linux-specific way we don't have to care about removing the
109
# socket file when quitting or starting (after an unclean shutdown).
110
#
111
# Sample output for "netstat -nlp":
112
#   unix 2 [ ACC ] STREAM LISTENING 247919 1234/python @ganeti-master
113
MASTER_SOCKET = "\0ganeti-master"
102
MASTER_SOCKET = SOCKET_DIR + "/ganeti-master"
114 103

  
115 104
# PID files
116 105
MASTERD_PID = "ganeti-masterd"

Also available in: Unified diff