mercurial/posix.py
changeset 45718 87c35b5a14eb
parent 45717 755214a84b9d
child 45942 89a2afe31e82
equal deleted inserted replaced
45717:755214a84b9d 45718:87c35b5a14eb
   762     # use relative path instead of full path at bind() if possible, since
   762     # use relative path instead of full path at bind() if possible, since
   763     # AF_UNIX path has very small length limit (107 chars) on common
   763     # AF_UNIX path has very small length limit (107 chars) on common
   764     # platforms (see sys/un.h)
   764     # platforms (see sys/un.h)
   765     dirname, basename = os.path.split(path)
   765     dirname, basename = os.path.split(path)
   766     bakwdfd = None
   766     bakwdfd = None
   767     if dirname:
   767 
   768         bakwdfd = os.open(b'.', os.O_DIRECTORY)
   768     try:
   769         os.chdir(dirname)
   769         if dirname:
   770     sock.bind(basename)
   770             bakwdfd = os.open(b'.', os.O_DIRECTORY)
   771     if bakwdfd:
   771             os.chdir(dirname)
   772         os.fchdir(bakwdfd)
   772         sock.bind(basename)
   773         os.close(bakwdfd)
   773         if bakwdfd:
       
   774             os.fchdir(bakwdfd)
       
   775     finally:
       
   776         if bakwdfd:
       
   777             os.close(bakwdfd)