Commit 73daf171 authored by Lasse Karstensen's avatar Lasse Karstensen

Merge branch 'master' into 4.1

parents 017ec218 57baf76f
...@@ -101,6 +101,7 @@ noinst_HEADERS = \ ...@@ -101,6 +101,7 @@ noinst_HEADERS = \
builtin_vcl.h \ builtin_vcl.h \
cache/cache_esi.h \ cache/cache_esi.h \
cache/cache_pool.h \ cache/cache_pool.h \
cache/cache_priv.h \
common/heritage.h \ common/heritage.h \
hash/hash_slinger.h \ hash/hash_slinger.h \
http1/cache_http1.h \ http1/cache_http1.h \
...@@ -124,6 +125,7 @@ nobase_pkginclude_HEADERS = \ ...@@ -124,6 +125,7 @@ nobase_pkginclude_HEADERS = \
varnishd_CFLAGS = \ varnishd_CFLAGS = \
@PCRE_CFLAGS@ \ @PCRE_CFLAGS@ \
-DVARNISHD_IS_NOT_A_VMOD \
-DVARNISH_STATE_DIR='"${VARNISH_STATE_DIR}"' \ -DVARNISH_STATE_DIR='"${VARNISH_STATE_DIR}"' \
-DVARNISH_VMOD_DIR='"${pkglibdir}/vmods"' \ -DVARNISH_VMOD_DIR='"${pkglibdir}/vmods"' \
-DVARNISH_VCL_DIR='"${varnishconfdir}"' -DVARNISH_VCL_DIR='"${varnishconfdir}"'
......
...@@ -648,46 +648,18 @@ struct sess { ...@@ -648,46 +648,18 @@ struct sess {
}; };
/*--------------------------------------------------------------------
* A transport is how we talk HTTP for a given request.
* This is different from a protocol because ESI child requests have
* their own "protocol" to talk to the parent ESI request, which may
* or may not, be talking a "real" HTTP protocol itself.
*/
typedef void vtr_deliver_f (struct req *, struct busyobj *, int wantbody);
struct transport {
unsigned magic;
#define TRANSPORT_MAGIC 0xf157f32f
vtr_deliver_f *deliver;
};
/* Prototypes etc ----------------------------------------------------*/ /* Prototypes etc ----------------------------------------------------*/
/* Cross file typedefs */ /* Cross file typedefs */
typedef enum htc_status_e htc_complete_f(struct http_conn *); typedef enum htc_status_e htc_complete_f(struct http_conn *);
/* cache_acceptor.c */
void VCA_Init(void);
void VCA_Shutdown(void);
/* cache_backend_cfg.c */
void VBE_InitCfg(void);
void VBE_Poll(void);
/* cache_backend_poll.c */
void VBP_Init(void);
/* cache_ban.c */ /* cache_ban.c */
struct ban *BAN_New(void); struct ban *BAN_New(void);
int BAN_AddTest(struct ban *, const char *, const char *, const char *); int BAN_AddTest(struct ban *, const char *, const char *, const char *);
void BAN_Free(struct ban *b); void BAN_Free(struct ban *b);
char *BAN_Insert(struct ban *b); char *BAN_Insert(struct ban *b);
void BAN_Free_Errormsg(char *); void BAN_Free_Errormsg(char *);
void BAN_Init(void);
void BAN_Shutdown(void);
void BAN_NewObjCore(struct objcore *oc); void BAN_NewObjCore(struct objcore *oc);
void BAN_DestroyObj(struct objcore *oc); void BAN_DestroyObj(struct objcore *oc);
int BAN_CheckObject(struct worker *, struct objcore *, struct req *); int BAN_CheckObject(struct worker *, struct objcore *, struct req *);
...@@ -699,7 +671,6 @@ void BAN_TailDeref(struct ban **ban); ...@@ -699,7 +671,6 @@ void BAN_TailDeref(struct ban **ban);
double BAN_Time(const struct ban *ban); double BAN_Time(const struct ban *ban);
/* cache_busyobj.c */ /* cache_busyobj.c */
void VBO_Init(void);
struct busyobj *VBO_GetBusyObj(struct worker *, const struct req *); struct busyobj *VBO_GetBusyObj(struct worker *, const struct req *);
void VBO_DerefBusyObj(struct worker *wrk, struct busyobj **busyobj); void VBO_DerefBusyObj(struct worker *wrk, struct busyobj **busyobj);
void VBO_extend(struct busyobj *, ssize_t); void VBO_extend(struct busyobj *, ssize_t);
...@@ -719,9 +690,6 @@ enum req_fsm_nxt CNT_Request(struct worker *, struct req *); ...@@ -719,9 +690,6 @@ enum req_fsm_nxt CNT_Request(struct worker *, struct req *);
void CNT_AcctLogCharge(struct dstat *, struct req *); void CNT_AcctLogCharge(struct dstat *, struct req *);
/* cache_cli.c [CLI] */ /* cache_cli.c [CLI] */
void CLI_Init(void);
void CLI_Run(void);
void CLI_AddFuncs(struct cli_proto *p);
extern pthread_t cli_thread; extern pthread_t cli_thread;
#define ASSERT_CLI() do {assert(pthread_self() == cli_thread);} while (0) #define ASSERT_CLI() do {assert(pthread_self() == cli_thread);} while (0)
...@@ -732,7 +700,6 @@ double EXP_Ttl(const struct req *, const struct exp*); ...@@ -732,7 +700,6 @@ double EXP_Ttl(const struct req *, const struct exp*);
double EXP_When(const struct exp *exp); double EXP_When(const struct exp *exp);
void EXP_Insert(struct worker *wrk, struct objcore *oc); void EXP_Insert(struct worker *wrk, struct objcore *oc);
void EXP_Inject(struct worker *wrk, struct objcore *oc, struct lru *lru); void EXP_Inject(struct worker *wrk, struct objcore *oc, struct lru *lru);
void EXP_Init(void);
void EXP_Rearm(struct objcore *, double now, double ttl, double grace, void EXP_Rearm(struct objcore *, double now, double ttl, double grace,
double keep); double keep);
void EXP_Touch(struct objcore *oc, double now); void EXP_Touch(struct objcore *oc, double now);
...@@ -758,9 +725,6 @@ enum vbf_fetch_mode_e { ...@@ -758,9 +725,6 @@ enum vbf_fetch_mode_e {
void VBF_Fetch(struct worker *wrk, struct req *req, void VBF_Fetch(struct worker *wrk, struct req *req,
struct objcore *oc, struct objcore *oldoc, enum vbf_fetch_mode_e); struct objcore *oc, struct objcore *oldoc, enum vbf_fetch_mode_e);
/* cache_fetch_proc.c */
void VFP_Init(void);
/* cache_gzip.c */ /* cache_gzip.c */
struct vgz; struct vgz;
...@@ -797,7 +761,6 @@ void HTTP_Copy(struct http *to, const struct http * const fm); ...@@ -797,7 +761,6 @@ void HTTP_Copy(struct http *to, const struct http * const fm);
struct http *HTTP_create(void *p, uint16_t nhttp); struct http *HTTP_create(void *p, uint16_t nhttp);
const char *http_Status2Reason(unsigned); const char *http_Status2Reason(unsigned);
unsigned http_EstimateWS(const struct http *fm, unsigned how); unsigned http_EstimateWS(const struct http *fm, unsigned how);
void HTTP_Init(void);
void http_PutResponse(struct http *to, const char *proto, uint16_t status, void http_PutResponse(struct http *to, const char *proto, uint16_t status,
const char *response); const char *response);
void http_FilterReq(struct http *to, const struct http *fm, unsigned how); void http_FilterReq(struct http *to, const struct http *fm, unsigned how);
...@@ -856,12 +819,6 @@ extern const char H__Reason[]; ...@@ -856,12 +819,6 @@ extern const char H__Reason[];
uint32_t VXID_Get(struct worker *, uint32_t marker); uint32_t VXID_Get(struct worker *, uint32_t marker);
extern volatile struct params * cache_param; extern volatile struct params * cache_param;
extern pthread_key_t witness_key; extern pthread_key_t witness_key;
void THR_SetName(const char *name);
const char* THR_GetName(void);
void THR_SetBusyobj(const struct busyobj *);
struct busyobj * THR_GetBusyobj(void);
void THR_SetRequest(const struct req *);
struct req * THR_GetRequest(void);
/* cache_lck.c */ /* cache_lck.c */
...@@ -873,7 +830,6 @@ void Lck__New(struct lock *lck, struct VSC_C_lck *, const char *); ...@@ -873,7 +830,6 @@ void Lck__New(struct lock *lck, struct VSC_C_lck *, const char *);
void Lck__Assert(const struct lock *lck, int held); void Lck__Assert(const struct lock *lck, int held);
/* public interface: */ /* public interface: */
void LCK_Init(void);
void Lck_Delete(struct lock *lck); void Lck_Delete(struct lock *lck);
int Lck_CondWait(pthread_cond_t *cond, struct lock *lck, double); int Lck_CondWait(pthread_cond_t *cond, struct lock *lck, double);
...@@ -933,12 +889,10 @@ int ObjCheckFlag(struct worker *, struct objcore *oc, enum obj_flags of); ...@@ -933,12 +889,10 @@ int ObjCheckFlag(struct worker *, struct objcore *oc, enum obj_flags of);
void ObjSetFlag(struct worker *, struct objcore *, enum obj_flags of, int val); void ObjSetFlag(struct worker *, struct objcore *, enum obj_flags of, int val);
/* cache_panic.c */ /* cache_panic.c */
void PAN_Init(void);
const char *body_status_2str(enum body_status e); const char *body_status_2str(enum body_status e);
const char *sess_close_2str(enum sess_close sc, int want_desc); const char *sess_close_2str(enum sess_close sc, int want_desc);
/* cache_pool.c */ /* cache_pool.c */
void Pool_Init(void);
int Pool_Task(struct pool *pp, struct pool_task *task, enum task_how how); int Pool_Task(struct pool *pp, struct pool_task *task, enum task_how how);
int Pool_Task_Arg(struct worker *, task_func_t *, int Pool_Task_Arg(struct worker *, task_func_t *,
const void *arg, size_t arg_len); const void *arg, size_t arg_len);
...@@ -947,9 +901,6 @@ int Pool_TrySumstat(struct worker *wrk); ...@@ -947,9 +901,6 @@ int Pool_TrySumstat(struct worker *wrk);
void Pool_PurgeStat(unsigned nobj); void Pool_PurgeStat(unsigned nobj);
int Pool_Task_Any(struct pool_task *task, enum task_how how); int Pool_Task_Any(struct pool_task *task, enum task_how how);
/* cache_proxy.c [VPX] */
task_func_t VPX_Proto_Sess;
/* cache_range.c [VRG] */ /* cache_range.c [VRG] */
void VRG_dorange(struct req *req, const char *r); void VRG_dorange(struct req *req, const char *r);
...@@ -997,13 +948,8 @@ const char *SES_Get_String_Attr(const struct sess *sp, enum sess_attr a); ...@@ -997,13 +948,8 @@ const char *SES_Get_String_Attr(const struct sess *sp, enum sess_attr a);
/* cache_shmlog.c */ /* cache_shmlog.c */
extern struct VSC_C_main *VSC_C_main; extern struct VSC_C_main *VSC_C_main;
void VSM_Init(void);
void *VSM_Alloc(unsigned size, const char *class, const char *type, void *VSM_Alloc(unsigned size, const char *class, const char *type,
const char *ident); const char *ident);
void VSL_Setup(struct vsl_log *vsl, void *ptr, size_t len);
void VSL_ChgId(struct vsl_log *vsl, const char *typ, const char *why,
uint32_t vxid);
void VSL_End(struct vsl_log *vsl);
void VSM_Free(void *ptr); void VSM_Free(void *ptr);
#ifdef VSL_ENDMARKER #ifdef VSL_ENDMARKER
void VSL(enum VSL_tag_e tag, uint32_t vxid, const char *fmt, ...) void VSL(enum VSL_tag_e tag, uint32_t vxid, const char *fmt, ...)
...@@ -1047,13 +993,8 @@ enum vry_finish_flag { KEEP, DISCARD }; ...@@ -1047,13 +993,8 @@ enum vry_finish_flag { KEEP, DISCARD };
void VRY_Finish(struct req *req, enum vry_finish_flag); void VRY_Finish(struct req *req, enum vry_finish_flag);
/* cache_vcl.c */ /* cache_vcl.c */
struct director *VCL_DefaultDirector(const struct vcl *);
const struct vrt_backend_probe *VCL_DefaultProbe(const struct vcl *);
void VCL_Init(void);
const char *VCL_Method_Name(unsigned); const char *VCL_Method_Name(unsigned);
const char *VCL_Name(const struct vcl *); const char *VCL_Name(const struct vcl *);
void VCL_Panic(struct vsb *, const struct vcl *);
void VCL_Poll(void);
void VCL_Ref(struct vcl *); void VCL_Ref(struct vcl *);
void VCL_Refresh(struct vcl **); void VCL_Refresh(struct vcl **);
void VCL_Rel(struct vcl **); void VCL_Rel(struct vcl **);
...@@ -1073,11 +1014,6 @@ const char *VCL_Return_Name(unsigned); ...@@ -1073,11 +1014,6 @@ const char *VCL_Return_Name(unsigned);
*/ */
const char *VRT_String(struct ws *ws, const char *h, const char *p, va_list ap); const char *VRT_String(struct ws *ws, const char *h, const char *p, va_list ap);
char *VRT_StringList(char *d, unsigned dl, const char *p, va_list ap); char *VRT_StringList(char *d, unsigned dl, const char *p, va_list ap);
void VRTPRIV_init(struct vrt_privs *privs);
void VRTPRIV_dynamic_kill(struct vrt_privs *privs, uintptr_t id);
/* cache_vrt_vmod.c */
void VMOD_Init(void);
/* cache_wrk.c */ /* cache_wrk.c */
...@@ -1119,10 +1055,6 @@ void STV_close(void); ...@@ -1119,10 +1055,6 @@ void STV_close(void);
int STV_BanInfo(enum baninfo event, const uint8_t *ban, unsigned len); int STV_BanInfo(enum baninfo event, const uint8_t *ban, unsigned len);
void STV_BanExport(const uint8_t *bans, unsigned len); void STV_BanExport(const uint8_t *bans, unsigned len);
/* storage_persistent.c */
void SMP_Init(void);
void SMP_Ready(void);
/* /*
* A normal pointer difference is signed, but we never want a negative value * A normal pointer difference is signed, but we never want a negative value
* so this little tool will make sure we don't get that. * so this little tool will make sure we don't get that.
...@@ -1183,3 +1115,8 @@ DO_DEBUG(enum debug_bits x) ...@@ -1183,3 +1115,8 @@ DO_DEBUG(enum debug_bits x)
if (DO_DEBUG(debug_bit)) \ if (DO_DEBUG(debug_bit)) \
VSL(SLT_Debug, (id), __VA_ARGS__); \ VSL(SLT_Debug, (id), __VA_ARGS__); \
} while (0) } while (0)
#ifdef VARNISHD_IS_NOT_A_VMOD
# include "cache/cache_priv.h"
#endif
/*-
* Copyright (c) 2006 Verdens Gang AS
* Copyright (c) 2006-2015 Varnish Software AS
* All rights reserved.
*
* Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Stuff that should *never* be exposed to a VMOD
*/
/*--------------------------------------------------------------------
* A transport is how we talk HTTP for a given request.
* This is different from a protocol because ESI child requests have
* their own "protocol" to talk to the parent ESI request, which may
* or may not, be talking a "real" HTTP protocol itself.
*/
typedef void vtr_deliver_f (struct req *, struct busyobj *, int wantbody);
struct transport {
unsigned magic;
#define TRANSPORT_MAGIC 0xf157f32f
vtr_deliver_f *deliver;
};
/* Prototypes etc ----------------------------------------------------*/
/* cache_acceptor.c */
void VCA_Init(void);
void VCA_Shutdown(void);
/* cache_backend_cfg.c */
void VBE_InitCfg(void);
void VBE_Poll(void);
/* cache_backend_poll.c */
void VBP_Init(void);
/* cache_ban.c */
void BAN_Init(void);
void BAN_Shutdown(void);
/* cache_busyobj.c */
void VBO_Init(void);
/* cache_cli.c [CLI] */
void CLI_Init(void);
void CLI_Run(void);
void CLI_AddFuncs(struct cli_proto *p);
/* cache_expire.c */
void EXP_Init(void);
/* cache_fetch_proc.c */
void VFP_Init(void);
/* cache_http.c */
void HTTP_Init(void);
/* cache_main.c */
void THR_SetName(const char *name);
const char* THR_GetName(void);
void THR_SetBusyobj(const struct busyobj *);
struct busyobj * THR_GetBusyobj(void);
void THR_SetRequest(const struct req *);
struct req * THR_GetRequest(void);
/* cache_lck.c */
void LCK_Init(void);
/* cache_panic.c */
void PAN_Init(void);
/* cache_pool.c */
void Pool_Init(void);
/* cache_proxy.c [VPX] */
task_func_t VPX_Proto_Sess;
/* cache_shmlog.c */
void VSM_Init(void);
void VSL_Setup(struct vsl_log *vsl, void *ptr, size_t len);
void VSL_ChgId(struct vsl_log *vsl, const char *typ, const char *why,
uint32_t vxid);
void VSL_End(struct vsl_log *vsl);
/* cache_vcl.c */
struct director *VCL_DefaultDirector(const struct vcl *);
const struct vrt_backend_probe *VCL_DefaultProbe(const struct vcl *);
void VCL_Init(void);
void VCL_Panic(struct vsb *, const struct vcl *);
void VCL_Poll(void);
/* cache_vrt.c */
void VRTPRIV_init(struct vrt_privs *privs);
void VRTPRIV_dynamic_kill(struct vrt_privs *privs, uintptr_t id);
/* cache_vrt_vmod.c */
void VMOD_Init(void);
/* storage_persistent.c */
void SMP_Init(void);
void SMP_Ready(void);
...@@ -15,6 +15,7 @@ flexelint \ ...@@ -15,6 +15,7 @@ flexelint \
-I../../lib/libvgz \ -I../../lib/libvgz \
-I../.. \ -I../.. \
-I/usr/local/include \ -I/usr/local/include \
-DVARNISHD_IS_NOT_A_VMOD \
-DVARNISH_STATE_DIR=\"foo\" \ -DVARNISH_STATE_DIR=\"foo\" \
-DVARNISH_VMOD_DIR=\"foo\" \ -DVARNISH_VMOD_DIR=\"foo\" \
-DVARNISH_VCL_DIR=\"foo\" \ -DVARNISH_VCL_DIR=\"foo\" \
......
...@@ -61,10 +61,10 @@ v1d_bytes(struct req *req, enum vdp_action act, void **priv, ...@@ -61,10 +61,10 @@ v1d_bytes(struct req *req, enum vdp_action act, void **priv,
static void static void
v1d_error(struct req *req, const char *msg) v1d_error(struct req *req, const char *msg)
{ {
static const char r_500[] = static const char r_500[] =
"HTTP/1.1 500 Internal Server Error\r\n" "HTTP/1.1 500 Internal Server Error\r\n"
"Server: Varnish\r\n" "Server: Varnish\r\n"
"Connection: close\r\n\r\n"; "Connection: close\r\n\r\n";
VSLb(req->vsl, SLT_Error, "%s", msg); VSLb(req->vsl, SLT_Error, "%s", msg);
VSLb(req->vsl, SLT_RespProtocol, "HTTP/1.1"); VSLb(req->vsl, SLT_RespProtocol, "HTTP/1.1");
...@@ -122,7 +122,7 @@ V1D_Deliver(struct req *req, struct busyobj *bo, int wantbody) ...@@ -122,7 +122,7 @@ V1D_Deliver(struct req *req, struct busyobj *bo, int wantbody)
V1L_Reserve(req->wrk, req->ws, &req->sp->fd, req->vsl, req->t_prev); V1L_Reserve(req->wrk, req->ws, &req->sp->fd, req->vsl, req->t_prev);
if (WS_Overflowed(req->ws)) { if (WS_Overflowed(req->ws)) {
v1d_error(req, "workspace_client overflow"); v1d_error(req, "workspace_client overflow");
return; return;
} }
......
...@@ -104,7 +104,7 @@ vsm_n_check(void) ...@@ -104,7 +104,7 @@ vsm_n_check(void)
struct VSM_head vsmh; struct VSM_head vsmh;
int retval = 1; int retval = 1;
fd = open(VSM_FILENAME, O_RDWR, 0644); fd = open(VSM_FILENAME, O_RDWR);
if (fd < 0) if (fd < 0)
return (0); return (0);
......
...@@ -42,6 +42,7 @@ varnish v1 -arg "-i J.F.Nobody" -vcl+backend { ...@@ -42,6 +42,7 @@ varnish v1 -arg "-i J.F.Nobody" -vcl+backend {
} }
sub vcl_hit { sub vcl_hit {
if (obj.status != 200) { return(synth(700)); }
if (obj.proto) { } if (obj.proto) { }
if (obj.reason) { } if (obj.reason) { }
if (obj.keep > 1m) { } if (obj.keep > 1m) { }
......
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