summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-02-27 18:48:41 +0800
committervictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-02-27 18:48:41 +0800
commit4de1839d301e2cc87ce30121637132a5f5a47791 (patch)
treeb5b6c2d928d66e8f8cc7167b018f29c514ace3b9
parentf7b66a549e691e5195eaeac9c15c88b6ca5beab3 (diff)
downloadpttbbs-4de1839d301e2cc87ce30121637132a5f5a47791.tar
pttbbs-4de1839d301e2cc87ce30121637132a5f5a47791.tar.gz
pttbbs-4de1839d301e2cc87ce30121637132a5f5a47791.tar.bz2
pttbbs-4de1839d301e2cc87ce30121637132a5f5a47791.tar.lz
pttbbs-4de1839d301e2cc87ce30121637132a5f5a47791.tar.xz
pttbbs-4de1839d301e2cc87ce30121637132a5f5a47791.tar.zst
pttbbs-4de1839d301e2cc87ce30121637132a5f5a47791.zip
check lock when get_record
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@680 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/record.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/mbbsd/record.c b/mbbsd/record.c
index cc82cde8..61f58dbc 100644
--- a/mbbsd/record.c
+++ b/mbbsd/record.c
@@ -1,4 +1,4 @@
-/* $Id: record.c,v 1.12 2002/12/31 17:40:51 in2 Exp $ */
+/* $Id: record.c,v 1.13 2003/02/27 10:48:41 victor Exp $ */
#include "bbs.h"
#undef HAVE_MMAP
@@ -78,6 +78,11 @@ get_records(char *fpath, void *rptr, int size, int id, int number)
if (id < 1 || (fd = open(fpath, O_RDONLY, 0)) == -1)
return -1;
+ if( flock(fd, LOCK_EX) < 0 ){
+ close(fd);
+ return -1;
+ }
+
if (lseek(fd, (off_t) (size * (id - 1)), SEEK_SET) == -1) {
close(fd);
return 0;