]> git.pond.sub.org Git - empserver/commitdiff
(file_lock, file_unlock, ef_lock, ef_unlock, commlock, communlock):
authorMarkus Armbruster <armbru@pond.sub.org>
Thu, 29 Jan 2004 17:07:26 +0000 (17:07 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 29 Jan 2004 17:07:26 +0000 (17:07 +0000)
File locking doesn't make sense, must be a leftover from the distant
past.  Remove.  Callers changed.

include/file.h
include/nat.h
include/prototypes.h
src/lib/commands/diss.c
src/lib/commands/mult.c
src/lib/commands/set.c
src/lib/common/file.c
src/lib/gen/Makefile
src/lib/gen/lock.c [deleted file]
src/lib/subs/comsub.c
src/lib/subs/distrea.c

index 4adc033dc5717d9bfb67179d20d56879d9daad01..f67032760bed05537c21374d3d414ade218e147a 100644 (file)
@@ -105,8 +105,6 @@ extern int ef_extend(int, int);
 extern void ef_zapcache(int);
 extern int ef_nelem(int);
 extern int ef_flags(int);
-extern int ef_lock(int);
-extern int ef_unlock(int);
 extern int ef_vars(int, register s_char *, u_char **,
                   u_char **, u_short **);
 extern int ef_byname(s_char *);
index 242f3bb7482a9d0cfd83f590b860bf90ba7e332d..891715a68ab3d9fcd826b51e93f791d31cb2446d 100644 (file)
@@ -175,8 +175,6 @@ extern double reltech(int level1, int level2, double mult);
 extern double multread(natid, natid);
 extern int commread(void);
 extern int commwrite(void);
-extern int commlock(void);
-extern int communlock(void);
 extern int commamt(natid, int, float *);
 extern void commset(natid, int, int);
 extern void multset(natid, float);
index c717185d25afa9e1c5b8ccf82b9be905034fd1fb..baa069ca89dda3097f5fb9626e2f44f1bc6c9faa 100644 (file)
@@ -418,8 +418,6 @@ extern s_char *getstring(s_char *, s_char *);
 #if !defined(_WIN32)
 extern s_char *inet_ntoa(struct in_addr);
 #endif
-extern int file_lock(int);
-extern int file_unlock(int);
 extern int diffx(int, int);
 extern int diffy(int, int);
 extern int deltax(int, int);
index f87586238d5247ba2d3c7b6ac1ad95053d9cdde6..1099e183dc30f91f2e80100da2c104a906341fa4 100644 (file)
@@ -238,14 +238,12 @@ diss(void)
        putloan(ni.cur, &loan);
     }
     /* clean up commodity and trade for this nation. */
-    commlock();
     commread();
     for (n = 1; n < I_MAX + 1; n++) {
        val = commamt(player->cnum, n, &dummy);
        commset(player->cnum, n, -val);
     }
     commwrite();
-    communlock();
     snxtitem_all(&ni, EF_TRADE);
     while (nxtitem(&ni, (s_char *)&trade)) {
        if (trade.trd_unitid >= 0 && trade.trd_owner == player->cnum) {
index f2d7f5770d7a11c7bd478d3b880c429d9ea5a7f8..3c51d5ae9e2b27325504daca630e1bbb66e5312e 100644 (file)
@@ -105,12 +105,7 @@ multsingle(natid us, natid them, struct natstr *natp)
        price = minmult;
     if (price >= maxmult)
        price = maxmult;
-    if (!commlock()) {
-       pr("Unable to lock commodity file; get help!\n");
-       return;
-    }
     if (commread() < 0) {
-       (void)communlock();
        pr("Unable to re-read commodity file; get help!\n");
        return;
     }
@@ -118,5 +113,4 @@ multsingle(natid us, natid them, struct natstr *natp)
     if (commwrite() < 0) {
        pr("Unable to write out commodity file; get help!\n");
     }
-    (void)communlock();
 }
index dde4b40428d8562c9fe1bf0ecee80a4d79f49e17..3dbeb4ac26896f1e13e83a540bb1f35bcf31867f 100644 (file)
@@ -127,10 +127,6 @@ set(void)
        }
        if ((price = atoi(p)) < 0)
            continue;
-       if (!ef_lock(EF_TRADE)) {
-           logerror("can't lock trade file");
-           return RET_SYS;
-       }
        foundslot = -1;
        freeslot = -1;
        snxtitem_all(&ni_trade, EF_TRADE);
@@ -178,7 +174,6 @@ set(void)
               trade_nameof(&trade, &item), ni.cur,
               id, foundslot >= 0 ? "reset" : "set", price);
        }
-       ef_unlock(EF_TRADE);
     }
     return RET_OK;
 }
index 677a456bb6c734045068ac43b8c904fe73730926..faf782b2a91bfcdae2a38ef01a488026140b02d3 100644 (file)
@@ -421,18 +421,6 @@ ef_flags(int type)
     return empfile[type].flags;
 }
 
