diff options
Diffstat (limited to 'src/binlog.c')
-rw-r--r-- | src/binlog.c | 66 |
1 files changed, 39 insertions, 27 deletions
diff --git a/src/binlog.c b/src/binlog.c index 45299f2..e9fb16e 100644 --- a/src/binlog.c +++ b/src/binlog.c @@ -31,5 +31,16 @@ #include "vcc_if.h" -#include "bin/varnishd/cache.h" +#if VARNISHVERSION == 3 +# include "bin/varnishd/cache.h" +# define VCL_VOID void +# define VCL_STRING const char * +# define MOD_CTX struct sess * +# define WSPTR(s) ((s)->wrk->ws) +#else +# include "bin/varnishd/cache/cache.h" +# define MOD_CTX const struct vrt_ctx * +# define WSPTR(s) ((s)->ws) +#endif #include "vmod-binlog.h" #include "pack.h" +#include "pthread.h" @@ -264,3 +275,3 @@ make_key() void -vmod_init(struct sess *sp, struct vmod_priv *priv, +vmod_init(MOD_CTX ctx, struct vmod_priv *priv, const char *dir, const char *format, const char *param) @@ -354,3 +365,2 @@ vmod_init(struct sess *sp, struct vmod_priv *priv, } - free(p); switch (*q) { @@ -371,2 +381,3 @@ vmod_init(struct sess *sp, struct vmod_priv *priv, conf->size = u; + free(p); } else @@ -428,3 +439,3 @@ vmod_init(struct sess *sp, struct vmod_priv *priv, static char * -mkfilename(struct sess *sp, struct binlog_config *conf) +mkfilename(MOD_CTX ctx, struct binlog_config *conf) { @@ -436,7 +447,7 @@ mkfilename(struct sess *sp, struct binlog_config *conf) ts -= ts % conf->interval; - u = WS_Reserve(sp->wrk->ws, 0); - p = sp->wrk->ws->f; + u = WS_Reserve(WSPTR(ctx), 0); + p = WSPTR(ctx)->f; n = strftime(p, u, conf->pattern, gmtime(&ts)); if (n == 0) { - WS_Release(sp->wrk->ws, 0); + WS_Release(WSPTR(ctx), 0); return NULL; @@ -445,3 +456,3 @@ mkfilename(struct sess *sp, struct binlog_config *conf) AN(q); - WS_Release(sp->wrk->ws, 0); + WS_Release(WSPTR(ctx), 0); return q; @@ -483,3 +494,3 @@ mkdir_p(struct binlog_config *conf, char *dir) static int -createfile(struct sess *sp, struct binlog_config *conf) +createfile(MOD_CTX ctx, struct binlog_config *conf) { @@ -491,3 +502,3 @@ createfile(struct sess *sp, struct binlog_config *conf) - fname = mkfilename(sp, conf); + fname = mkfilename(ctx, conf); if (!fname) @@ -593,3 +604,3 @@ checkheader(struct binlog_config *conf, size_t hdrsize) static int -newfile(struct sess *sp, struct binlog_config *conf) +newfile(MOD_CTX ctx, struct binlog_config *conf) { @@ -603,3 +614,3 @@ newfile(struct sess *sp, struct binlog_config *conf) - if (createfile(sp, conf)) + if (createfile(ctx, conf)) return -1; @@ -659,3 +670,4 @@ newfile(struct sess *sp, struct binlog_config *conf) } else { - debug(conf,1,("created new log file %s",conf->fname)); + debug(conf,1,("created new log file %s, size %lu",conf->fname, + (unsigned long)conf->size)); memcpy(conf->base->magic, BINLOG_MAGIC_STR, BINLOG_MAGIC_LEN); @@ -676,3 +688,3 @@ newfile(struct sess *sp, struct binlog_config *conf) static void -closefile(struct sess *sp, struct binlog_config *conf) +closefile(MOD_CTX ctx, struct binlog_config *conf) { @@ -693,4 +705,4 @@ closefile(struct sess *sp, struct binlog_config *conf) -void -vmod_start(struct sess *sp, struct vmod_priv *priv) +VCL_VOID +vmod_start(MOD_CTX ctx, struct vmod_priv *priv) { @@ -707,4 +719,4 @@ vmod_start(struct sess *sp, struct vmod_priv *priv) AZ(pthread_mutex_lock(&conf->mutex)); - closefile(sp, conf); - newfile(sp, conf); + closefile(ctx, conf); + newfile(ctx, conf); AZ(pthread_mutex_unlock(&conf->mutex)); @@ -716,4 +728,4 @@ vmod_start(struct sess *sp, struct vmod_priv *priv) -void -vmod_pack(struct sess *sp, struct vmod_priv *priv, const char *str) +VCL_VOID +vmod_pack(MOD_CTX ctx, struct vmod_priv *priv, VCL_STRING str) { @@ -751,4 +763,4 @@ vmod_pack(struct sess *sp, struct vmod_priv *priv, const char *str) -void -vmod_commit(struct sess *sp, struct vmod_priv *priv) +VCL_VOID +vmod_commit(MOD_CTX ctx, struct vmod_priv *priv) { @@ -791,4 +803,4 @@ vmod_commit(struct sess *sp, struct vmod_priv *priv) -void -vmod_sync(struct sess *sp, struct vmod_priv *priv) +VCL_VOID +vmod_sync(MOD_CTX ctx, struct vmod_priv *priv) { @@ -805,4 +817,4 @@ vmod_sync(struct sess *sp, struct vmod_priv *priv) -void -vmod_close(struct sess *sp, struct vmod_priv *priv) +VCL_VOID +vmod_close(MOD_CTX ctx, struct vmod_priv *priv) { @@ -815,3 +827,3 @@ vmod_close(struct sess *sp, struct vmod_priv *priv) AZ(pthread_mutex_lock(&mutex)); - closefile(sp, conf); + closefile(ctx, conf); close(conf->dd); |