Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/blacklist/bin sync only when idle or every 100 ...



details:   https://anonhg.NetBSD.org/src/rev/0de0b7967ca5
branches:  trunk
changeset: 805942:0de0b7967ca5
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Jan 24 07:46:20 2015 +0000

description:
sync only when idle or every 100 turns.

diffstat:

 external/bsd/blacklist/bin/blacklistd.c |   9 ++++++---
 external/bsd/blacklist/bin/state.c      |  21 ++++++++++++++-------
 external/bsd/blacklist/bin/state.h      |   3 ++-
 3 files changed, 22 insertions(+), 11 deletions(-)

diffs (116 lines):

diff -r a916599bf99c -r 0de0b7967ca5 external/bsd/blacklist/bin/blacklistd.c
--- a/external/bsd/blacklist/bin/blacklistd.c   Sat Jan 24 07:31:51 2015 +0000
+++ b/external/bsd/blacklist/bin/blacklistd.c   Sat Jan 24 07:46:20 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: blacklistd.c,v 1.27 2015/01/23 22:34:13 christos Exp $ */
+/*     $NetBSD: blacklistd.c,v 1.28 2015/01/24 07:46:20 christos Exp $ */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "config.h"
 #endif
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: blacklistd.c,v 1.27 2015/01/23 22:34:13 christos Exp $");
+__RCSID("$NetBSD: blacklistd.c,v 1.28 2015/01/24 07:46:20 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -415,7 +415,7 @@
                        err(EXIT_FAILURE, "Can't create pidfile");
        }
 
-       while (!done) {
+       for (size_t t = 0; !done; t++) {
                if (rconf) {
                        rconf = 0;
                        conf_parse(configfile);
@@ -427,12 +427,15 @@
                        (*lfun)(LOG_ERR, "poll (%m)");
                        return EXIT_FAILURE;
                case 0:
+                       state_sync(state);
                        break;
                default:
                        for (size_t i = 0; i < nfd; i++)
                                if (pfd[i].revents & POLLIN)
                                        process(bl[i]);
                }
+               if (t % 100 == 0)
+                       state_sync(state);
                update();
        }
        state_close(state);
diff -r a916599bf99c -r 0de0b7967ca5 external/bsd/blacklist/bin/state.c
--- a/external/bsd/blacklist/bin/state.c        Sat Jan 24 07:31:51 2015 +0000
+++ b/external/bsd/blacklist/bin/state.c        Sat Jan 24 07:46:20 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: state.c,v 1.12 2015/01/24 07:31:51 christos Exp $      */
+/*     $NetBSD: state.c,v 1.13 2015/01/24 07:46:20 christos Exp $      */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: state.c,v 1.12 2015/01/24 07:31:51 christos Exp $");
+__RCSID("$NetBSD: state.c,v 1.13 2015/01/24 07:46:20 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -152,11 +152,11 @@
 
        switch (rv = (*db->del)(db, &k, 0)) {
        case 0:
-               (*db->sync)(db, 0);
-               /*FALLTHROUGH*/
        case 1:
-               if (debug > 1)
+               if (debug > 1) {
                        (*lfun)(LOG_DEBUG, "%s: returns %d", __func__, rv);
+                       (*db->sync)(db, 0);
+               }
                return 0;
        default:
                (*lfun)(LOG_ERR, "%s: failed (%m)", __func__);
@@ -216,9 +216,10 @@
 
        switch (rv = (*db->put)(db, &k, &v, 0)) {
        case 0:
-               if (debug > 1)
+               if (debug > 1) {
                        (*lfun)(LOG_DEBUG, "%s: returns %d", __func__, rv);
-               (*db->sync)(db, 0);
+                       (*db->sync)(db, 0);
+               }
                return 0;
        case 1:
                errno = EEXIST;
@@ -262,3 +263,9 @@
                return -1;
        }
 }
+
+int
+state_sync(DB *db)
+{
+       return (*db->sync)(db, 0);
+}
diff -r a916599bf99c -r 0de0b7967ca5 external/bsd/blacklist/bin/state.h
--- a/external/bsd/blacklist/bin/state.h        Sat Jan 24 07:31:51 2015 +0000
+++ b/external/bsd/blacklist/bin/state.h        Sat Jan 24 07:46:20 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: state.h,v 1.3 2015/01/22 03:08:09 christos Exp $       */
+/*     $NetBSD: state.h,v 1.4 2015/01/24 07:46:20 christos Exp $       */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -59,6 +59,7 @@
 int state_del(DB *, const struct sockaddr_storage *, const struct conf *);
 int state_iterate(DB *, struct sockaddr_storage *, struct conf *,
     struct dbinfo *, unsigned int);
+int state_sync(DB *);
 __END_DECLS
 
 #endif /* _STATE_H */



Home | Main Index | Thread Index | Old Index