link with zlib so we can read gzip compressed loadfiles
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 3 Nov 2009 04:25:40 +0000 (15:25 +1100)
committerAndrew Tridgell <tridge@samba.org>
Tue, 8 Dec 2009 05:56:33 +0000 (16:56 +1100)
Makefile.in
child.c
dbench.c

index 109db3fe6e3dc6485d078204082cb9af6d4a31a4..d0871f9fb6b38bec2e4f991f0336b0cf8bd26441 100644 (file)
@@ -10,7 +10,7 @@ mandir=@mandir@
 datadir=@datadir@
 XSLTPROC = /usr/bin/xsltproc
 INSTALLCMD=@INSTALL@
-LIBS=@LIBS@ -lpopt
+LIBS=@LIBS@ -lpopt -lz
 
 CC=@CC@
 CFLAGS=@CFLAGS@ -I. -DVERSION=\"$(VERSION)\" -DDATADIR=\"$(datadir)\"
diff --git a/child.c b/child.c
index 731bf49aab64cf51be47750c7d2549f78991bf8c..211fc5320a476f93ce2423a40ce2dabe94eb3a3f 100644 (file)
--- a/child.c
+++ b/child.c
@@ -26,6 +26,7 @@
 */
 
 #include "dbench.h"
+#include <zlib.h>
 
 #define ival(s) strtol(s, NULL, 0)
 
@@ -142,13 +143,13 @@ void child_run(struct child_struct *child0, const char *loadfile)
        char **sparams, **params;
        char *p;
        const char *status;
-       FILE *f;
+       gzFile *gzf;
        pid_t parent = getppid();
        double targett;
        struct child_struct *child;
 
-       f = fopen(loadfile, "r");
-       if (f == NULL) {
+       gzf = gzopen(loadfile, "r");
+       if (gzf == NULL) {
                perror(loadfile);
                exit(1);
        }
@@ -169,7 +170,7 @@ again:
                nb_time_reset(child);
        }
 
-       while (fgets(line, sizeof(line)-1, f)) {
+       while (gzgets(gzf, line, sizeof(line)-1)) {
                params = sparams;
 
                if (kill(parent, 0) == -1) {
@@ -247,11 +248,11 @@ again:
                goto done;
        }
 
-       rewind(f);
+       gzrewind(gzf);
        goto again;
 
 done:
-       fclose(f);
+       gzclose(gzf);
        for (child=child0;child<child0+options.clients_per_process;child++) {
                child->cleanup = 1;
                fflush(stdout);
index 82b1481fdb6743745952dc7a8d22796b48a1ae6a..8371dc7a16bd02a9ead75e6a2e5ce0f8b97e1425 100644 (file)
--- a/dbench.c
+++ b/dbench.c
@@ -25,6 +25,7 @@
 #include "dbench.h"
 #include "popt.h"
 #include <sys/sem.h>
+#include <zlib.h>
 
 struct options options = {
        .backend             = "fileio",
@@ -58,11 +59,11 @@ static int barrier=-1;
 static double throughput;
 struct nb_operations *nb_ops;
 
-static FILE *open_loadfile(void)
+static gzFile *open_loadfile(void)
 {
-       FILE            *f;
+       gzFile          *f;
 
-       if ((f = fopen(options.loadfile, "rt")) != NULL)
+       if ((f = gzopen(options.loadfile, "rt")) != NULL)
                return f;
 
        fprintf(stderr,
@@ -251,7 +252,7 @@ static void create_procs(int nprocs, void (*fn)(struct child_struct *, const cha
        int i, status;
        int synccount;
        struct timeval tv;
-       FILE *load;
+       gzFile *load;
        struct sembuf sbuf;
        double t;