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
commit63a3064bdaf6547a3257c62c542b7657fc3992d9 (patch)
tree9e72a63d70d854c590a0d5dea20fe319cf05387f
parent610ff0b10e08dc5e9321e819f338acc0bd805c14 (diff)
downloadpttbbs-63a3064bdaf6547a3257c62c542b7657fc3992d9.tar
pttbbs-63a3064bdaf6547a3257c62c542b7657fc3992d9.tar.gz
pttbbs-63a3064bdaf6547a3257c62c542b7657fc3992d9.tar.bz2
pttbbs-63a3064bdaf6547a3257c62c542b7657fc3992d9.tar.lz
pttbbs-63a3064bdaf6547a3257c62c542b7657fc3992d9.tar.xz
pttbbs-63a3064bdaf6547a3257c62c542b7657fc3992d9.tar.zst
pttbbs-63a3064bdaf6547a3257c62c542b7657fc3992d9.zip
check lock when get_record
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk@680 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttbbs/mbbsd/record.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/pttbbs/mbbsd/record.c b/pttbbs/mbbsd/record.c
index cc82cde8..61f58dbc 100644
--- a/pttbbs/mbbsd/record.c
+++ b/pttbbs/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;