-int
-ef_lock(int type)
-{
-    return file_lock(empfile[type].fd);
-}
-
-int
-ef_unlock(int type)
-{
-    return file_unlock(empfile[type].fd);
-}
-
 time_t
 ef_mtime(int type)
 {
index 37e01c88ec065dd4423fee6333afac66560ed8a5..c0ee62e3b58e337be299a1e9f650a27beefe7643 100644 (file)
@@ -37,13 +37,13 @@ NTLIB = $(SRCDIR)\lib\libgen.lib
 
 OBJS =  atoip.o chance.o copy.o disassoc.o dtable.o \
        emp_config.o getstarg.o getstring.o inet.o io.o \
-       io_mask.o ioqueue.o lock.o mapdist.o minmax.o numstr.o onearg.o \
+       io_mask.o ioqueue.o mapdist.o minmax.o numstr.o onearg.o \
        parse.o plur.o queue.o round.o scthash.o \
        strdup.o
 
 NTOBJS = atoip.obj chance.obj copy.obj disassoc.obj dtable.obj \
        emp_config.obj getstarg.obj getstring.obj \
-       inet.obj io.obj io_mask.obj ioqueue.obj lock.obj mapdist.obj minmax.obj \
+       inet.obj io.obj io_mask.obj ioqueue.obj mapdist.obj minmax.obj \
        numstr.obj onearg.obj parse.obj plur.obj queue.obj round.obj \
        scthash.obj strdup.obj
 
diff --git a/src/lib/gen/lock.c b/src/lib/gen/lock.c
deleted file mode 100644 (file)
index c3015f8..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
- *
- *  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
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- *  ---
- *
- *  See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
- *  related information and legal notices. It is expected that any future
- *  projects/authors will amend these files as needed.
- *
- *  ---
- *
- *  lock.c: Lock a file
- * 
- *  Known contributors to this file:
- *      Doug Hay, 1998
- */
-
-#ifdef aix
-#define L_SET 0
-#endif /* aix */
-
-#include "misc.h"
-#include "gen.h"
-#include "common.h"
-#include <fcntl.h>
-
-#ifdef sys5
-#include <unistd.h>
-#endif
-#if !defined(L_SET) && !defined(_WIN32)
-#include <sys/file.h>
-#endif
-
-#ifdef aix
-#define L_SET 0
-#endif /* aix */
-
-#if defined(_WIN32)
-#include <sys/locking.h>
-
-int
-file_lock(int fd)
-{
-    if (_locking(fd, _LK_LOCK, 0) < 0) {
-       logerror("file lock (fd %d) failed", fd);
-       return 0;
-    }
-    return 1;
-}
-
-int
-file_unlock(int fd)
-{
-    if (_locking(fd, _LK_UNLCK, 0) < 0) {
-       logerror("file lock (fd %d) failed", fd);
-       return 0;
-    }
-    return 1;
-}
-
-#else
-
-#ifndef NOFLOCK
-
-int flock();
-
-int
-file_lock(int fd)
-{
-    if (flock(fd, LOCK_EX) < 0) {
-       logerror("file lock (fd %d) failed", fd);
-       return 0;
-    }
-    return 1;
-}
-
-int
-file_unlock(int fd)
-{
-    if (flock(fd, LOCK_UN) < 0) {
-       logerror("file unlock (fd %d) failed", fd);
-       return 0;
-    }
-    return 1;
-}
-
-#else
-
-int
-file_lock(int fd)
-{
-    struct flock lock;
-
-    lock.l_type = F_WRLCK;
-    lock.l_whence = L_SET;
-    lock.l_start = 0;
-    lock.l_len = 0;
-    lock.l_pid = 0;
-    if (fcntl(fd, F_SETLKW, &lock) < 0) {
-       logerror("file lock (fd %d) failed", fd);
-       return 0;
-    }
-    return 1;
-}
-
-int
-file_unlock(int fd)
-{
-    struct flock lock;
-
-    lock.l_type = F_UNLCK;
-    lock.l_whence = L_SET;
-    lock.l_start = 0;
-    lock.l_len = 0;
-    lock.l_pid = 0;
-    if (fcntl(fd, F_SETLKW, &lock) < 0) {
-       logerror("file unlock (fd %d) failed", fd);
-       return 0;
-    }
-    return 1;
-}
-#endif
-
-#endif /* _WIN32 */
index 9cbc790ee1665fb394e2d8c0d0f60dbd7e80d079..641105891c1ad7d6048668cb4a718f2fa4d8726a 100644 (file)
@@ -129,18 +129,6 @@ commwrite(void)
     return 0;
 }
 
-int
-commlock(void)
-{
-    return file_lock(commf);
-}
-
-int
-communlock(void)
-{
-    return file_unlock(commf);
-}
-
 /*
  * returns amount of commodity, and price to the user
  */
index 2ee977021b2ff52b0ba47b72276ffef5b1b6d47c..af7e4a4f82642b340a8af8084e06b255bd5cb8cd 100644 (file)
@@ -55,17 +55,11 @@ distrea(int n, register struct trtstr *tp)
        return 0;
     (void)time(&now);
     if (now > tp->trt_exp) {
-       if (!ef_lock(EF_TREATY)) {
-           pr("Can't lock treaty file; get help!\n");
-           return 0;
-       }
        tp->trt_status = TS_FREE;
        if (!puttre(n, tp)) {
            pr("Couldn't save treaty; get help!\n");
-           (void)ef_unlock(EF_TREATY);
            return 0;
        }
-       (void)ef_unlock(EF_TREATY);
        pr("Treaty #%d expired %s", n, ctime(&tp->trt_exp));
        return 0;
     }