Lines 79-85
Link Here
|
79 |
except IOError, e: |
79 |
except IOError, e: |
80 |
if "errno" not in dir(e): |
80 |
if "errno" not in dir(e): |
81 |
raise |
81 |
raise |
82 |
if e.errno == errno.EAGAIN: |
82 |
if e.errno in (errno.EACCES, errno.EAGAIN): |
83 |
# resource temp unavailable; eg, someone beat us to the lock. |
83 |
# resource temp unavailable; eg, someone beat us to the lock. |
84 |
if waiting_msg is None: |
84 |
if waiting_msg is None: |
85 |
if isinstance(mypath, int): |
85 |
if isinstance(mypath, int): |
Lines 111-117
Link Here
|
111 |
|
111 |
|
112 |
|
112 |
|
113 |
if type(lockfilename) == types.StringType and \ |
113 |
if type(lockfilename) == types.StringType and \ |
114 |
myfd != HARDLINK_FD and os.fstat(myfd).st_nlink == 0: |
114 |
myfd != HARDLINK_FD and _fstat_nlink(myfd) == 0: |
115 |
# The file was deleted on us... Keep trying to make one... |
115 |
# The file was deleted on us... Keep trying to make one... |
116 |
os.close(myfd) |
116 |
os.close(myfd) |
117 |
portage_util.writemsg("lockfile recurse\n",1) |
117 |
portage_util.writemsg("lockfile recurse\n",1) |
Lines 122-127
Link Here
|
122 |
portage_util.writemsg(str((lockfilename,myfd,unlinkfile))+"\n",1) |
122 |
portage_util.writemsg(str((lockfilename,myfd,unlinkfile))+"\n",1) |
123 |
return (lockfilename,myfd,unlinkfile,locking_method) |
123 |
return (lockfilename,myfd,unlinkfile,locking_method) |
124 |
|
124 |
|
|
|
125 |
def _fstat_nlink(fd): |
126 |
""" |
127 |
@param fd: an open file descriptor |
128 |
@type fd: Integer |
129 |
@rtype: Integer |
130 |
@return: the current number of hardlinks to the file |
131 |
""" |
132 |
try: |
133 |
return os.fstat(fd).st_nlink |
134 |
except EnvironmentError, e: |
135 |
if e.errno == errno.ENOENT: |
136 |
# Some filesystems such as CIFS return |
137 |
# ENOENT which means st_nlink == 0. |
138 |
return 0 |
139 |
raise |
140 |
|
125 |
def unlockfile(mytuple): |
141 |
def unlockfile(mytuple): |
126 |
import fcntl |
142 |
import fcntl |
127 |
|
143 |
|
Lines 167-173
Link Here
|
167 |
# We won the lock, so there isn't competition for it. |
183 |
# We won the lock, so there isn't competition for it. |
168 |
# We can safely delete the file. |
184 |
# We can safely delete the file. |
169 |
portage_util.writemsg("Got the lockfile...\n",1) |
185 |
portage_util.writemsg("Got the lockfile...\n",1) |
170 |
if os.fstat(myfd).st_nlink == 1: |
186 |
if _fstat_nlink(myfd) == 1: |
171 |
os.unlink(lockfilename) |
187 |
os.unlink(lockfilename) |
172 |
portage_util.writemsg("Unlinked lockfile...\n",1) |
188 |
portage_util.writemsg("Unlinked lockfile...\n",1) |
173 |
locking_method(myfd,fcntl.LOCK_UN) |
189 |
locking_method(myfd,fcntl.LOCK_UN) |