Commit b74600ce authored by Geoff Simmons's avatar Geoff Simmons

add the -L/-T options -- config params tx.limit and tx.timeout,

just like the -L and -T options for the standard VSL tools
parent d5d8f817
......@@ -53,6 +53,7 @@
#include <limits.h>
#include <stdarg.h>
#include <dlfcn.h>
#include <float.h>
#include "trackrdrd.h"
#include "config_common.h"
......@@ -62,6 +63,7 @@
#include "vapi/vsl.h"
#include "miniobj.h"
#include "vas.h"
#include "vdef.h"
#define QUERY "VCL_log ~ \"^track \""
#define I_TAG "VSL"
......@@ -659,6 +661,18 @@ CHILD_Main(int readconfig)
}
vsl = VSL_New();
if (config.tx_limit > 0) {
char L[sizeof("4294967296") + 1];
bprintf(L, "%u", config.tx_limit);
assert(VSL_Arg(vsl, 'L', L) > 0);
}
if (config.tx_timeout >= 0) {
char T[DBL_MAX_10_EXP - DBL_MIN_10_EXP + 2];
bprintf(T, "%f", config.tx_timeout);
assert(VSL_Arg(vsl, 'T', T) > 0);
}
if (EMPTY(config.varnish_bindump)) {
vsm = VSM_New();
AN(vsm);
......
......@@ -106,6 +106,19 @@ conf_getUnsignedInt(const char *rval, unsigned *i)
return(0); \
}
#define confNonNegativeDouble(name,fld) \
if (strcmp(lval, (name)) == 0) { \
char *p; \
errno = 0; \
double d = strtod(rval, &p); \
if (errno) \
return errno; \
if (p[0] != '\0' || d < 0 || isnan(d) || !finite(d)) \
return EINVAL; \
config.fld = d; \
return 0; \
}
int
CONF_Add(const char *lval, const char *rval)
{
......@@ -132,6 +145,10 @@ CONF_Add(const char *lval, const char *rval)
confUnsigned("restart.pause", restart_pause);
confUnsigned("thread.restarts", thread_restarts);
confUnsigned("monitor.interval", monitor_interval);
confUnsigned("tx.limit", tx_limit);
confNonNegativeDouble("idle.pause", idle_pause);
confNonNegativeDouble("tx.timeout", tx_timeout);
if (strcmp(lval, "max.records") == 0) {
unsigned int i;
......@@ -186,18 +203,6 @@ CONF_Add(const char *lval, const char *rval)
return(EINVAL);
}
if (strcmp(lval, "idle.pause") == 0) {
char *p;
errno = 0;
double d = strtod(rval, &p);
if (errno)
return errno;
if (p[0] != '\0' || d < 0 || isnan(d) || !finite(d))
return EINVAL;
config.idle_pause = d;
return 0;
}
return EINVAL;
}
......@@ -235,6 +240,9 @@ CONF_Init(void)
bprintf(config.user_name, "%s", pw->pw_name);
config.uid = pw->pw_uid;
config.gid = pw->pw_gid;
config.tx_limit = 0;
config.tx_timeout = -1.;
}
/* XXX: stdout is /dev/null in child process */
......@@ -281,4 +289,6 @@ CONF_Dump(int level)
confdump(level, "idle.pause = %f", config.idle_pause);
confdump(level, "thread.restarts = %u", config.thread_restarts);
confdump(level, "user = %s", config.user_name);
confdump(level, "tx.limit = %u", config.tx_limit);
confdump(level, "tx.timeout = %f", config.tx_timeout);
}
......@@ -29,7 +29,7 @@ rm -f $LOG $MSG
# "Not running as root" filtered so that the test is independent of
# the user running it
CKSUM=$( grep -v 'Worker 1' $LOG | sed -e 's/\(initializing\) \(.*\)/\1/' | sed -e 's/\(Running as\) \([a-zA-Z0-9]*\)$/\1/' | grep -v 'Not running as root' | cksum)
if [ "$CKSUM" != '2709219299 214213' ]; then
if [ "$CKSUM" != '625760318 214345' ]; then
echo "ERROR: Regression test incorrect reader log cksum: $CKSUM"
exit 1
fi
......
......@@ -222,7 +222,8 @@ main(int argc, char * const *argv)
{
int c, d_flag = 0, D_flag = 0, err;
const char *P_arg = NULL, *l_arg = NULL, *n_arg = NULL, *f_arg = NULL,
*y_arg = NULL, *c_arg = NULL, *u_arg = NULL, *N_arg = NULL;
*y_arg = NULL, *c_arg = NULL, *u_arg = NULL, *N_arg = NULL,
*L_arg = NULL, *T_arg = NULL;
pid_t child_pid;
CONF_Init();
......@@ -234,7 +235,7 @@ main(int argc, char * const *argv)
}
cli_config_filename[0] = '\0';
while ((c = getopt(argc, argv, "u:P:Vn:hl:df:y:c:DN:")) != -1) {
while ((c = getopt(argc, argv, "u:P:Vn:hl:df:y:c:DN:L:T:")) != -1) {
switch (c) {
case 'P':
P_arg = optarg;
......@@ -269,6 +270,12 @@ main(int argc, char * const *argv)
case 'u':
u_arg = optarg;
break;
case 'L':
L_arg = optarg;
break;
case 'T':
T_arg = optarg;
break;
case 'h':
usage(EXIT_SUCCESS);
default:
......@@ -320,6 +327,15 @@ main(int argc, char * const *argv)
if (N_arg)
bprintf(config.vsmfile, "%s", N_arg);
if (L_arg && ((err = CONF_Add("tx.limit", L_arg)) != 0)) {
fprintf(stderr, "-L: %s\n", strerror(err));
usage(EXIT_FAILURE);
}
if (T_arg && ((err = CONF_Add("tx.timeout", T_arg)) != 0)) {
fprintf(stderr, "-T: %s\n", strerror(err));
usage(EXIT_FAILURE);
}
if (LOG_Open(PACKAGE_NAME) != 0) {
exit(EXIT_FAILURE);
}
......
......@@ -188,6 +188,7 @@ struct config {
#define DEF_IDLE_PAUSE 0.01
double idle_pause;
double tx_timeout;
uid_t uid;
gid_t gid;
......@@ -222,6 +223,8 @@ struct config {
unsigned thread_restarts;
unsigned chunk_size;
#define DEF_CHUNK_SIZE 64
unsigned tx_limit;
} config;
void CONF_Init(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment