summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-07-26 17:33:44 (GMT)
committerGuido van Rossum <guido@python.org>1995-07-26 17:33:44 (GMT)
commit07b14dd8bc1cd695c316c22e6a4489f4e1bfc13e (patch)
tree26f0750639bbfa6ef451942fd242956a58251a72 /Modules
parentef38b78f944156ae84e66c7e827bf1df0149f3c9 (diff)
downloadcpython-07b14dd8bc1cd695c316c22e6a4489f4e1bfc13e.zip
cpython-07b14dd8bc1cd695c316c22e6a4489f4e1bfc13e.tar.gz
cpython-07b14dd8bc1cd695c316c22e6a4489f4e1bfc13e.tar.bz2
add locking where it exists
Diffstat (limited to 'Modules')
-rw-r--r--Modules/dbhashmodule.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/Modules/dbhashmodule.c b/Modules/dbhashmodule.c
index e04cebc..a8df027 100644
--- a/Modules/dbhashmodule.c
+++ b/Modules/dbhashmodule.c
@@ -334,19 +334,30 @@ dbhashopen(self, args)
return NULL;
if (flag != NULL) {
/* XXX need a way to pass O_EXCL, O_EXLOCK, O_NONBLOCK, O_SHLOCK */
- if (strcmp(flag, "r") == 0)
+ if (flag[0] == 'r')
flags = O_RDONLY;
- else if (strcmp(flag, "w") == 0)
+ else if (flag[0] == 'w')
flags = O_RDWR;
- else if (strcmp(flag, "c") == 0)
+ else if (flag[0] == 'c')
flags = O_RDWR|O_CREAT;
- else if (strcmp(flag, "n") == 0)
+ else if (flag[0] == 'n')
flags = O_RDWR|O_CREAT|O_TRUNC;
else {
err_setstr(DbhashError,
- "Flag should be one of 'r', 'w', 'c' or 'n'");
+ "Flag should begin with 'r', 'w', 'c' or 'n'");
return NULL;
}
+ if (flag[1] == 'l') {
+#if defined(O_EXLOCK) && defined(O_SHLOCK)
+ if (flag[0] == 'r')
+ flags |= O_SHLOCK;
+ else
+ flags |= O_EXLOCK;
+#else
+ err_setstr(DbhashError, "locking not supported on this platform");
+ return NULL;
+#endif
+ }
}
return newdbhashobject(file, flags, mode,
bsize, ffactor, nelem, cachesize, hash, lorder);