Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
喜羊羊3508
Dak
提交
a319a419
D
Dak
项目概览
喜羊羊3508
/
Dak
11 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Dak
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a319a419
编写于
2月 11, 2003
作者:
J
James Troup
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update for python's broken lockf()
上级
f2d23dda
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
21 addition
and
91 deletion
+21
-91
contrib/python_1.5.2-fcntl_lockf.diff
contrib/python_1.5.2-fcntl_lockf.diff
+0
-82
jennifer
jennifer
+10
-4
kelly
kelly
+11
-5
未找到文件。
contrib/python_1.5.2-fcntl_lockf.diff
已删除
100644 → 0
浏览文件 @
f2d23dda
--- python-1.5.2/Modules/fcntlmodule.c.orig Wed Jan 6 13:44:23 1999
+++ python-1.5.2/Modules/fcntlmodule.c Sun Apr 1 07:42:54 2001
@@ -233,30 +233,12 @@
{
int fd, code, ret, whence = 0;
PyObject *lenobj = NULL, *startobj = NULL;
+ struct flock l;
if (!PyArg_ParseTuple(args, "ii|OOi", &fd, &code,
&lenobj, &startobj, &whence))
return NULL;
-#ifndef LOCK_SH
-#define LOCK_SH 1 /* shared lock */
-#define LOCK_EX 2 /* exclusive lock */
-#define LOCK_NB 4 /* don't block when locking */
-#define LOCK_UN 8 /* unlock */
-#endif
- {
- struct flock l;
- if (code == LOCK_UN)
- l.l_type = F_UNLCK;
- else if (code & LOCK_SH)
- l.l_type = F_RDLCK;
- else if (code & LOCK_EX)
- l.l_type = F_WRLCK;
- else {
- PyErr_SetString(PyExc_ValueError,
- "unrecognized flock argument");
- return NULL;
- }
l.l_start = l.l_len = 0;
if (startobj != NULL) {
#if !defined(HAVE_LARGEFILE_SUPPORT)
@@ -281,10 +263,45 @@
return NULL;
}
l.l_whence = whence;
+ switch (code)
+ {
+ case F_TEST:
+ /* Test the lock: return 0 if FD is unlocked or locked by this process;
+ return -1, set errno to EACCES, if another process holds the lock. */
+ if (fcntl (fd, F_GETLK, &l) < 0) {
+ PyErr_SetFromErrno(PyExc_IOError);
+ return NULL;
+ }
+ if (l.l_type == F_UNLCK || l.l_pid == getpid ()) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+ errno = EACCES;
+ PyErr_SetFromErrno(PyExc_IOError);
+ return NULL;
+
+ case F_ULOCK:
+ l.l_type = F_UNLCK;
+ code = F_SETLK;
+ break;
+ case F_LOCK:
+ l.l_type = F_WRLCK;
+ code = F_SETLKW;
+ break;
+ case F_TLOCK:
+ l.l_type = F_WRLCK;
+ code = F_SETLK;
+ break;
+
+ default:
+ PyErr_SetString(PyExc_ValueError,
+ "unrecognized flock argument");
+ return NULL;
+ }
Py_BEGIN_ALLOW_THREADS
- ret = fcntl(fd, (code & LOCK_NB) ? F_SETLK : F_SETLKW, &l);
+ ret = fcntl(fd, code, &l);
Py_END_ALLOW_THREADS
- }
+
if (ret < 0) {
PyErr_SetFromErrno(PyExc_IOError);
return NULL;
jennifer
浏览文件 @
a319a419
...
...
@@ -2,7 +2,7 @@
#
Checks
Debian
packages
from
Incoming
#
Copyright
(
C
)
2000
,
2001
,
2002
,
2003
James
Troup
<
james
@
nocrew
.
org
>
#
$
Id
:
jennifer
,
v
1.3
1
2003
-
02
-
07
14
:
53
:
42
troup
Exp
$
#
$
Id
:
jennifer
,
v
1.3
2
2003
-
02
-
11
18
:
10
:
37
troup
Exp
$
#
This
program
is
free
software
;
you
can
redistribute
it
and
/
or
modify
#
it
under
the
terms
of
the
GNU
General
Public
License
as
published
by
...
...
@@ -29,7 +29,7 @@
################################################################################
import
FCNTL
,
errno
,
fcntl
,
gzip
,
os
,
re
,
shutil
,
stat
,
sys
,
time
,
traceback
;
import
errno
,
fcntl
,
gzip
,
os
,
re
,
shutil
,
stat
,
sys
,
time
,
traceback
;
import
apt_inst
,
apt_pkg
;
import
db_access
,
katie
,
logging
,
utils
;
...
...
@@ -45,7 +45,7 @@ re_valid_pkg_name = re.compile(r"^[\dA-Za-z][\dA-Za-z\+\-\.]+$");
################################################################################
#
Globals
jennifer_version
=
"$Revision: 1.3
1
$"
;
jennifer_version
=
"$Revision: 1.3
2
$"
;
Cnf
=
None
;
Options
=
None
;
...
...
@@ -1008,7 +1008,13 @@ def main():
if not Options["No-Action"]:
lock_fd = os.open(Cnf["Dinstall::LockFile"], os.O_RDWR | os.O_CREAT);
fcntl.lockf(lock_fd, FCNTL.F_TLOCK);
try:
fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB);
except IOError, e:
if errno.errorcode[e.errno] == '
EACCES
' or errno.errorcode[e.errno] == '
EAGAIN
':
utils.fubar("Couldn'
t
obtain
lock
;
assuming
another
jennifer
is
already
running
.
");
else:
raise;
Logger = Katie.Logger = logging.Logger(Cnf, "
jennifer
");
# debian-{devel-,}-changes@lists.debian.org toggles writes access based on this header
...
...
kelly
浏览文件 @
a319a419
#
!/usr/bin/env python
#
Installs
Debian
packages
#
Copyright
(
C
)
2000
,
2001
,
2002
James
Troup
<
james
@
nocrew
.
org
>
#
$
Id
:
kelly
,
v
1.
4
2003
-
01
-
02
18
:
12
:
05
troup
Exp
$
#
Copyright
(
C
)
2000
,
2001
,
2002
,
2003
James
Troup
<
james
@
nocrew
.
org
>
#
$
Id
:
kelly
,
v
1.
5
2003
-
02
-
11
18
:
10
:
37
troup
Exp
$
#
This
program
is
free
software
;
you
can
redistribute
it
and
/
or
modify
#
it
under
the
terms
of
the
GNU
General
Public
License
as
published
by
...
...
@@ -32,14 +32,14 @@
###############################################################################
import
FCNTL
,
fcntl
,
os
,
sys
,
time
;
import
fcntl
,
os
,
sys
,
time
;
import
apt_pkg
;
import
db_access
,
katie
,
logging
,
utils
;
###############################################################################
#
Globals
kelly_version
=
"$Revision: 1.
4
$"
;
kelly_version
=
"$Revision: 1.
5
$"
;
Cnf
=
None
;
Options
=
None
;
...
...
@@ -575,7 +575,13 @@ def main():
# Obtain lock if not in no-action mode and initialize the log
if not Options["No-Action"]:
lock_fd = os.open(Cnf["Dinstall::LockFile"], os.O_RDWR | os.O_CREAT);
fcntl.lockf(lock_fd, FCNTL.F_TLOCK);
try:
fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB);
except IOError, e:
if errno.errorcode[e.errno] == '
EACCES
' or errno.errorcode[e.errno] == '
EAGAIN
':
utils.fubar("Couldn'
t
obtain
lock
;
assuming
another
kelly
is
already
running
.
");
else:
raise;
Logger = Katie.Logger = logging.Logger(Cnf, "
katie
");
if not installing_to_stable and Cnf.get("
Dir
::
UrgencyLog
"):
Urgency_Logger = Urgency_Log(Cnf);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录