Commit 49ef6b71 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

cleanups



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4883 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 7a2df0cb
......@@ -60,13 +60,13 @@ void VSL_Close(struct VSL_data *vd);
int VSL_Open(struct VSL_data *vd);
void VSL_Delete(struct VSL_data *vd);
struct varnish_stats *VSL_OpenStats(struct VSL_data *vd);
const char *VSL_Name(struct VSL_data *vd);
const char *VSL_Name(const struct VSL_data *vd);
extern const char *VSL_tags[256];
void *VSL_Find_Alloc(struct VSL_data *vd, const char *class, const char *type,
const char *ident, unsigned *lenp);
struct shmalloc *vsl_iter0(struct VSL_data *vd);
void vsl_itern(struct VSL_data *vd, struct shmalloc **pp);
struct shmalloc *vsl_iter0(const struct VSL_data *vd);
void vsl_itern(const struct VSL_data *vd, struct shmalloc **pp);
#define VSL_FOREACH(var, vd) \
for((var) = vsl_iter0((vd)); (var) != NULL; vsl_itern((vd), &(var)))
......
......@@ -10,10 +10,9 @@
SVNID("$Id$")
#include <sys/types.h>
#include <stdint.h>
#include "varnishapi.h"
static const char *b64 =
static const char b64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static char i64[256];
......
......@@ -34,12 +34,11 @@ SVNID("$Id$")
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -98,6 +97,7 @@ VSL_Delete(struct VSL_data *vd)
vbit_destroy(vd->vbm_select);
free(vd->n_opt);
free(vd->rbuf);
free(vd->fname);
free(vd);
}
......@@ -112,21 +112,28 @@ VSL_Open(struct VSL_data *vd)
if (vd->vsl_lh != NULL)
return (0);
vd->vsl_fd = open(vd->vsl, O_RDONLY);
vd->vsl_fd = open(vd->fname, O_RDONLY);
if (vd->vsl_fd < 0) {
fprintf(stderr, "Cannot open %s: %s\n",
vd->vsl, strerror(errno));
vd->fname, strerror(errno));
return (1);
}
assert(fstat(vd->vsl_fd, &vd->fstat) == 0);
if (!S_ISREG(vd->fstat.st_mode)) {
fprintf(stderr, "%s is not a regular file\n", vd->fname);
return (1);
}
i = read(vd->vsl_fd, &slh, sizeof slh);
if (i != sizeof slh) {
fprintf(stderr, "Cannot read %s: %s\n",
vd->vsl, strerror(errno));
vd->fname, strerror(errno));
return (1);
}
if (slh.magic != SHMLOGHEAD_MAGIC) {
fprintf(stderr, "Wrong magic number in file %s\n",
vd->vsl);
vd->fname);
return (1);
}
......@@ -134,7 +141,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",
vd->vsl, strerror(errno));
vd->fname, strerror(errno));
return (1);
}
vd->vsl_end = (uint8_t *)vd->vsl_lh + slh.shm_size;
......@@ -160,7 +167,7 @@ VSL_Close(struct VSL_data *vd)
/*--------------------------------------------------------------------*/
struct shmalloc *
vsl_iter0(struct VSL_data *vd)
vsl_iter0(const struct VSL_data *vd)
{
CHECK_OBJ_NOTNULL(vd, VSL_MAGIC);
......@@ -171,7 +178,7 @@ vsl_iter0(struct VSL_data *vd)
}
void
vsl_itern(struct VSL_data *vd, struct shmalloc **pp)
vsl_itern(const struct VSL_data *vd, struct shmalloc **pp)
{
CHECK_OBJ_NOTNULL(vd, VSL_MAGIC);
......@@ -191,7 +198,7 @@ vsl_itern(struct VSL_data *vd, struct shmalloc **pp)
/*--------------------------------------------------------------------*/
static struct shmalloc *
vsl_find_alloc(struct VSL_data *vd, const char *class, const char *type, const char *ident)
vsl_find_alloc(const struct VSL_data *vd, const char *class, const char *type, const char *ident)
{
struct shmalloc *sha;
......@@ -272,7 +279,7 @@ VSL_OpenLog(struct VSL_data *vd)
/*--------------------------------------------------------------------*/
const char *
VSL_Name(struct VSL_data *vd)
VSL_Name(const struct VSL_data *vd)
{
return (vd->n_opt);
......
......@@ -37,7 +37,8 @@ struct VSL_data {
unsigned magic;
#define VSL_MAGIC 0x6e3bd69b
char *vsl;
char *fname;
struct stat fstat;
int vsl_fd;
struct shmloghead *vsl_lh;
......
......@@ -33,13 +33,12 @@
SVNID("$Id$")
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -212,7 +211,7 @@ 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)) {
if (vin_n_arg(vd->n_opt, NULL, NULL, &vd->fname)) {
fprintf(stderr, "Invalid instance name: %s\n",
strerror(errno));
return (-1);
......
......@@ -33,13 +33,9 @@
SVNID("$Id$")
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......
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