return;
}
- for (i=0;nb_ops.ops[i].name;i++) {
- if (strcasecmp(op.op, nb_ops.ops[i].name) == 0) {
- nb_ops.ops[i].fn(&op);
+ for (i=0;nb_ops->ops[i].name;i++) {
+ if (strcasecmp(op.op, nb_ops->ops[i].name) == 0) {
+ nb_ops->ops[i].fn(&op);
finish_op(child, &child->ops[i]);
return;
}
/* run a test that simulates an approximate netbench client load */
+#define MAX_PARM_LEN 1024
void child_run(struct child_struct *child0, const char *loadfile)
{
int i;
- char line[1024], fname[1024], fname2[1024];
+ char line[MAX_PARM_LEN], fname[MAX_PARM_LEN], fname2[MAX_PARM_LEN];
char **sparams, **params;
char *p;
const char *status;
double targett;
struct child_struct *child;
+ f = fopen(loadfile, "r");
+ if (f == NULL) {
+ perror(loadfile);
+ exit(1);
+ }
+
for (child=child0;child<child0+options.clients_per_process;child++) {
child->line = 0;
asprintf(&child->cname,"client%d", child->id);
sparams = calloc(20, sizeof(char *));
for (i=0;i<20;i++) {
- sparams[i] = malloc(100);
- }
-
- f = fopen(loadfile, "r");
- if (f == NULL) {
- perror(loadfile);
- exit(1);
+ sparams[i] = malloc(MAX_PARM_LEN);
+ memset(sparams[i], 0, MAX_PARM_LEN);
}
again:
}
if (strncmp(params[i-1], "NT_STATUS_", 10) != 0 &&
- strncmp(params[i-1], "0x", 2) != 0) {
+ strncmp(params[i-1], "0x", 2) != 0 &&
+ strncmp(params[i-1], "*", 1) != 0) {
printf("Badly formed status at line %d\n", child->line);
continue;
}
}
}
+ if (options.run_once) {
+ goto done;
+ }
+
rewind(f);
goto again;
child->cleanup = 1;
fflush(stdout);
if (!options.skip_cleanup) {
- nb_ops.cleanup(child);
+ nb_ops->cleanup(child);
}
child->cleanup_finished = 1;
+ if(child->cname){
+ free(child->cname);
+ child->cname = NULL;
+ }
}
}