about summary refs log tree commit
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2007-08-22 10:34:20 -0700
committerEric Wong <normalperson@yhbt.net>2007-08-22 10:34:20 -0700
commit6dab29fb11bec8cecb5fc8ae5013cb88f31701b3 (patch)
tree764a1840c7361ec03ac330a999504b96f7a1b045
parent6d2780bf8c9aeb3489bdf61698eef5281de7d39d (diff)
downloaddavid-6dab29fb11bec8cecb5fc8ae5013cb88f31701b3.tar.gz
make configuration constants dynamically assignable HEAD master
This will eventually allow us to tweak things easily w/o
recompiling
-rw-r--r--david.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/david.c b/david.c
index 5c8c43d..bda4624 100644
--- a/david.c
+++ b/david.c
@@ -10,25 +10,25 @@
  *
  * NR_CONN needs to be <= (FD_SETSIZE - 4)
  */
-#define MAX_CHILDREN 1
-#define NR_CONN 1000
+static int MAX_CHILDREN = 1;
+static int NR_CONN = 1000;
 
 /*
  * the delay between subsequent send/recv() calls to each socket,
  * assuming the socket is write/readable
  */
-#define DELAY_SECONDS 1
+static int DELAY_SECONDS = 1;
 
 /* the maximum number of bytes we write at once */
-#define WR_BYTES 8
+static int WR_BYTES = 8;
 
 /* the maximum number of bytes we read at once */
-#define RD_BYTES 8
+static int RD_BYTES = 8;
 
 /*
  * set this to 1 to enable printing of requests and responses to stdout
  */
-#define DEBUG 1
+static int DEBUG = 0;
 
 /* -------- end of configuration section --------- */
 
@@ -77,8 +77,8 @@ struct interface {
         time_t last;
 };
 
-struct interface interfaces[NR_CONN];
-static pid_t children_pids[MAX_CHILDREN];
+static struct interface *interfaces;
+static pid_t *children_pids;
 
 static void die(const char *fmt, ...)
 {
@@ -187,6 +187,8 @@ static void init_interface(const int i)
 static void open_interfaces(void)
 {
         int i;
+
+        interfaces = malloc(sizeof(struct interface) * NR_CONN);
         for (i = 0; i < NR_CONN; ++i)
                 init_interface(i);
 }
@@ -304,6 +306,7 @@ int main(int argc, const char *argv[])
 
         mmap_request(argv[1]);
         setup_addrinfo();
+        children_pids = malloc(sizeof(pid_t) * MAX_CHILDREN);
 
         for (i = 0; i < MAX_CHILDREN; ++i) {
                 fflush(NULL);