From 34dbf8a60f7c3cbd24e65f7f143003ff4b4e863e Mon Sep 17 00:00:00 2001 From: Alex Pyrgiotis Date: Thu, 18 Apr 2013 18:34:17 +0300 Subject: [PATCH] bench: Fix issuing of read/write requests Due to no initialization of struct bench, some "ifs" in the code would show different behavior depending on the junk values they would check. Now however, there is proper initialization of struct bench. --- xseg/peers/user/bench-utils.c | 4 ++-- xseg/peers/user/bench-xseg.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/xseg/peers/user/bench-utils.c b/xseg/peers/user/bench-utils.c index d857269..d3dbb3d 100644 --- a/xseg/peers/user/bench-utils.c +++ b/xseg/peers/user/bench-utils.c @@ -73,7 +73,7 @@ static inline uint64_t __get_object_from_name(char *name) static inline uint64_t __get_object(struct bench *prefs, uint64_t new) { - if (prefs->to < 0) + if (prefs->ts > 0) new = new / (prefs->os / prefs->bs); return new; } @@ -402,7 +402,7 @@ uint64_t determine_next(struct bench *prefs) uint64_t calculate_offset(struct bench *prefs, uint64_t new) { - if (prefs->to < 0) + if (prefs->ts > 0) return (new * prefs->bs) % prefs->os; else return 0; diff --git a/xseg/peers/user/bench-xseg.c b/xseg/peers/user/bench-xseg.c index f78059e..365b681 100644 --- a/xseg/peers/user/bench-xseg.c +++ b/xseg/peers/user/bench-xseg.c @@ -140,13 +140,14 @@ int custom_peer_init(struct peerd *peer, int argc, char *argv[]) perror("malloc"); return -1; } - prefs->flags = 0; + memset(prefs, 0, sizeof(struct bench)); prefs->status = malloc(sizeof(struct req_status)); if (!prefs->status) { perror("malloc"); return -1; } + memset(prefs->status, 0, sizeof(struct req_status)); //Begin reading the benchmark-specific arguments @@ -267,7 +268,7 @@ int custom_peer_init(struct peerd *peer, int argc, char *argv[]) } else if (total_size[0]) { if (prefs->op != X_READ && prefs->op != X_WRITE) { XSEGLOG2(&lc, E, - "Total objects must be supplied (required by op %s)\n", op); + "Total objects must be supplied (required by -op %s)\n", op); goto arg_fail; } prefs->ts = str2num(total_size); -- 1.7.10.4