1 --- python-1.5.2/Modules/fcntlmodule.c.orig Wed Jan 6 13:44:23 1999
2 +++ python-1.5.2/Modules/fcntlmodule.c Sun Apr 1 07:42:54 2001
5 int fd, code, ret, whence = 0;
6 PyObject *lenobj = NULL, *startobj = NULL;
9 if (!PyArg_ParseTuple(args, "ii|OOi", &fd, &code,
10 &lenobj, &startobj, &whence))
14 -#define LOCK_SH 1 /* shared lock */
15 -#define LOCK_EX 2 /* exclusive lock */
16 -#define LOCK_NB 4 /* don't block when locking */
17 -#define LOCK_UN 8 /* unlock */
21 - if (code == LOCK_UN)
23 - else if (code & LOCK_SH)
25 - else if (code & LOCK_EX)
28 - PyErr_SetString(PyExc_ValueError,
29 - "unrecognized flock argument");
32 l.l_start = l.l_len = 0;
33 if (startobj != NULL) {
34 #if !defined(HAVE_LARGEFILE_SUPPORT)
42 + /* Test the lock: return 0 if FD is unlocked or locked by this process;
43 + return -1, set errno to EACCES, if another process holds the lock. */
44 + if (fcntl (fd, F_GETLK, &l) < 0) {
45 + PyErr_SetFromErrno(PyExc_IOError);
48 + if (l.l_type == F_UNLCK || l.l_pid == getpid ()) {
53 + PyErr_SetFromErrno(PyExc_IOError);
70 + PyErr_SetString(PyExc_ValueError,
71 + "unrecognized flock argument");
74 Py_BEGIN_ALLOW_THREADS
75 - ret = fcntl(fd, (code & LOCK_NB) ? F_SETLK : F_SETLKW, &l);
76 + ret = fcntl(fd, code, &l);
81 PyErr_SetFromErrno(PyExc_IOError);