Commit 7a2df0cb authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Move the -n processing up to VSL_Arg() time



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4882 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent ec5ae8cd
......@@ -108,32 +108,25 @@ VSL_Open(struct VSL_data *vd)
{
int i;
struct shmloghead slh;
char *logname;
if (vd->vsl_lh != NULL)
return (0);
if (vin_n_arg(vd->n_opt, NULL, NULL, &logname)) {
fprintf(stderr, "Invalid instance name: %s\n",
strerror(errno));
return (1);
}
vd->vsl_fd = open(logname, O_RDONLY);
vd->vsl_fd = open(vd->vsl, O_RDONLY);
if (vd->vsl_fd < 0) {
fprintf(stderr, "Cannot open %s: %s\n",
logname, strerror(errno));
vd->vsl, strerror(errno));
return (1);
}
i = read(vd->vsl_fd, &slh, sizeof slh);
if (i != sizeof slh) {
fprintf(stderr, "Cannot read %s: %s\n",
logname, strerror(errno));
vd->vsl, strerror(errno));
return (1);
}
if (slh.magic != SHMLOGHEAD_MAGIC) {
fprintf(stderr, "Wrong magic number in file %s\n",
logname);
vd->vsl);
return (1);
}
......@@ -141,7 +134,7 @@ VSL_Open(struct VSL_data *vd)
PROT_READ, MAP_SHARED|MAP_HASSEMAPHORE, vd->vsl_fd, 0);
if (vd->vsl_lh == MAP_FAILED) {
fprintf(stderr, "Cannot mmap %s: %s\n",
logname, strerror(errno));
vd->vsl, strerror(errno));
return (1);
}
vd->vsl_end = (uint8_t *)vd->vsl_lh + slh.shm_size;
......
......@@ -37,6 +37,7 @@ struct VSL_data {
unsigned magic;
#define VSL_MAGIC 0x6e3bd69b
char *vsl;
int vsl_fd;
struct shmloghead *vsl_lh;
......
......@@ -212,6 +212,11 @@ VSL_Arg(struct VSL_data *vd, int arg, const char *opt)
free(vd->n_opt);
vd->n_opt = strdup(opt);
assert(vd->n_opt != NULL);
if (vin_n_arg(vd->n_opt, NULL, NULL, &vd->vsl)) {
fprintf(stderr, "Invalid instance name: %s\n",
strerror(errno));
return (-1);
}
return (1);
case 'r': return (vsl_r_arg(vd, opt));
case 's': return (vsl_s_arg(vd, opt));
......
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