diff options
Diffstat (limited to 'david.c')
-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); |