1 |
Author: zmedico |
2 |
Date: 2008-03-27 04:50:32 +0000 (Thu, 27 Mar 2008) |
3 |
New Revision: 9518 |
4 |
|
5 |
Modified: |
6 |
main/branches/2.1.2/pym/portage_locks.py |
7 |
Log: |
8 |
Bug #212882 |
9 |
|
10 |
- For compatibility with ENOENT exceptions raised from |
11 |
fstat calls with CIFS, wrap fstat calls with an appropriate exception |
12 |
handler. (trunk r9474) |
13 |
|
14 |
- Fix lockfile() to handle errno.EACCES raised from the fcntl |
15 |
call since the spec says that it's equivalent to EAGAIN and it appears that |
16 |
CIFS returns EACCES in this case. (trunk r9458) |
17 |
|
18 |
|
19 |
Modified: main/branches/2.1.2/pym/portage_locks.py |
20 |
=================================================================== |
21 |
--- main/branches/2.1.2/pym/portage_locks.py 2008-03-27 04:41:17 UTC (rev 9517) |
22 |
+++ main/branches/2.1.2/pym/portage_locks.py 2008-03-27 04:50:32 UTC (rev 9518) |
23 |
@@ -79,7 +79,7 @@ |
24 |
except IOError, e: |
25 |
if "errno" not in dir(e): |
26 |
raise |
27 |
- if e.errno == errno.EAGAIN: |
28 |
+ if e.errno in (errno.EACCES, errno.EAGAIN): |
29 |
# resource temp unavailable; eg, someone beat us to the lock. |
30 |
if waiting_msg is None: |
31 |
if isinstance(mypath, int): |
32 |
@@ -111,7 +111,7 @@ |
33 |
|
34 |
|
35 |
if type(lockfilename) == types.StringType and \ |
36 |
- myfd != HARDLINK_FD and os.fstat(myfd).st_nlink == 0: |
37 |
+ myfd != HARDLINK_FD and _fstat_nlink(myfd) == 0: |
38 |
# The file was deleted on us... Keep trying to make one... |
39 |
os.close(myfd) |
40 |
portage_util.writemsg("lockfile recurse\n",1) |
41 |
@@ -122,6 +122,22 @@ |
42 |
portage_util.writemsg(str((lockfilename,myfd,unlinkfile))+"\n",1) |
43 |
return (lockfilename,myfd,unlinkfile,locking_method) |
44 |
|
45 |
+def _fstat_nlink(fd): |
46 |
+ """ |
47 |
+ @param fd: an open file descriptor |
48 |
+ @type fd: Integer |
49 |
+ @rtype: Integer |
50 |
+ @return: the current number of hardlinks to the file |
51 |
+ """ |
52 |
+ try: |
53 |
+ return os.fstat(fd).st_nlink |
54 |
+ except EnvironmentError, e: |
55 |
+ if e.errno == errno.ENOENT: |
56 |
+ # Some filesystems such as CIFS return |
57 |
+ # ENOENT which means st_nlink == 0. |
58 |
+ return 0 |
59 |
+ raise |
60 |
+ |
61 |
def unlockfile(mytuple): |
62 |
import fcntl |
63 |
|
64 |
@@ -167,7 +183,7 @@ |
65 |
# We won the lock, so there isn't competition for it. |
66 |
# We can safely delete the file. |
67 |
portage_util.writemsg("Got the lockfile...\n",1) |
68 |
- if os.fstat(myfd).st_nlink == 1: |
69 |
+ if _fstat_nlink(myfd) == 1: |
70 |
os.unlink(lockfilename) |
71 |
portage_util.writemsg("Unlinked lockfile...\n",1) |
72 |
locking_method(myfd,fcntl.LOCK_UN) |
73 |
|
74 |
-- |
75 |
gentoo-commits@l.g.o mailing list |