diff options
author | Eric Wong <normalperson@yhbt.net> | 2007-08-22 10:34:20 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2007-08-22 10:34:20 -0700 |
commit | 6dab29fb11bec8cecb5fc8ae5013cb88f31701b3 (patch) | |
tree | 764a1840c7361ec03ac330a999504b96f7a1b045 | |
parent | 6d2780bf8c9aeb3489bdf61698eef5281de7d39d (diff) | |
download | david-master.tar.gz |
This will eventually allow us to tweak things easily w/o recompiling
-rw-r--r-- | david.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -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); |