link with zlib so we can read gzip compressed loadfiles
[tridge/dbench.git] / child.c
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);