[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/autogen.des
|
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $Id: autogen.des 2458 2008-02-13 17:12:59Z des $
+# $Id: autogen.des 2564 2008-03-08 13:38:23Z des $
#
set -ex
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/autogen.sh
^
|
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $Id: autogen.sh 2222 2007-11-01 21:47:58Z des $
+# $Id: autogen.sh 2233 2007-11-08 21:05:43Z des $
#
warn() {
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/Makefile.am
^
|
@@ -1,4 +1,4 @@
-# $Id: Makefile.am 2456 2008-02-13 14:58:48Z des $
+# $Id: Makefile.am 2564 2008-03-08 13:38:23Z des $
SUBDIRS = varnishadm varnishd varnishlog varnishncsa varnishreplay
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishadm/Makefile.am
^
|
@@ -1,4 +1,4 @@
-# $Id: Makefile.am 2455 2008-02-13 13:55:39Z des $
+# $Id: Makefile.am 2564 2008-03-08 13:38:23Z des $
INCLUDES = -I$(top_srcdir)/include
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishadm/varnishadm.1
^
|
@@ -26,7 +26,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: varnishadm.1 2415 2008-01-31 11:57:51Z des $
+.\" $Id: varnishadm.1 2496 2008-02-17 09:26:32Z des $
.\"
.Dd January 31, 2008
.Dt VARNISHADM 1
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishadm/varnishadm.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: varnishadm.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: varnishadm.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/Makefile.am
^
|
@@ -1,4 +1,4 @@
-# $Id: Makefile.am 2455 2008-02-13 13:55:39Z des $
+# $Id: Makefile.am 2564 2008-03-08 13:38:23Z des $
INCLUDES = -I$(top_srcdir)/include
@@ -12,11 +12,12 @@
cache_acceptor_poll.c \
cache_acceptor_kqueue.c \
cache_backend.c \
+ cache_backend_random.c \
+ cache_backend_round_robin.c \
+ cache_backend_simple.c \
cache_ban.c \
cache_center.c \
cache_cli.c \
- cache_dir_random.c \
- cache_dir_simple.c \
cache_expire.c \
cache_fetch.c \
cache_hash.c \
|
[-]
[+]
|
Deleted |
varnish-20080428.tar.bz2/bin/varnishd/c.sh
^
|
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-# A client side script to test the ESI parsing, see s.sh for serverside
-
-set -e
-
-echo "[2J"
-while true
-do
- sleep 1
- echo "[H"
- fetch -o - -q http://localhost:8080/ | hexdump -C |
- sed 's/$/[K/'
- echo "[J"
-done
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache.h 2606 2008-03-16 14:11:26Z des $
+ * $Id: cache.h 2496 2008-02-17 09:26:32Z des $
*/
#include <sys/time.h>
@@ -34,11 +34,7 @@
#include <sys/socket.h>
#include <pthread.h>
-#ifdef HAVE_PTHREAD_NP_H
-#include <pthread_np.h>
-#endif
#include <stdint.h>
-#include <limits.h>
#include "vqueue.h"
@@ -48,11 +44,8 @@
#include "vcl_returns.h"
#include "common.h"
-#include "heritage.h"
#include "miniobj.h"
-#define HTTP_HDR_MAX_VAL 32
-
enum {
/* Fields from the first line of HTTP proto */
HTTP_HDR_REQ,
@@ -62,27 +55,19 @@
HTTP_HDR_RESPONSE,
/* HTTP header lines */
HTTP_HDR_FIRST,
- HTTP_HDR_MAX = HTTP_HDR_MAX_VAL
+ HTTP_HDR_MAX = 32 /* XXX: should be #defined */
};
-/* Note: intentionally not IOV_MAX unless it has to be */
-#if (IOV_MAX < (HTTP_HDR_MAX_VAL * 2))
-# define MAX_IOVS IOV_MAX
-#else
-# define MAX_IOVS (HTTP_HDR_MAX_VAL * 2)
-#endif
+/* Note: intentionally not IOV_MAX */
+#define MAX_IOVS (HTTP_HDR_MAX * 2)
struct cli;
struct vsb;
struct sess;
struct object;
struct objhead;
-struct objexp;
struct workreq;
struct addrinfo;
-struct esi_bit;
-struct vrt_backend;
-struct cli_proto;
/*--------------------------------------------------------------------*/
@@ -111,7 +96,6 @@
char *f; /* (F)ree pointer */
char *r; /* (R)eserved length */
char *e; /* (E)nd of buffer */
- int overflow; /* workspace overflowed */
};
/*--------------------------------------------------------------------
@@ -177,7 +161,7 @@
double used;
- pthread_cond_t cond;
+ int pipe[2];
VTAILQ_ENTRY(worker) list;
struct workreq *wrq;
@@ -230,7 +214,7 @@
off_t where;
};
-/* Object structure --------------------------------------------------*/
+/* -------------------------------------------------------------------*/
struct object {
unsigned magic;
@@ -239,11 +223,11 @@
unsigned xid;
struct objhead *objhead;
struct storage *objstore;
- struct objexp *objexp;
struct ws ws_o[1];
unsigned char *vary;
+ unsigned heap_idx;
unsigned ban_seq;
unsigned pass;
@@ -259,23 +243,19 @@
double age;
double entered;
double ttl;
- double grace;
- double prefetch;
double last_modified;
struct http http[1];
VTAILQ_ENTRY(object) list;
- VTAILQ_HEAD(, storage) store;
+ VTAILQ_ENTRY(object) deathrow;
- VTAILQ_HEAD(, esi_bit) esibits;
+ VTAILQ_HEAD(, storage) store;
- double last_use;
+ VTAILQ_HEAD(, sess) waitinglist;
- /* Prefetch */
- struct object *parent;
- struct object *child;
+ double lru_stamp;
};
struct objhead {
@@ -287,7 +267,6 @@
VTAILQ_HEAD(,object) objects;
char *hash;
unsigned hashlen;
- VTAILQ_HEAD(, sess) waitinglist;
};
/* -------------------------------------------------------------------*/
@@ -300,7 +279,6 @@
unsigned xid;
int restarts;
- int esis;
struct worker *wrk;
@@ -331,24 +309,18 @@
double t_resp;
double t_end;
- /* Acceptable grace period */
- double grace;
-
enum step step;
unsigned cur_method;
unsigned handling;
- unsigned char sendbody;
unsigned char wantbody;
int err_code;
const char *err_reason;
VTAILQ_ENTRY(sess) list;
- struct director *director;
struct backend *backend;
struct bereq *bereq;
struct object *obj;
- struct objhead *objhead;
struct VCL_conf *vcl;
/* Various internal stuff */
@@ -364,23 +336,6 @@
const char **hashptr;
};
-/* -------------------------------------------------------------------
- * A director is a piece of code which selects one of possibly multiple
- * backends to use.
- */
-
-typedef struct backend *vdi_choose_f(struct sess *sp);
-typedef void vdi_fini_f(struct director *d);
-
-struct director {
- unsigned magic;
-#define DIRECTOR_MAGIC 0x3336351d
- const char *name;
- vdi_choose_f *choose;
- vdi_fini_f *fini;
- void *priv;
-};
-
/* -------------------------------------------------------------------*/
/* Backend connection */
@@ -390,8 +345,54 @@
VTAILQ_ENTRY(vbe_conn) list;
struct backend *backend;
int fd;
+ void *priv;
+};
+
+
+/* Backend method */
+typedef struct vbe_conn *vbe_getfd_f(const struct sess *sp);
+typedef void vbe_close_f(struct worker *w, struct vbe_conn *vc);
+typedef void vbe_recycle_f(struct worker *w, struct vbe_conn *vc);
+typedef void vbe_init_f(void);
+typedef const char *vbe_gethostname_f(const struct backend *);
+typedef void vbe_cleanup_f(const struct backend *);
+typedef void vbe_updatehealth_f(const struct sess *sp, const struct vbe_conn *vc, int);
+
+struct backend_method {
+ const char *name;
+ vbe_getfd_f *getfd;
+ vbe_close_f *close;
+ vbe_recycle_f *recycle;
+ vbe_cleanup_f *cleanup;
+ vbe_gethostname_f *gethostname;
+ vbe_updatehealth_f *updatehealth;
+ vbe_init_f *init;
+};
+
+/* Backend indstance */
+struct backend {
+ unsigned magic;
+#define BACKEND_MAGIC 0x64c4c7c6
+ char *vcl_name;
+
+ VTAILQ_ENTRY(backend) list;
+ int refcount;
+ pthread_mutex_t mtx;
+
+ struct backend_method *method;
+ void *priv;
+
+ int health;
+ double last_check;
+ int minute_limit;
};
+/*
+ * NB: This list is not locked, it is only ever manipulated from the
+ * cachers CLI thread.
+ */
+VTAILQ_HEAD(backendlist, backend);
+
/* Prototypes etc ----------------------------------------------------*/
@@ -405,20 +406,33 @@
/* cache_backend.c */
void VBE_Init(void);
-struct vbe_conn *VBE_GetFd(struct sess *sp);
+struct vbe_conn *VBE_GetFd(const struct sess *sp);
void VBE_ClosedFd(struct worker *w, struct vbe_conn *vc);
void VBE_RecycleFd(struct worker *w, struct vbe_conn *vc);
struct bereq * VBE_new_bereq(void);
void VBE_free_bereq(struct bereq *bereq);
+extern struct backendlist backendlist;
void VBE_DropRef(struct backend *);
-struct backend *VBE_AddBackend(struct cli *cli, const struct vrt_backend *vb);
+void VBE_DropRefLocked(struct backend *);
+struct backend *VBE_NewBackend(struct backend_method *method);
+struct vbe_conn *VBE_NewConn(void);
+void VBE_ReleaseConn(struct vbe_conn *);
void VBE_UpdateHealth(const struct sess *sp, const struct vbe_conn *, int);
-void VBE_AddHostHeader(struct sess *sp);
-void VBE_SelectBackend(struct sess *sp);
+
+/* convenience functions for backend methods */
+int VBE_TryConnect(const struct sess *sp, const struct addrinfo *ai);
+int VBE_CheckFd(int fd);
+
+/* cache_backend_simple.c */
+extern struct backend_method backend_method_simple;
+extern struct backend_method backend_method_random;
+extern struct backend_method backend_method_round_robin;
/* cache_ban.c */
void AddBan(const char *, int hash);
void BAN_Init(void);
+void cli_func_url_purge(struct cli *cli, const char * const *av, void *priv);
+void cli_func_hash_purge(struct cli *cli, const char * const *av, void *priv);
void BAN_NewObj(struct object *o);
int BAN_CheckObject(struct object *o, const char *url, const char *hash);
@@ -428,29 +442,23 @@
/* cache_cli.c [CLI] */
void CLI_Init(void);
-void CLI_Run(void);
-enum cli_set_e {MASTER_CLI, PUBLIC_CLI, DEBUG_CLI};
-void CLI_AddFuncs(enum cli_set_e which, struct cli_proto *p);
-extern pthread_t cli_thread;
-#define ASSERT_CLI() do {assert(pthread_self() == cli_thread);} while (0)
/* cache_expiry.c */
-void EXP_Insert(struct object *o, double now);
+void EXP_Insert(struct object *o);
void EXP_Init(void);
-void EXP_Rearm(const struct object *o);
-void EXP_Touch(const struct object *o, double now);
+void EXP_TTLchange(struct object *o);
+void EXP_Touch(struct object *o, double now);
int EXP_NukeOne(struct sess *sp);
/* cache_fetch.c */
int Fetch(struct sess *sp);
-int FetchReqBody(struct sess *sp);
/* cache_hash.c */
void HSH_Prealloc(struct sess *sp);
int HSH_Compare(const struct sess *sp, const struct objhead *o);
void HSH_Copy(const struct sess *sp, const struct objhead *o);
struct object *HSH_Lookup(struct sess *sp);
-void HSH_Unbusy(struct sess *sp);
+void HSH_Unbusy(struct object *o);
void HSH_Ref(struct object *o);
void HSH_Deref(struct object *o);
void HSH_Init(void);
@@ -494,9 +502,6 @@
#include "http_headers.h"
#undef HTTPH
-/* cache_main.c */
-void THR_Name(const char *name);
-
/* cache_pipe.c */
void PipeSession(struct sess *sp);
@@ -507,9 +512,9 @@
unsigned WRK_Flush(struct worker *w);
unsigned WRK_Write(struct worker *w, const void *ptr, int len);
unsigned WRK_WriteH(struct worker *w, const txt *hh, const char *suf);
-#ifdef SENDFILE_WORKS
+#ifdef HAVE_SENDFILE
void WRK_Sendfile(struct worker *w, int fd, off_t off, unsigned len);
-#endif /* SENDFILE_WORKS */
+#endif /* HAVE_SENDFILE */
/* cache_session.c [SES] */
void SES_Init(void);
@@ -522,21 +527,14 @@
void VSL_Init(void);
#ifdef SHMLOGHEAD_MAGIC
+void VSLR(enum shmlogtag tag, int id, txt t);
void VSL(enum shmlogtag tag, int id, const char *fmt, ...);
void WSLR(struct worker *w, enum shmlogtag tag, int id, txt t);
void WSL(struct worker *w, enum shmlogtag tag, int id, const char *fmt, ...);
-void WSL_Flush(struct worker *w, int overflow);
-
-#define DSL(flag, tag, id, ...) \
- do { \
- if (params->diag_bitmap & (flag)) \
- VSL((tag), (id), __VA_ARGS__); \
- } while (0)
-
-#define WSP(sess, tag, ...) \
- WSL((sess)->wrk, tag, (sess)->fd, __VA_ARGS__)
-
-#define WSPR(sess, tag, txt) \
+void WSL_Flush(struct worker *w);
+#define WSP(sess, tag, fmt, ...) \
+ WSL((sess)->wrk, tag, (sess)->fd, fmt, __VA_ARGS__)
+#define WSPR(sess, tag, txt) \
WSLR((sess)->wrk, tag, (sess)->fd, txt)
#define INCOMPL() do { \
@@ -548,10 +546,11 @@
/* cache_response.c */
void RES_BuildHttp(struct sess *sp);
+void RES_Error(struct sess *sp, int code, const char *reason);
void RES_WriteObj(struct sess *sp);
/* cache_synthetic.c */
-void SYN_ErrorPage(struct sess *sp, int status, const char *reason);
+void SYN_ErrorPage(struct sess *sp, int status, const char *reason, int ttl);
/* cache_vary.c */
void VRY_Create(const struct sess *sp);
@@ -562,7 +561,6 @@
void VCL_Refresh(struct VCL_conf **vcc);
void VCL_Rel(struct VCL_conf **vcc);
void VCL_Get(struct VCL_conf **vcc);
-void VCL_Idle(void);
#define VCL_RET_MAC(l,u,b,n)
#define VCL_MET_MAC(l,u,b) void VCL_##l##_method(struct sess *);
@@ -570,10 +568,13 @@
#undef VCL_MET_MAC
#undef VCL_RET_MAC
-/* cache_vrt_esi.c */
-
-void ESI_Deliver(struct sess *);
-void ESI_Destroy(struct object *);
+#ifdef CLI_PRIV_H
+cli_func_t cli_func_config_list;
+cli_func_t cli_func_config_load;
+cli_func_t cli_func_config_discard;
+cli_func_t cli_func_config_use;
+cli_func_t cli_func_dump_pool;
+#endif
/* cache_ws.c */
@@ -586,58 +587,41 @@
char *WS_Alloc(struct ws *ws, unsigned bytes);
char *WS_Dup(struct ws *ws, const char *);
char *WS_Snapshot(struct ws *ws);
-unsigned WS_Free(struct ws *ws);
/* rfc2616.c */
int RFC2616_cache_policy(const struct sess *sp, const struct http *hp);
+#if 1
#define MTX pthread_mutex_t
#define MTX_INIT(foo) AZ(pthread_mutex_init(foo, NULL))
#define MTX_DESTROY(foo) AZ(pthread_mutex_destroy(foo))
-#define TRYLOCK(foo, r) \
-do { \
- (r) = pthread_mutex_trylock(foo); \
- assert(r == 0 || r == EBUSY); \
- if (params->diag_bitmap & 0x8) { \
- VSL(SLT_Debug, 0, \
- "MTX_TRYLOCK(%s,%s,%d," #foo ") = %d", \
- __func__, __FILE__, __LINE__, (r)); \
- } \
-} while (0)
-#define LOCK(foo) \
-do { \
- if (!(params->diag_bitmap & 0x18)) { \
- AZ(pthread_mutex_lock(foo)); \
- } else { \
- int ixjd = pthread_mutex_trylock(foo); \
- assert(ixjd == 0 || ixjd == EBUSY); \
- if (ixjd) { \
- VSL(SLT_Debug, 0, \
- "MTX_CONTEST(%s,%s,%d," #foo ")", \
- __func__, __FILE__, __LINE__); \
- AZ(pthread_mutex_lock(foo)); \
- } else if (params->diag_bitmap & 0x8) { \
- VSL(SLT_Debug, 0, \
- "MTX_LOCK(%s,%s,%d," #foo ")", \
- __func__, __FILE__, __LINE__); \
- } \
- } \
-} while (0)
-#define UNLOCK(foo) \
-do { \
- AZ(pthread_mutex_unlock(foo)); \
- if (params->diag_bitmap & 0x8) \
- VSL(SLT_Debug, 0, \
- "MTX_UNLOCK(%s,%s,%d," #foo ")", \
- __func__, __FILE__, __LINE__); \
-} while (0)
-
-#if defined(HAVE_PTHREAD_MUTEX_ISOWNED_NP)
-#define ALOCKED(mutex) AN(pthread_mutex_isowned_np((mutex)))
-#elif defined(DIAGNOSTICS)
-#define ALOCKED(mutex) AN(pthread_mutex_trylock((mutex)))
+#define LOCK(foo) AZ(pthread_mutex_lock(foo))
+#define UNLOCK(foo) AZ(pthread_mutex_unlock(foo))
#else
-#define ALOCKED(mutex) (void)(mutex)
+#define MTX pthread_mutex_t
+#define MTX_INIT(foo) AZ(pthread_mutex_init(foo, NULL))
+#define MTX_DESTROY(foo) AZ(pthread_mutex_destroy(foo))
+#define LOCK(foo) \
+do { \
+ if (pthread_mutex_trylock(foo)) { \
+ VSL(SLT_Debug, 0, \
+ "MTX_CONTEST(%s,%s,%d," #foo ")", \
+ __func__, __FILE__, __LINE__); \
+ AZ(pthread_mutex_lock(foo)); \
+ } else if (1) { \
+ VSL(SLT_Debug, 0, \
+ "MTX_LOCK(%s,%s,%d," #foo ")", \
+ __func__, __FILE__, __LINE__); \
+ } \
+} while (0);
+#define UNLOCK(foo) \
+do { \
+ AZ(pthread_mutex_unlock(foo)); \
+ if (1) \
+ VSL(SLT_Debug, 0, \
+ "MTX_UNLOCK(%s,%s,%d," #foo ")", \
+ __func__, __FILE__, __LINE__); \
+} while (0);
#endif
/*
@@ -677,9 +661,7 @@
}
#ifdef WITHOUT_ASSERTS
-#define spassert(cond) ((void)(cond))
-#define SPAZ(val) ((void)(val) == 0)
-#define SPAN(val) ((void)(val) != 0)
+#define spassert(cond) ((void)0)
#else
void panic(const char *, int, const char *,
const struct sess *, const char *, ...);
@@ -690,6 +672,4 @@
panic(__FILE__, __LINE__, __func__, sp, \
"assertion failed: %s\n", #cond); \
} while (0)
-#define SPAZ(val) spassert((val) == 0)
-#define SPAN(val) spassert((val) != 0)
#endif
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_acceptor.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_acceptor.c 2632 2008-04-21 06:33:37Z phk $
+ * $Id: cache_acceptor.c 2564 2008-03-08 13:38:23Z des $
*
* XXX: We need to pass sessions back into the event engine when they are
* reused. Not sure what the most efficient way is for that. For now
@@ -50,8 +50,7 @@
#include "compat/srandomdev.h"
#endif
-#include "cli.h"
-#include "cli_priv.h"
+#include "heritage.h"
#include "shmlog.h"
#include "cache.h"
#include "cache_acceptor.h"
@@ -157,7 +156,6 @@
unsigned u;
double now;
- THR_Name("cache-acceptor");
(void)arg;
/* Set up the poll argument */
@@ -203,7 +201,7 @@
addr = (void*)&addr_s;
i = accept(pfd[u].fd, addr, &l);
if (i < 0) {
- if (errno != EAGAIN && errno != ECONNABORTED) {
+ if (errno != EAGAIN) {
VSL(SLT_Debug, pfd[u].fd,
"Accept failed errno=%d", errno);
/* XXX: stats ? */
@@ -270,22 +268,17 @@
AZ(sp->obj);
AZ(sp->vcl);
assert(sp->fd >= 0);
- if (vca_act->pass == NULL)
- assert(sizeof sp == write(vca_pipes[1], &sp, sizeof sp));
- else
- vca_act->pass(sp);
+ assert(sizeof sp == write(vca_pipes[1], &sp, sizeof sp));
}
/*--------------------------------------------------------------------*/
-static void
-ccf_start(struct cli *cli, const char * const *av, void *priv)
+void
+VCA_Init(void)
{
- (void)cli;
- (void)av;
- (void)priv;
+
/* XXX: Add selector mechanism at some point */
vca_act = vca_acceptors[0];
@@ -293,21 +286,8 @@
fprintf(stderr, "No acceptor in program\n");
exit (2);
}
- if (vca_act->pass == NULL)
- AZ(pipe(vca_pipes));
+ AZ(pipe(vca_pipes));
vca_act->init();
AZ(pthread_create(&vca_thread_acct, NULL, vca_acct, NULL));
VSL(SLT_Debug, 0, "Acceptor is %s", vca_act->name);
}
-
-static struct cli_proto vca_cmds[] = {
- { CLI_SERVER_START, ccf_start },
- { NULL }
-};
-
-void
-VCA_Init(void)
-{
-
- CLI_AddFuncs(MASTER_CLI, vca_cmds);
-}
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_acceptor.h
^
|
@@ -26,18 +26,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_acceptor.h 2632 2008-04-21 06:33:37Z phk $
+ * $Id: cache_acceptor.h 2496 2008-02-17 09:26:32Z des $
*/
struct sess;
typedef void acceptor_init_f(void);
-typedef void acceptor_pass_f(struct sess *);
struct acceptor {
const char *name;
acceptor_init_f *init;
- acceptor_pass_f *pass;
};
#if defined(HAVE_EPOLL_CTL)
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_acceptor_epoll.c
^
|
@@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_acceptor_epoll.c 2515 2008-02-19 11:52:27Z phk $
+ * $Id: cache_acceptor_epoll.c 2564 2008-03-08 13:38:23Z des $
*
* XXX: We need to pass sessions back into the event engine when they are
* reused. Not sure what the most efficient way is for that. For now
@@ -43,6 +43,7 @@
#include <sys/epoll.h>
+#include "heritage.h"
#include "shmlog.h"
#include "cache.h"
#include "cache_acceptor.h"
@@ -74,7 +75,6 @@
struct sess *sp, *sp2;
int i;
- THR_Name("cache-epoll");
(void)arg;
epfd = epoll_create(16);
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_acceptor_kqueue.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_acceptor_kqueue.c 2603 2008-03-13 10:29:14Z phk $
+ * $Id: cache_acceptor_kqueue.c 2564 2008-03-08 13:38:23Z des $
*
* XXX: We need to pass sessions back into the event engine when they are
* reused. Not sure what the most efficient way is for that. For now
@@ -38,7 +38,6 @@
#if defined(HAVE_KQUEUE)
#include <stdio.h>
-#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
@@ -46,18 +45,14 @@
#include <sys/event.h>
+#include "heritage.h"
#include "shmlog.h"
#include "cache.h"
#include "cache_acceptor.h"
-
-/**********************************************************************/
-
-
static pthread_t vca_kqueue_thread;
static int kq = -1;
-
static VTAILQ_HEAD(,sess) sesshead = VTAILQ_HEAD_INITIALIZER(sesshead);
#define NKEV 100
@@ -66,27 +61,17 @@
static unsigned nki;
static void
-vca_kq_flush(void)
-{
- int i;
-
- if (nki == 0)
- return;
- i = kevent(kq, ki, nki, NULL, 0, NULL);
- assert(i == 0);
- nki = 0;
-}
-
-static void
vca_kq_sess(struct sess *sp, short arm)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- assert(sp->fd >= 0);
- DSL(0x04, SLT_Debug, sp->fd, "KQ: EV_SET sp %p arm %x", sp, arm);
+ if (sp->fd < 0)
+ return;
EV_SET(&ki[nki], sp->fd, EVFILT_READ, arm, 0, 0, sp);
- if (++nki == NKEV)
- vca_kq_flush();
+ if (++nki == NKEV || arm == EV_DELETE) {
+ AZ(kevent(kq, ki, nki, NULL, 0, NULL));
+ nki = 0;
+ }
}
static void
@@ -107,7 +92,7 @@
assert(ss[j]->fd >= 0);
AZ(ss[j]->obj);
VTAILQ_INSERT_TAIL(&sesshead, ss[j], list);
- vca_kq_sess(ss[j], EV_ADD | EV_ONESHOT);
+ vca_kq_sess(ss[j], EV_ADD);
j++;
i -= sizeof ss[0];
}
@@ -115,30 +100,24 @@
return;
}
CAST_OBJ_NOTNULL(sp, kp->udata, SESS_MAGIC);
- DSL(0x04, SLT_Debug, sp->id, "KQ: sp %p kev data %lu flags 0x%x%s",
+#ifdef DIAGNOSTICS
+ VSL(SLT_Debug, sp->id, "sp %p kev data %lu flags 0x%x%s",
sp, (unsigned long)kp->data, kp->flags,
(kp->flags & EV_EOF) ? " EOF" : "");
-
- spassert(sp->id == kp->ident);
- spassert(sp->fd == sp->id);
+#endif
if (kp->data > 0) {
i = HTC_Rx(sp->htc);
- if (i == 0) {
- vca_kq_sess(sp, EV_ADD | EV_ONESHOT);
+ if (i == 0)
return; /* more needed */
- }
VTAILQ_REMOVE(&sesshead, sp, list);
+ vca_kq_sess(sp, EV_DELETE);
vca_handover(sp, i);
return;
- } else if (kp->flags & EV_EOF) {
+ } else if (kp->flags == EV_EOF) {
VTAILQ_REMOVE(&sesshead, sp, list);
vca_close_session(sp, "EOF");
SES_Delete(sp);
return;
- } else {
- VSL(SLT_Debug, sp->id, "KQ: sp %p kev data %lu flags 0x%x%s",
- sp, (unsigned long)kp->data, kp->flags,
- (kp->flags & EV_EOF) ? " EOF" : "");
}
}
@@ -152,7 +131,6 @@
double deadline;
struct sess *sp;
- THR_Name("cache-kqueue");
(void)arg;
kq = kqueue();
@@ -170,6 +148,8 @@
assert(n >= 1 && n <= NKEV);
nki = 0;
for (kp = ke, j = 0; j < n; j++, kp++) {
+ if (kp->flags & EV_ERROR)
+ continue;
if (kp->filter == EVFILT_TIMER) {
dotimer = 1;
continue;
@@ -179,14 +159,6 @@
}
if (!dotimer)
continue;
- /*
- * Make sure we have no pending changes for the fd's
- * we are about to close, in case the accept(2) in the
- * other thread creates new fd's betwen our close and
- * the kevent(2) at the top of this loop, the kernel
- * would not know we meant "the old fd of this number".
- */
- vca_kq_flush();
deadline = TIM_real() - params->sess_timeout;
for (;;) {
sp = VTAILQ_FIRST(&sesshead);
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_acceptor_poll.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_acceptor_poll.c 2593 2008-03-11 11:25:28Z des $
+ * $Id: cache_acceptor_poll.c 2564 2008-03-08 13:38:23Z des $
*
*/
@@ -41,6 +41,7 @@
#include <unistd.h>
#include <poll.h>
+#include "heritage.h"
#include "shmlog.h"
#include "cache.h"
#include "cache_acceptor.h"
@@ -56,21 +57,23 @@
static void
vca_pollspace(unsigned fd)
{
- struct pollfd *newpollfd = pollfd;
- unsigned newnpoll = npoll;
+ struct pollfd *p;
+ unsigned u, v;
if (fd < npoll)
return;
- newnpoll = npoll;
- while (fd >= newnpoll)
- newnpoll = newnpoll * 2 + 1;
- VSL(SLT_Debug, 0, "Acceptor poll space increased to %u", newnpoll);
- newpollfd = realloc(newpollfd, newnpoll * sizeof *newpollfd);
- XXXAN(newpollfd); /* close offending fd */
- memset(newpollfd + npoll, 0, (newnpoll - npoll) * sizeof *newpollfd);
- pollfd = newpollfd;
- while (npoll < newnpoll)
- pollfd[npoll++].fd = -1;
+ if (npoll == 0)
+ npoll = 16;
+ for (u = npoll; fd >= u; )
+ u += u;
+ VSL(SLT_Debug, 0, "Acceptor Pollspace %u", u);
+ p = realloc(pollfd, u * sizeof *p);
+ XXXAN(p); /* close offending fd */
+ memset(p + npoll, 0, (u - npoll) * sizeof *p);
+ for (v = npoll ; v <= u; v++)
+ p->fd = -1;
+ pollfd = p;
+ npoll = u;
}
/*--------------------------------------------------------------------*/
@@ -111,7 +114,6 @@
double deadline;
int i, fd;
- THR_Name("cache-poll");
(void)arg;
vca_poll(vca_pipes[0]);
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_backend.c
^
|
@@ -26,49 +26,14 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_backend.c 2559 2008-03-07 11:13:11Z phk $
+ * $Id: cache_backend.c 2564 2008-03-08 13:38:23Z des $
*
- * This is the central switch-board for backend connections and it is
- * slightly complicated by a number of optimizations.
- *
- * The data structures:
- *
- * A backend is a TCP destination, possibly multi-homed and it has a
- * number of associated properties and statistics.
- *
- * A vbe_conn is an open TCP connection to a backend.
- *
- * A bereq is a memory carrier for handling a HTTP transaction with
- * a backend over a vbe_conn.
- *
- * A director is a piece of code that selects which backend to use,
- * by whatever method or metric it chooses.
- *
- * The relationships:
- *
- * Backends and directors get instantiated when VCL's are loaded,
- * and this always happen in the CLI thread.
- *
- * When a VCL tries to instantiate a backend, any existing backend
- * with the same identity (== definition in VCL) will be used instead
- * so that vbe_conn's can be reused across VCL changes.
- *
- * Directors disapper with the VCL that created them.
- *
- * Backends disappear when their reference count drop to zero.
- *
- * Backends have their host/port name looked up to addrinfo structures
- * when they are instantiated, and we just cache that result and cycle
- * through the entries (for multihomed backends) on failure only.
- * XXX: add cli command to redo lookup.
- *
- * bereq is sort of a step-child here, we just manage the pool of them.
+ * Manage backend connections and requests.
*
*/
#include "config.h"
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -77,63 +42,17 @@
#include <sys/socket.h>
#include <netdb.h>
+#include "heritage.h"
#include "shmlog.h"
#include "cache.h"
-#include "vrt.h"
-#include "cli_priv.h"
-
-/* Backend indstance */
-struct backend {
- unsigned magic;
-#define BACKEND_MAGIC 0x64c4c7c6
-
- struct vrt_backend vrt[1];
-
- VTAILQ_ENTRY(backend) list;
- int refcount;
- pthread_mutex_t mtx;
-
- struct addrinfo *ai;
- struct addrinfo *last_ai;
- VTAILQ_HEAD(, vbe_conn) connlist;
-
- int health;
-};
-
-static MTX VBE_mtx;
-
-/*
- * List of cached vbe_conns, used if enabled in params/heritage
- */
-static VTAILQ_HEAD(,vbe_conn) vbe_conns = VTAILQ_HEAD_INITIALIZER(vbe_conns);
-
-/*
- * List of cached bereq's
- */
static VTAILQ_HEAD(,bereq) bereq_head = VTAILQ_HEAD_INITIALIZER(bereq_head);
+static VTAILQ_HEAD(,vbe_conn) vbe_head = VTAILQ_HEAD_INITIALIZER(vbe_head);
-/*
- * The list of backends is not locked, it is only ever accessed from
- * the CLI thread, so there is no need.
- */
-static VTAILQ_HEAD(, backend) backends =
- VTAILQ_HEAD_INITIALIZER(backends);
+static MTX VBE_mtx;
-/*--------------------------------------------------------------------
- * Create default Host: header for backend request
- */
-void
-VBE_AddHostHeader(struct sess *sp)
-{
+struct backendlist backendlist = VTAILQ_HEAD_INITIALIZER(backendlist);
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- CHECK_OBJ_NOTNULL(sp->bereq, BEREQ_MAGIC);
- CHECK_OBJ_NOTNULL(sp->bereq->http, HTTP_MAGIC);
- CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
- http_PrintfHeader(sp->wrk, sp->fd, sp->bereq->http,
- "Host: %s", sp->backend->vrt->hostname);
-}
/*--------------------------------------------------------------------
* Attempt to connect to a given addrinfo entry.
@@ -144,7 +63,7 @@
*
*/
-static int
+int
VBE_TryConnect(const struct sess *sp, const struct addrinfo *ai)
{
struct sockaddr_storage ss;
@@ -154,9 +73,6 @@
char abuf1[TCP_ADDRBUFSIZE], abuf2[TCP_ADDRBUFSIZE];
char pbuf1[TCP_PORTBUFSIZE], pbuf2[TCP_PORTBUFSIZE];
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
-
/*
* ai is only valid with the lock held, so copy out the bits
* we need to make the connection
@@ -184,21 +100,22 @@
}
TCP_myname(s, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1);
- TCP_name((void*)&ss, alen, abuf2, sizeof abuf2, pbuf2, sizeof pbuf2);
+ TCP_name((void*)&ss, alen,
+ abuf2, sizeof abuf2, pbuf2, sizeof pbuf2);
WSL(sp->wrk, SLT_BackendOpen, s, "%s %s %s %s %s",
- sp->backend->vrt->vcl_name, abuf1, pbuf1, abuf2, pbuf2);
+ sp->backend->vcl_name, abuf1, pbuf1, abuf2, pbuf2);
LOCK(&sp->backend->mtx);
return (s);
}
/*--------------------------------------------------------------------
- * Check that there is still something at the far end of a given socket.
+ * Check that there is still something at the far end of a given fd.
* We poll the fd with instant timeout, if there are any events we can't
* use it (backends are not allowed to pipeline).
*/
-static int
+int
VBE_CheckFd(int fd)
{
struct pollfd pfd;
@@ -210,10 +127,7 @@
}
/*--------------------------------------------------------------------
- * Get a bereq structure for talking HTTP with the backend.
- * First attempt to pick one from our stash, else make a new.
- *
- * Can fail with NULL.
+ * Get a http structure for talking to the backend.
*/
struct bereq *
@@ -230,21 +144,19 @@
if (bereq != NULL) {
CHECK_OBJ(bereq, BEREQ_MAGIC);
} else {
- len = params->sess_workspace;
+ len = params->mem_workspace;
bereq = calloc(sizeof *bereq + len, 1);
if (bereq == NULL)
return (NULL);
bereq->magic = BEREQ_MAGIC;
WS_Init(bereq->ws, "bereq", bereq + 1, len);
- VSL_stats->n_bereq++;
}
http_Setup(bereq->http, bereq->ws);
return (bereq);
}
-/*--------------------------------------------------------------------
- * Return a bereq to the stash.
- */
+/*--------------------------------------------------------------------*/
+/* XXX: no backpressure on pool size */
void
VBE_free_bereq(struct bereq *bereq)
@@ -257,90 +169,91 @@
UNLOCK(&VBE_mtx);
}
-/*--------------------------------------------------------------------
- * Manage a pool of vbe_conn structures.
- * XXX: as an experiment, make this caching controled by a parameter
- * XXX: so we can see if it has any effect.
- */
+/*--------------------------------------------------------------------*/
-static struct vbe_conn *
+struct vbe_conn *
VBE_NewConn(void)
{
struct vbe_conn *vc;
- vc = VTAILQ_FIRST(&vbe_conns);
+ vc = VTAILQ_FIRST(&vbe_head);
if (vc != NULL) {
LOCK(&VBE_mtx);
- vc = VTAILQ_FIRST(&vbe_conns);
+ vc = VTAILQ_FIRST(&vbe_head);
if (vc != NULL) {
VSL_stats->backend_unused--;
- VTAILQ_REMOVE(&vbe_conns, vc, list);
+ VTAILQ_REMOVE(&vbe_head, vc, list);
+ } else {
+ VSL_stats->n_vbe_conn++;
}
UNLOCK(&VBE_mtx);
}
if (vc != NULL)
return (vc);
+
vc = calloc(sizeof *vc, 1);
XXXAN(vc);
vc->magic = VBE_CONN_MAGIC;
vc->fd = -1;
- VSL_stats->n_vbe_conn++;
return (vc);
}
-static void
+/*--------------------------------------------------------------------*/
+
+void
VBE_ReleaseConn(struct vbe_conn *vc)
{
CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC);
assert(vc->backend == NULL);
assert(vc->fd < 0);
+ LOCK(&VBE_mtx);
+ VTAILQ_INSERT_HEAD(&vbe_head, vc, list);
+ VSL_stats->backend_unused++;
+ UNLOCK(&VBE_mtx);
+}
- if (params->cache_vbe_conns) {
- LOCK(&VBE_mtx);
- VTAILQ_INSERT_HEAD(&vbe_conns, vc, list);
- VSL_stats->backend_unused++;
- UNLOCK(&VBE_mtx);
- } else {
- VSL_stats->n_vbe_conn--;
- free(vc);
- }
+/*--------------------------------------------------------------------*/
+
+struct backend *
+VBE_NewBackend(struct backend_method *method)
+{
+ struct backend *b;
+
+ b = calloc(sizeof *b, 1);
+ XXXAN(b);
+ b->magic = BACKEND_MAGIC;
+ b->method = method;
+
+ MTX_INIT(&b->mtx);
+ b->refcount = 1;
+
+ b->last_check = TIM_mono();
+ b->minute_limit = 1;
+
+ VTAILQ_INSERT_TAIL(&backendlist, b, list);
+ return (b);
}
-/*--------------------------------------------------------------------
- * Drop a reference to a backend.
- * The last reference must come from the watcher in the CLI thread,
- * as only that thread is allowed to clean up the backend list.
- */
+/*--------------------------------------------------------------------*/
-static void
+void
VBE_DropRefLocked(struct backend *b)
{
int i;
- struct vbe_conn *vbe, *vbe2;
CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC);
- assert(b->refcount > 0);
i = --b->refcount;
+ if (i == 0)
+ VTAILQ_REMOVE(&backendlist, b, list);
UNLOCK(&b->mtx);
- if (i > 0)
+ if (i)
return;
-
- ASSERT_CLI();
- VTAILQ_REMOVE(&backends, b, list);
- VTAILQ_FOREACH_SAFE(vbe, &b->connlist, list, vbe2) {
- VTAILQ_REMOVE(&b->connlist, vbe, list);
- if (vbe->fd >= 0)
- AZ(close(vbe->fd));
- VBE_ReleaseConn(vbe);
- }
- free(TRUST_ME(b->vrt->ident));
- free(TRUST_ME(b->vrt->hostname));
- free(TRUST_ME(b->vrt->portname));
b->magic = 0;
+ b->method->cleanup(b);
+ free(b->vcl_name);
free(b);
- VSL_stats->n_backend--;
}
void
@@ -353,129 +266,17 @@
VBE_DropRefLocked(b);
}
-/*--------------------------------------------------------------------
- * Try to get a socket connected to one of the addresses on the list.
- * We start from the cached "last good" address and try all items on
- * the list exactly once.
- *
- * Called with backend mutex held, but will release/acquire it.
- *
- * XXX: Not ready for DNS re-lookups
- */
-
-static int
-bes_conn_try_list(const struct sess *sp, struct backend *bp)
-{
- struct addrinfo *ai, *from;
- int s, loops;
-
- CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC);
-
- /* No addrinfo, no connection */
- if (bp->ai == NULL)
- return (-1);
- AN(bp->last_ai);
-
- /* Called with lock held */
- loops = 0;
- ai = from = bp->last_ai;
- while (loops == 0 || ai != from) {
-
- /* NB: releases/acquires backend lock */
- s = VBE_TryConnect(sp, ai);
-
- if (s >= 0) {
- bp->last_ai = ai;
- return (s);
- }
-
- /* Try next one */
- ai = ai->ai_next;
- if (ai == NULL) {
- loops++;
- ai = bp->ai;
- }
- }
- /* We have tried them all, fail */
- return (-1);
-}
-
-
-/*--------------------------------------------------------------------*/
-
-static int
-bes_conn_try(const struct sess *sp, struct backend *bp)
-{
- int s;
-
- LOCK(&bp->mtx);
- bp->refcount++;
- s = bes_conn_try_list(sp, bp); /* releases/acquires backend lock */
- if (s < 0)
- bp->refcount--; /* Only keep ref on success */
- UNLOCK(&bp->mtx);
- return (s);
-}
-
-/*--------------------------------------------------------------------*/
-
-void
-VBE_SelectBackend(struct sess *sp)
-{
- struct backend *bp;
-
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC);
- bp = sp->director->choose(sp);
- CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC);
- sp->backend = bp;
-}
-
/*--------------------------------------------------------------------*/
struct vbe_conn *
-VBE_GetFd(struct sess *sp)
+VBE_GetFd(const struct sess *sp)
{
- struct backend *bp;
- struct vbe_conn *vc;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- bp = sp->backend;
-
- /* first look for vbe_conn's we can recycle */
- while (1) {
- LOCK(&bp->mtx);
- vc = VTAILQ_FIRST(&bp->connlist);
- if (vc != NULL) {
- bp->refcount++;
- assert(vc->backend == bp);
- assert(vc->fd >= 0);
- VTAILQ_REMOVE(&bp->connlist, vc, list);
- }
- UNLOCK(&bp->mtx);
- if (vc == NULL)
- break;
- if (VBE_CheckFd(vc->fd)) {
- /* XXX locking of stats */
- VSL_stats->backend_reuse += 1;
- VSL_stats->backend_conn++;
- return (vc);
- }
- VBE_ClosedFd(sp->wrk, vc);
- }
-
- vc = VBE_NewConn();
- assert(vc->fd == -1);
- AZ(vc->backend);
- vc->fd = bes_conn_try(sp, bp);
- if (vc->fd < 0) {
- VBE_ReleaseConn(vc);
- VSL_stats->backend_fail++;
- return (NULL);
- }
- vc->backend = bp;
- VSL_stats->backend_conn++;
- return (vc);
+ CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
+ AN(sp->backend->method);
+ AN(sp->backend->method->getfd);
+ return(sp->backend->method->getfd(sp));
}
/* Close a connection ------------------------------------------------*/
@@ -484,19 +285,13 @@
VBE_ClosedFd(struct worker *w, struct vbe_conn *vc)
{
struct backend *b;
- int i;
CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC);
CHECK_OBJ_NOTNULL(vc->backend, BACKEND_MAGIC);
b = vc->backend;
- assert(vc->fd >= 0);
- WSL(w, SLT_BackendClose, vc->fd, "%s", vc->backend->vrt->vcl_name);
- i = close(vc->fd);
- assert(i == 0 || errno == ECONNRESET || errno == ENOTCONN);
- vc->fd = -1;
- VBE_DropRef(vc->backend);
- vc->backend = NULL;
- VBE_ReleaseConn(vc);
+ AN(b->method);
+ AN(b->method->close);
+ b->method->close(w, vc);
CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC);
}
@@ -505,18 +300,15 @@
void
VBE_RecycleFd(struct worker *w, struct vbe_conn *vc)
{
- struct backend *bp;
+ struct backend *b;
CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC);
CHECK_OBJ_NOTNULL(vc->backend, BACKEND_MAGIC);
- assert(vc->fd >= 0);
- bp = vc->backend;
- WSL(w, SLT_BackendReuse, vc->fd, "%s", vc->backend->vrt->vcl_name);
- LOCK(&vc->backend->mtx);
- VSL_stats->backend_recycle++;
- VTAILQ_INSERT_HEAD(&bp->connlist, vc, list);
- VBE_DropRefLocked(vc->backend);
- CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC);
+ b = vc->backend;
+ AN(b->method);
+ AN(b->method->recycle);
+ b->method->recycle(w, vc);
+ CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC);
}
/* Update health ----------------------------------------------------*/
@@ -526,11 +318,6 @@
void
VBE_UpdateHealth(const struct sess *sp, const struct vbe_conn *vc, int a)
{
- (void)sp;
- (void)vc;
- (void)a;
-#if 0
- INCOMPL();
struct backend *b;
if (vc != NULL) {
@@ -547,118 +334,18 @@
if(b->method->updatehealth != NULL)
b->method->updatehealth(sp, vc, a);
CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC);
-#endif
}
-/*--------------------------------------------------------------------
- * DNS lookup of backend host/port
- */
+/*--------------------------------------------------------------------*/
static void
-vbe_dns_lookup(struct cli *cli, struct backend *bp)
-{
- int error;
- struct addrinfo *res, hint, *old;
-
- CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC);
-
- memset(&hint, 0, sizeof hint);
- hint.ai_family = PF_UNSPEC;
- hint.ai_socktype = SOCK_STREAM;
- res = NULL;
- error = getaddrinfo(bp->vrt->hostname, bp->vrt->portname,
- &hint, &res);
- if (error) {
- if (res != NULL)
- freeaddrinfo(res);
- /*
- * We cannot point to the source code any more, it may
- * be long gone from memory. We already checked over in
- * the VCL compiler, so this is only relevant for refreshes.
- * XXX: which we do when exactly ?
- */
- cli_out(cli, "DNS(/hosts) lookup failed for (%s/%s): %s",
- bp->vrt->hostname, bp->vrt->portname, gai_strerror(error));
- return;
- }
- LOCK(&bp->mtx);
- old = bp->ai;
- bp->ai = res;
- bp->last_ai = res;
- UNLOCK(&bp->mtx);
- if (old != NULL)
- freeaddrinfo(old);
-}
-
-/*--------------------------------------------------------------------
- * Add a backend/director instance when loading a VCL.
- * If an existing backend is matched, grab a refcount and return one.
- * Else create a new backend structure with reference initialized to one
- * and return zero.
- */
-
-struct backend *
-VBE_AddBackend(struct cli *cli, const struct vrt_backend *vb)
+VBE_AddBackendMethod(const struct backend_method *bem)
{
- struct backend *b;
-
- AN(vb->hostname);
- AN(vb->portname);
- AN(vb->ident);
- (void)cli;
- ASSERT_CLI();
- VTAILQ_FOREACH(b, &backends, list) {
- CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC);
- if (strcmp(b->vrt->ident, vb->ident))
- continue;
- b->refcount++;
- return (b);
- }
-
- b = calloc(sizeof *b, 1);
- XXXAN(b);
- b->magic = BACKEND_MAGIC;
- VTAILQ_INIT(&b->connlist);
-
- memcpy(b->vrt, vb, sizeof *vb);
- /*
- * This backend may live longer than the VCL that instantiated it
- * so we cannot simply reference the VCL's copy of the strings.
- */
- b->vrt->ident = strdup(vb->ident);
- XXXAN(b->vrt->ident);
- b->vrt->hostname = strdup(vb->hostname);
- XXXAN(b->vrt->hostname);
- b->vrt->portname = strdup(vb->portname);
- XXXAN(b->vrt->portname);
- b->vrt->vcl_name = strdup(vb->vcl_name);
- XXXAN(b->vrt->vcl_name);
-
- MTX_INIT(&b->mtx);
- b->refcount = 1;
-
- vbe_dns_lookup(cli, b);
- VTAILQ_INSERT_TAIL(&backends, b, list);
- VSL_stats->n_backend++;
- return (b);
+ if (bem->init != NULL)
+ bem->init();
}
-
-/*--------------------------------------------------------------------*/
-
-void
-VRT_fini_dir(struct cli *cli, struct director *b)
-{
-
- ASSERT_CLI();
-#if 0
- VBE_DropRef(b);
-#else
- (void)b;
- (void)cli;
-#endif
-}
/*--------------------------------------------------------------------*/
void
@@ -666,4 +353,7 @@
{
MTX_INIT(&VBE_mtx);
+ VBE_AddBackendMethod(&backend_method_simple);
+ VBE_AddBackendMethod(&backend_method_random);
+ VBE_AddBackendMethod(&backend_method_round_robin);
}
|
[-]
[+]
|
Added |
varnish-20080428.tar.bz2/bin/varnishd/cache_backend_random.c
^
|
@@ -0,0 +1,512 @@
+/*-
+ * Copyright (c) 2006 Verdens Gang AS
+ * Copyright (c) 2006-2008 Linpro AS
+ * All rights reserved.
+ *
+ * Author: Cecilie Fritzvold <cecilihf@linpro.no>
+ *
+ * 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.
+ *
+ * $Id: cache_backend_random.c 2496 2008-02-17 09:26:32Z des $
+ *
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <netdb.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "shmlog.h"
+#include "cache.h"
+#include "vrt.h"
+
+
+struct ber {
+ unsigned magic;
+#define BER_MAGIC 0x645b03f4
+ struct brspec *blist;
+ int count;
+#if 0
+ /* Store a hash of the backend info given in
+ * vcl for comparison when a new vcl file is
+ * uploaded. Not in use yet.
+ */
+ unsigned hash;
+#endif
+};
+
+struct brspec {
+ unsigned magic;
+#define BRSPEC_MAGIC 0x5aa072a7
+ struct brspec *next;
+ double limit;
+ char *hostname;
+ char *portname;
+ struct addrinfo *addr;
+ struct addrinfo *last_addr;
+ double dnsttl;
+ double dnstime;
+ unsigned dnsseq;
+ VTAILQ_HEAD(, vbe_conn) connlist;
+ int health;
+};
+
+/*--------------------------------------------------------------------
+ * Try to get a socket connected to one of the addresses on the list.
+ * We start from the cached "last good" address and try all items on
+ * the list exactly once.
+ * If a new DNS lookup is made while we try, we start over and try the
+ * new list exactly once.
+ */
+
+static int
+ber_conn_try_list(const struct sess *sp, struct brspec *bs)
+{
+ struct addrinfo *ai, *from;
+ int s, loops;
+ unsigned myseq;
+
+ CHECK_OBJ_NOTNULL(bs, BRSPEC_MAGIC);
+ if (bs->addr == NULL)
+ return (-1);
+ AN(bs->last_addr);
+
+ /* Called with lock held */
+ myseq = bs->dnsseq;
+ loops = 0;
+ ai = from = bs->last_addr;
+ while (1) {
+
+ /* NB: releases/acquires lock */
+ s = VBE_TryConnect(sp, ai);
+
+ if (s >= 0) {
+ /* Update cached "last good" if still valid */
+ if (myseq == bs->dnsseq)
+ bs->last_addr = ai;
+ return (s);
+ }
+
+ if (myseq != bs->dnsseq) {
+ /* A DNS-lookup happended, try again from start */
+ loops = 0;
+ from = bs->last_addr;
+ ai = from;
+ } else {
+ /* Try next one */
+ ai = ai->ai_next;
+ if (ai == NULL) {
+ loops++;
+ ai = bs->addr;
+ }
+ }
+ if (loops == 1 && ai == from)
+ return (-1);
+ }
+}
+
+/*--------------------------------------------------------------------*/
+
+static const char *
+ber_dns_lookup(struct backend *bp, struct brspec *bs)
+{
+ struct addrinfo *res, hint, *old;
+ int error;
+
+ CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC);
+ CHECK_OBJ_NOTNULL(bs, BRSPEC_MAGIC);
+
+ bs->dnstime = TIM_mono();
+
+ /* Let go of lock while we do sleepable stuff */
+ UNLOCK(&bp->mtx);
+
+ memset(&hint, 0, sizeof hint);
+ hint.ai_family = PF_UNSPEC;
+ hint.ai_socktype = SOCK_STREAM;
+ res = NULL;
+ error = getaddrinfo(bs->hostname,
+ bs->portname == NULL ? "http" : bs->portname,
+ &hint, &res);
+ LOCK(&bp->mtx);
+ if (error) {
+ if (res != NULL)
+ freeaddrinfo(res);
+ return(gai_strerror(error));
+ }
+ bs->dnsseq++;
+ old = bs->addr;
+ bs->last_addr = res;
+ bs->addr = res;
+ if (old != NULL)
+ freeaddrinfo(old);
+ return (NULL);
+}
+
+/*--------------------------------------------------------------------*/
+
+static int
+ber_conn_try(const struct sess *sp, struct backend *bp, struct brspec *bs)
+{
+ int s;
+
+ LOCK(&bp->mtx);
+
+ s = ber_conn_try_list(sp, bs);
+ if (s >= 0) {
+ bp->refcount++;
+ UNLOCK(&bp->mtx);
+ return (s);
+ }
+
+ if (bs->dnstime + bs->dnsttl >= TIM_mono()) {
+ UNLOCK(&bp->mtx);
+ return (-1);
+ }
+
+ (void)ber_dns_lookup(bp, bs);
+
+ /* And try the entire list */
+ s = ber_conn_try_list(sp, bs);
+ if (s >= 0) {
+ bp->refcount++;
+ UNLOCK(&bp->mtx);
+ return (s);
+ }
+
+ UNLOCK(&bp->mtx);
+ return (-1);
+
+}
+
+
+/* Get a backend connection ------------------------------------------
+ *
+ * Get the next backend in the round-robin list, and connect to this.
+ *
+ * Try all cached backend connections for this backend, and use the
+ * first one that is looks like it is still connected.
+ * If that fails to get us a connection, create a new one, reusing a
+ * connection from the freelist, if possible.
+ *
+ * This function is slightly complicated by optimizations on bermtx.
+ */
+
+static struct vbe_conn *
+ber_nextfd(const struct sess *sp)
+{
+ struct vbe_conn *vc;
+ struct backend *bp;
+ int reuse = 0;
+ struct ber *ber;
+ struct brspec *bs;
+ int min_health = -10;
+ int num = 0;
+ double r = 0;
+
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
+ bp = sp->backend;
+ CAST_OBJ_NOTNULL(ber, bp->priv, BER_MAGIC);
+
+ r = (double)rand() / ((double)(RAND_MAX)+1.0);
+ bs = ber->blist;
+ CHECK_OBJ_NOTNULL(bs, BRSPEC_MAGIC);
+ while (r > bs->limit) {
+ bs = bs->next;
+ CHECK_OBJ_NOTNULL(bs, BRSPEC_MAGIC);
+ }
+
+ /* If health is low (bad), use round-robin to find
+ * a server with better health (if possible).
+ */
+ while (bs->health < min_health) {
+ bs = bs->next;
+ num++;
+ if (num > ber->count) {
+ min_health *= 10;
+ num = 0;
+ }
+ }
+
+ while (1) {
+ LOCK(&bp->mtx);
+ vc = VTAILQ_FIRST(&bs->connlist);
+ if (vc != NULL) {
+ bp->refcount++;
+ assert(vc->backend == bp);
+ assert(vc->fd >= 0);
+ VTAILQ_REMOVE(&bs->connlist, vc, list);
+ }
+ UNLOCK(&bp->mtx);
+ if (vc == NULL)
+ break;
+
+ if (VBE_CheckFd(vc->fd)) {
+ /* XXX locking of stats */
+ VSL_stats->backend_reuse += reuse;
+ VSL_stats->backend_conn++;
+ return (vc);
+ }
+ VBE_ClosedFd(sp->wrk, vc);
+ }
+
+ vc = VBE_NewConn();
+ assert(vc->fd == -1);
+ AZ(vc->backend);
+ vc->fd = ber_conn_try(sp, bp, bs);
+ if (vc->fd < 0) {
+ VBE_ReleaseConn(vc);
+ VSL_stats->backend_fail++;
+ return (NULL);
+ }
+ vc->backend = bp;
+ vc->priv = bs;
+ VSL_stats->backend_conn++;
+ return (vc);
+
+}
+
+static struct vbe_conn *
+ber_GetFd(const struct sess *sp)
+{
+ struct vbe_conn *vc;
+ unsigned n;
+ for (n = 1; n < 5; n++) {
+ vc = ber_nextfd(sp);
+ if (vc == NULL) {
+ AZ(usleep(100000 * n));
+ continue;
+ }
+ assert(vc->fd >= 0);
+ assert(vc->backend == sp->backend);
+ WSL(sp->wrk, SLT_BackendXID, vc->fd, "%u", sp->xid);
+ WSP(sp, SLT_Backend, "%d %s", vc->fd, sp->backend->vcl_name);
+ return (vc);
+ }
+ return (NULL);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+ber_ClosedFd(struct worker *w, struct vbe_conn *vc)
+{
+ CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC);
+ CHECK_OBJ_NOTNULL(vc->backend, BACKEND_MAGIC);
+ assert(vc->fd >= 0);
+ WSL(w, SLT_BackendClose, vc->fd, "%s", vc->backend->vcl_name);
+ AZ(close(vc->fd));
+ vc->fd = -1;
+ VBE_DropRef(vc->backend);
+ vc->backend = NULL;
+ VBE_ReleaseConn(vc);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+ber_RecycleFd(struct worker *w, struct vbe_conn *vc)
+{
+ struct brspec *bs;
+
+ CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC);
+ CHECK_OBJ_NOTNULL(vc->backend, BACKEND_MAGIC);
+ CAST_OBJ_NOTNULL(bs, vc->priv, BRSPEC_MAGIC);
+
+ assert(vc->fd >= 0);
+ WSL(w, SLT_BackendReuse, vc->fd, "%s", vc->backend->vcl_name);
+ LOCK(&vc->backend->mtx);
+ VSL_stats->backend_recycle++;
+ VTAILQ_INSERT_HEAD(&bs->connlist, vc, list);
+ VBE_DropRefLocked(vc->backend);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+ber_Cleanup(const struct backend *b)
+{
+ struct ber *ber;
+ struct vbe_conn *vbe;
+ struct brspec *bs, *bstmp;
+
+ assert(b->refcount == 0);
+ CAST_OBJ_NOTNULL(ber, b->priv, BER_MAGIC);
+
+ bs = ber->blist;
+
+ do {
+ free(bs->portname);
+ free(bs->hostname);
+ freeaddrinfo(bs->addr);
+ while (1) {
+ vbe = VTAILQ_FIRST(&bs->connlist);
+ if (vbe == NULL)
+ break;
+ VTAILQ_REMOVE(&bs->connlist, vbe, list);
+ if (vbe->fd >= 0)
+ AZ(close(vbe->fd));
+ free(vbe);
+ }
+ bstmp = bs;
+ bs = bs->next;
+ free(bstmp);
+ } while (bs != ber->blist);
+
+ free(ber);
+}
+
+/*--------------------------------------------------------------------*/
+
+/* Will return the hostname of the first backend in the list */
+static const char *
+ber_GetHostname(const struct backend *b)
+{
+ struct ber *ber;
+
+ CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC);
+ CAST_OBJ_NOTNULL(ber, b->priv, BER_MAGIC);
+ return (ber->blist->hostname);
+}
+
+/*--------------------------------------------------------------------*/
+
+/* This should maybe be divided into two separate functions. One for
+ * increasing/decreasing health, and one for "pulling" the health
+ * towards neutral (0) as time passes
+ */
+static void
+ber_UpdateHealth(const struct sess *sp, const struct vbe_conn *vc, int add)
+{
+ struct brspec *bs, *first;
+ struct ber *ber;
+
+ if (vc != NULL) {
+ CAST_OBJ_NOTNULL(bs, vc->priv, BRSPEC_MAGIC);
+
+ if (bs->health + add >= -10000 || bs->health + add <= 10000)
+ bs->health += add;
+ } else {
+ CAST_OBJ_NOTNULL(ber, sp->backend->priv, BRSPEC_MAGIC);
+ first = ber->blist;
+ bs = first;
+ do {
+ bs = bs->next;
+ bs->health = (int)((double)bs->health / 2);
+ } while (bs != first);
+ }
+}
+
+/*--------------------------------------------------------------------*/
+
+struct backend_method backend_method_random = {
+ .name = "random",
+ .getfd = ber_GetFd,
+ .close = ber_ClosedFd,
+ .recycle = ber_RecycleFd,
+ .gethostname = ber_GetHostname,
+ .updatehealth = ber_UpdateHealth,
+ .cleanup = ber_Cleanup,
+};
+
+/*--------------------------------------------------------------------*/
+
+void
+VRT_init_random_backend(struct backend **bp, const struct vrt_random_backend *t)
+{
+ struct backend *b;
+ struct ber *ber;
+ struct vrt_backend_entry *be;
+ struct brspec *bs = NULL;
+ struct brspec *bs_prev = NULL;
+ struct brspec *bs_first = NULL;
+ double limit = 0;
+ double default_weight;
+
+ /*
+ * Scan existing backends to see if we can recycle one of them.
+ */
+
+ /*
+ * XXX: Do this by comparing a hash generated from this new
+ * XXX: backend with the earlier computed hashes from existing
+ * XXX: backends ? Should the hash be a parameter to this function,
+ * XXX: or computed here?
+ */
+
+ b = VBE_NewBackend(&backend_method_random);
+
+ ber = calloc(sizeof *ber, 1);
+ XXXAN(ber);
+ ber->magic = BER_MAGIC;
+ ber->count = t->count;
+
+ b->priv = ber;
+
+ AN(t->name);
+ b->vcl_name = strdup(t->name);
+ XXXAN(b->vcl_name);
+
+ default_weight = 1.0 / (double)t->count;
+
+ be = t->bentry;
+ while (be != NULL) {
+ bs = calloc(sizeof *bs, 1);
+ XXXAN(bs);
+ bs->magic = BRSPEC_MAGIC;
+ AN(be->port);
+ bs->portname = strdup(be->port);
+ XXXAN(bs->portname);
+
+ AN(be->host);
+ bs->hostname = strdup(be->host);
+ XXXAN(bs->hostname);
+
+ if (!(t->weighted))
+ be->weight = default_weight;
+
+ limit += be->weight;
+ bs->limit = limit;
+
+ bs->dnsttl = 300;
+ bs->health = 0;
+
+ if (bs_first == NULL)
+ bs_first = bs;
+
+ bs->next = bs_prev;
+ bs_prev = bs;
+ be = be->next;
+ }
+ XXXAN(bs_first);
+ bs_first->next = bs;
+ ber->blist = bs;
+
+ *bp = b;
+}
+
|
[-]
[+]
|
Added |
varnish-20080428.tar.bz2/bin/varnishd/cache_backend_round_robin.c
^
|
@@ -0,0 +1,489 @@
+/*-
+ * Copyright (c) 2006 Verdens Gang AS
+ * Copyright (c) 2006-2008 Linpro AS
+ * All rights reserved.
+ *
+ * Author: Cecilie Fritzvold <cecilihf@linpro.no>
+ *
+ * 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.
+ *
+ * $Id: cache_backend_round_robin.c 2496 2008-02-17 09:26:32Z des $
+ *
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <netdb.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "shmlog.h"
+#include "cache.h"
+#include "vrt.h"
+
+
+struct brr {
+ unsigned magic;
+#define BRR_MAGIC 0x66f05894
+ struct bspec *blist;
+ int count;
+#if 0
+ /* Store a hash of the backend info given in
+ * vcl for comparison when a new vcl file is
+ * uploaded. Not in use yet.
+ */
+ unsigned hash;
+#endif
+};
+
+struct bspec {
+ unsigned magic;
+#define BSPEC_MAGIC 0x761d69c2
+ struct bspec *next;
+ char *hostname;
+ char *portname;
+ struct addrinfo *addr;
+ struct addrinfo *last_addr;
+ double dnsttl;
+ double dnstime;
+ unsigned dnsseq;
+ VTAILQ_HEAD(, vbe_conn) connlist;
+ int health;
+};
+
+/*--------------------------------------------------------------------
+ * Try to get a socket connected to one of the addresses on the list.
+ * We start from the cached "last good" address and try all items on
+ * the list exactly once.
+ * If a new DNS lookup is made while we try, we start over and try the
+ * new list exactly once.
+ */
+
+static int
+brr_conn_try_list(const struct sess *sp, struct bspec *bs)
+{
+ struct addrinfo *ai, *from;
+ int s, loops;
+ unsigned myseq;
+
+ CHECK_OBJ_NOTNULL(bs, BSPEC_MAGIC);
+ if (bs->addr == NULL)
+ return (-1);
+ AN(bs->last_addr);
+
+ /* Called with lock held */
+ myseq = bs->dnsseq;
+ loops = 0;
+ ai = from = bs->last_addr;
+ while (1) {
+
+ /* NB: releases/acquires lock */
+ s = VBE_TryConnect(sp, ai);
+
+ if (s >= 0) {
+ /* Update cached "last good" if still valid */
+ if (myseq == bs->dnsseq)
+ bs->last_addr = ai;
+ return (s);
+ }
+
+ if (myseq != bs->dnsseq) {
+ /* A DNS-lookup happended, try again from start */
+ loops = 0;
+ from = bs->last_addr;
+ ai = from;
+ } else {
+ /* Try next one */
+ ai = ai->ai_next;
+ if (ai == NULL) {
+ loops++;
+ ai = bs->addr;
+ }
+ }
+ if (loops == 1 && ai == from)
+ return (-1);
+ }
+}
+
+/*--------------------------------------------------------------------*/
+
+static const char *
+brr_dns_lookup(struct backend *bp, struct bspec *bs)
+{
+ struct addrinfo *res, hint, *old;
+ int error;
+
+ CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC);
+ CHECK_OBJ_NOTNULL(bs, BSPEC_MAGIC);
+
+ bs->dnstime = TIM_mono();
+
+ /* Let go of lock while we do sleepable stuff */
+ UNLOCK(&bp->mtx);
+
+ memset(&hint, 0, sizeof hint);
+ hint.ai_family = PF_UNSPEC;
+ hint.ai_socktype = SOCK_STREAM;
+ res = NULL;
+ error = getaddrinfo(bs->hostname,
+ bs->portname == NULL ? "http" : bs->portname,
+ &hint, &res);
+ LOCK(&bp->mtx);
+ if (error) {
+ if (res != NULL)
+ freeaddrinfo(res);
+ return(gai_strerror(error));
+ }
+ bs->dnsseq++;
+ old = bs->addr;
+ bs->last_addr = res;
+ bs->addr = res;
+ if (old != NULL)
+ freeaddrinfo(old);
+ return (NULL);
+}
+
+/*--------------------------------------------------------------------*/
+
+static int
+brr_conn_try(const struct sess *sp, struct backend *bp, struct bspec *bs)
+{
+ int s;
+
+ LOCK(&bp->mtx);
+
+ s = brr_conn_try_list(sp, bs);
+ if (s >= 0) {
+ bp->refcount++;
+ UNLOCK(&bp->mtx);
+ return (s);
+ }
+
+ if (bs->dnstime + bs->dnsttl >= TIM_mono()) {
+ UNLOCK(&bp->mtx);
+ return (-1);
+ }
+
+ (void)brr_dns_lookup(bp, bs);
+
+ /* And try the entire list */
+ s = brr_conn_try_list(sp, bs);
+ if (s >= 0) {
+ bp->refcount++;
+ UNLOCK(&bp->mtx);
+ return (s);
+ }
+
+ UNLOCK(&bp->mtx);
+ return (-1);
+}
+
+
+/* Get a backend connection ------------------------------------------
+ *
+ * Get the next backend in the round-robin list, and connect to this.
+ *
+ * Try all cached backend connections for this backend, and use the
+ * first one that is looks like it is still connected.
+ * If that fails to get us a connection, create a new one, reusing a
+ * connection from the freelist, if possible.
+ *
+ * This function is slightly complicated by optimizations on brrmtx.
+ */
+
+static struct vbe_conn *
+brr_nextfd(const struct sess *sp)
+{
+ struct vbe_conn *vc;
+ struct backend *bp;
+ int reuse = 0;
+ struct brr *brr;
+ struct bspec *bs;
+ int min_health = -10;
+ int num = 0;
+
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
+ bp = sp->backend;
+ CAST_OBJ_NOTNULL(brr, bp->priv, BRR_MAGIC);
+
+ do {
+ bs = brr->blist = brr->blist->next;
+ num++;
+ if (num > brr->count) {
+ min_health *= 10;
+ num = 0;
+ }
+ } while (bs->health < min_health);
+
+ while (1) {
+ LOCK(&bp->mtx);
+ vc = VTAILQ_FIRST(&bs->connlist);
+ if (vc != NULL) {
+ bp->refcount++;
+ assert(vc->backend == bp);
+ assert(vc->fd >= 0);
+ VTAILQ_REMOVE(&bs->connlist, vc, list);
+ }
+ UNLOCK(&bp->mtx);
+ if (vc == NULL)
+ break;
+
+ if (VBE_CheckFd(vc->fd)) {
+ /* XXX locking of stats */
+ VSL_stats->backend_reuse += reuse;
+ VSL_stats->backend_conn++;
+ return (vc);
+ }
+ VBE_ClosedFd(sp->wrk, vc);
+ }
+
+ vc = VBE_NewConn();
+ assert(vc->fd == -1);
+ AZ(vc->backend);
+ vc->fd = brr_conn_try(sp, bp, bs);
+ if (vc->fd < 0) {
+ VBE_ReleaseConn(vc);
+ VSL_stats->backend_fail++;
+ return (NULL);
+ }
+ vc->backend = bp;
+ vc->priv = bs;
+ VSL_stats->backend_conn++;
+ return (vc);
+}
+
+static struct vbe_conn *
+brr_GetFd(const struct sess *sp)
+{
+ struct vbe_conn *vc;
+ unsigned n;
+ for (n = 1; n < 5; n++) {
+ vc = brr_nextfd(sp);
+ if (vc == NULL) {
+ AZ(usleep(100000 * n));
+ continue;
+ }
+ assert(vc->fd >= 0);
+ assert(vc->backend == sp->backend);
+ WSL(sp->wrk, SLT_BackendXID, vc->fd, "%u", sp->xid);
+ WSP(sp, SLT_Backend, "%d %s", vc->fd, sp->backend->vcl_name);
+ return (vc);
+ }
+ return (NULL);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+brr_ClosedFd(struct worker *w, struct vbe_conn *vc)
+{
+ CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC);
+ CHECK_OBJ_NOTNULL(vc->backend, BACKEND_MAGIC);
+ assert(vc->fd >= 0);
+ WSL(w, SLT_BackendClose, vc->fd, "%s", vc->backend->vcl_name);
+ AZ(close(vc->fd));
+ vc->fd = -1;
+ VBE_DropRef(vc->backend);
+ vc->backend = NULL;
+ VBE_ReleaseConn(vc);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+brr_RecycleFd(struct worker *w, struct vbe_conn *vc)
+{
+ struct bspec *bs;
+
+ CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC);
+ CHECK_OBJ_NOTNULL(vc->backend, BACKEND_MAGIC);
+ CAST_OBJ_NOTNULL(bs, vc->priv, BSPEC_MAGIC);
+
+ assert(vc->fd >= 0);
+ WSL(w, SLT_BackendReuse, vc->fd, "%s", vc->backend->vcl_name);
+ LOCK(&vc->backend->mtx);
+ VSL_stats->backend_recycle++;
+ VTAILQ_INSERT_HEAD(&bs->connlist, vc, list);
+ VBE_DropRefLocked(vc->backend);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+brr_Cleanup(const struct backend *b)
+{
+ struct brr *brr;
+ struct vbe_conn *vbe;
+ struct bspec *bs, *bstmp;
+
+ assert(b->refcount == 0);
+ CAST_OBJ_NOTNULL(brr, b->priv, BRR_MAGIC);
+
+ bs = brr->blist;
+
+ do {
+ free(bs->portname);
+ free(bs->hostname);
+ freeaddrinfo(bs->addr);
+ while (1) {
+ vbe = VTAILQ_FIRST(&bs->connlist);
+ if (vbe == NULL)
+ break;
+ VTAILQ_REMOVE(&bs->connlist, vbe, list);
+ if (vbe->fd >= 0)
+ AZ(close(vbe->fd));
+ free(vbe);
+ }
+ bstmp = bs;
+ bs = bs->next;
+ free(bstmp);
+ } while (bs != brr->blist);
+
+ free(brr);
+}
+
+/*--------------------------------------------------------------------*/
+
+/* Will return the hostname of the first backend in the list */
+static const char *
+brr_GetHostname(const struct backend *b)
+{
+ struct brr *brr;
+
+ CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC);
+ CAST_OBJ_NOTNULL(brr, b->priv, BRR_MAGIC);
+ return (brr->blist->hostname);
+}
+
+/*--------------------------------------------------------------------*/
+
+/* This should maybe be divided into two separate functions. One for
+ * increasing/decreasing health, and one for "pulling" the health
+ * towards neutral (0) as time passes
+ */
+static void
+brr_UpdateHealth(const struct sess *sp, const struct vbe_conn *vc, int add)
+{
+ struct bspec *bs, *first;
+ struct brr *brr;
+
+ if (vc != NULL) {
+
+ CAST_OBJ_NOTNULL(bs, vc->priv, BSPEC_MAGIC);
+
+ if (bs->health + add >= -10000 || bs->health + add <= 10000)
+ bs->health += add;
+ } else {
+ CAST_OBJ_NOTNULL(brr, sp->backend->priv, BSPEC_MAGIC);
+ first = brr->blist;
+ bs = first;
+ do {
+ bs = bs->next;
+ bs->health = (int)((double)bs->health / 2);
+ } while (bs != first);
+ }
+}
+
+/*--------------------------------------------------------------------*/
+
+struct backend_method backend_method_round_robin = {
+ .name = "round_robin",
+ .getfd = brr_GetFd,
+ .close = brr_ClosedFd,
+ .recycle = brr_RecycleFd,
+ .gethostname = brr_GetHostname,
+ .updatehealth = brr_UpdateHealth,
+ .cleanup = brr_Cleanup,
+};
+
+/*--------------------------------------------------------------------*/
+
+void
+VRT_init_round_robin_backend(struct backend **bp, const struct vrt_round_robin_backend *t)
+{
+ struct backend *b;
+ struct brr *brr;
+ struct vrt_backend_entry *be;
+ struct bspec *bs = NULL;
+ struct bspec *bs_prev = NULL;
+ struct bspec *bs_first = NULL;
+
+ /*
+ * Scan existing backends to see if we can recycle one of them.
+ */
+ /*
+ * XXX: Do this by comparing a hash generated from this new
+ * XXX: backend with the earlier computed hashes from existing
+ * XXX: backends ? Should the hash be a parameter to this function,
+ * XXX: or computed here?
+ */
+
+
+ b = VBE_NewBackend(&backend_method_round_robin);
+
+ brr = calloc(sizeof *brr, 1);
+ XXXAN(brr);
+ brr->magic = BRR_MAGIC;
+ brr->count = t->count;
+
+ b->priv = brr;
+
+ AN(t->name);
+ b->vcl_name = strdup(t->name);
+ XXXAN(b->vcl_name);
+
+ be = t->bentry;
+ while (be != NULL) {
+ bs = calloc(sizeof *bs, 1);
+ XXXAN(bs);
+ bs->magic = BSPEC_MAGIC;
+ AN(be->port);
+ bs->portname = strdup(be->port);
+ XXXAN(bs->portname);
+
+ AN(be->host);
+ bs->hostname = strdup(be->host);
+ XXXAN(bs->hostname);
+
+ bs->dnsttl = 300;
+ bs->health = 0;
+
+ if (bs_first == NULL)
+ bs_first = bs;
+
+ bs->next = bs_prev;
+ bs_prev = bs;
+ be = be->next;
+ }
+
+ XXXAN(bs_first);
+ bs_first->next = bs;
+ brr->blist = bs;
+
+ *bp = b;
+}
+
|
[-]
[+]
|
Added |
varnish-20080428.tar.bz2/bin/varnishd/cache_backend_simple.c
^
|
@@ -0,0 +1,414 @@
+/*-
+ * Copyright (c) 2006 Verdens Gang AS
+ * Copyright (c) 2006-2008 Linpro 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.
+ *
+ * $Id$
+ *
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <netdb.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "shmlog.h"
+#include "cache.h"
+#include "vrt.h"
+
+struct bes {
+ unsigned magic;
+#define BES_MAGIC 0x015e17ac
+ char *hostname;
+ char *portname;
+ char *ident;
+ struct addrinfo *addr;
+ struct addrinfo *last_addr;
+ double dnsttl;
+ double dnstime;
+ unsigned dnsseq;
+ VTAILQ_HEAD(, vbe_conn) connlist;
+};
+
+/*--------------------------------------------------------------------
+ * Try to get a socket connected to one of the addresses on the list.
+ * We start from the cached "last good" address and try all items on
+ * the list exactly once.
+ * If a new DNS lookup is made while we try, we start over and try the
+ * new list exactly once.
+ */
+
+static int
+bes_conn_try_list(const struct sess *sp, struct bes *bes)
+{
+ struct addrinfo *ai, *from;
+ int s, loops;
+ unsigned myseq;
+
+ CHECK_OBJ_NOTNULL(bes, BES_MAGIC);
+ if (bes->addr == NULL)
+ return (-1);
+ AN(bes->last_addr);
+
+ /* Called with lock held */
+ myseq = bes->dnsseq;
+ loops = 0;
+ ai = from = bes->last_addr;
+ while (1) {
+
+ /* NB: releases/acquires lock */
+ s = VBE_TryConnect(sp, ai);
+
+ if (s >= 0) {
+ /* Update cached "last good" if still valid */
+ if (myseq == bes->dnsseq)
+ bes->last_addr = ai;
+ return (s);
+ }
+
+ if (myseq != bes->dnsseq) {
+ /* A DNS-lookup happended, try again from start */
+ loops = 0;
+ from = bes->last_addr;
+ ai = from;
+ } else {
+ /* Try next one */
+ ai = ai->ai_next;
+ if (ai == NULL) {
+ loops++;
+ ai = bes->addr;
+ }
+ }
+ if (loops == 1 && ai == from)
+ return (-1);
+ }
+}
+
+/*--------------------------------------------------------------------*/
+
+static const char *
+bes_dns_lookup(struct backend *bp)
+{
+ struct addrinfo *res, hint, *old;
+ struct bes *bes;
+ int error;
+
+ CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC);
+ CAST_OBJ_NOTNULL(bes, bp->priv, BES_MAGIC);
+
+ bes->dnstime = TIM_mono();
+
+ /* Let go of lock while we do sleepable stuff */
+ UNLOCK(&bp->mtx);
+
+ memset(&hint, 0, sizeof hint);
+ hint.ai_family = PF_UNSPEC;
+ hint.ai_socktype = SOCK_STREAM;
+ res = NULL;
+ error = getaddrinfo(bes->hostname,
+ bes->portname == NULL ? "http" : bes->portname,
+ &hint, &res);
+ LOCK(&bp->mtx);
+ if (error) {
+ if (res != NULL)
+ freeaddrinfo(res);
+ return(gai_strerror(error));
+ }
+ bes->dnsseq++;
+ old = bes->addr;
+ bes->last_addr = res;
+ bes->addr = res;
+ if (old != NULL)
+ freeaddrinfo(old);
+ return (NULL);
+}
+
+/*--------------------------------------------------------------------*/
+
+static int
+bes_conn_try(const struct sess *sp, struct backend *bp)
+{
+ int s;
+ struct bes *bes;
+
+ CAST_OBJ_NOTNULL(bes, bp->priv, BES_MAGIC);
+
+ LOCK(&bp->mtx);
+
+ s = bes_conn_try_list(sp, bes);
+ if (s >= 0) {
+ bp->refcount++;
+ UNLOCK(&bp->mtx);
+ return (s);
+ }
+
+ if (bes->dnstime + bes->dnsttl >= TIM_mono()) {
+ UNLOCK(&bp->mtx);
+ return (-1);
+ }
+
+ (void)bes_dns_lookup(bp);
+
+ /* And try the entire list */
+ s = bes_conn_try_list(sp, bes);
+ if (s >= 0) {
+ bp->refcount++;
+ UNLOCK(&bp->mtx);
+ return (s);
+ }
+
+ UNLOCK(&bp->mtx);
+ return (-1);
+}
+
+/* Get a backend connection ------------------------------------------
+ *
+ * Try all cached backend connections for this backend, and use the
+ * first one that is looks like it is still connected.
+ * If that fails to get us a connection, create a new one, reusing a
+ * connection from the freelist, if possible.
+ *
+ * This function is slightly complicated by optimizations on besmtx.
+ */
+
+static struct vbe_conn *
+bes_nextfd(const struct sess *sp)
+{
+ struct vbe_conn *vc;
+ struct backend *bp;
+ int reuse = 0;
+ struct bes *bes;
+
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
+ bp = sp->backend;
+ CAST_OBJ_NOTNULL(bes, bp->priv, BES_MAGIC);
+ while (1) {
+ LOCK(&bp->mtx);
+ vc = VTAILQ_FIRST(&bes->connlist);
+ if (vc != NULL) {
+ bp->refcount++;
+ assert(vc->backend == bp);
+ assert(vc->fd >= 0);
+ VTAILQ_REMOVE(&bes->connlist, vc, list);
+ }
+ UNLOCK(&bp->mtx);
+ if (vc == NULL)
+ break;
+
+ if (VBE_CheckFd(vc->fd)) {
+ /* XXX locking of stats */
+ VSL_stats->backend_reuse += reuse;
+ VSL_stats->backend_conn++;
+ return (vc);
+ }
+ VBE_ClosedFd(sp->wrk, vc);
+ }
+
+ vc = VBE_NewConn();
+ assert(vc->fd == -1);
+ AZ(vc->backend);
+ vc->fd = bes_conn_try(sp, bp);
+ if (vc->fd < 0) {
+ VBE_ReleaseConn(vc);
+ VSL_stats->backend_fail++;
+ return (NULL);
+ }
+ vc->backend = bp;
+ VSL_stats->backend_conn++;
+ return (vc);
+}
+
+/*--------------------------------------------------------------------*/
+
+static struct vbe_conn *
+bes_GetFd(const struct sess *sp)
+{
+ struct vbe_conn *vc;
+ unsigned n;
+ for (n = 1; n < 5; n++) {
+ vc = bes_nextfd(sp);
+ if (vc == NULL) {
+ AZ(usleep(100000 * n));
+ continue;
+ }
+ assert(vc->fd >= 0);
+ assert(vc->backend == sp->backend);
+ WSL(sp->wrk, SLT_BackendXID, vc->fd, "%u", sp->xid);
+ WSP(sp, SLT_Backend, "%d %s", vc->fd, sp->backend->vcl_name);
+ return (vc);
+ }
+ return (NULL);
+}
+
+/* Close a connection ------------------------------------------------*/
+
+static void
+bes_ClosedFd(struct worker *w, struct vbe_conn *vc)
+{
+
+ CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC);
+ CHECK_OBJ_NOTNULL(vc->backend, BACKEND_MAGIC);
+ assert(vc->fd >= 0);
+ WSL(w, SLT_BackendClose, vc->fd, "%s", vc->backend->vcl_name);
+ AZ(close(vc->fd));
+ vc->fd = -1;
+ VBE_DropRef(vc->backend);
+ vc->backend = NULL;
+ VBE_ReleaseConn(vc);
+}
+
+/* Recycle a connection ----------------------------------------------*/
+
+static void
+bes_RecycleFd(struct worker *w, struct vbe_conn *vc)
+{
+ struct bes *bes;
+
+ CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC);
+ CHECK_OBJ_NOTNULL(vc->backend, BACKEND_MAGIC);
+ CAST_OBJ_NOTNULL(bes, vc->backend->priv, BES_MAGIC);
+
+ assert(vc->fd >= 0);
+ WSL(w, SLT_BackendReuse, vc->fd, "%s", vc->backend->vcl_name);
+ LOCK(&vc->backend->mtx);
+ VSL_stats->backend_recycle++;
+ VTAILQ_INSERT_HEAD(&bes->connlist, vc, list);
+ VBE_DropRefLocked(vc->backend);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+bes_Cleanup(const struct backend *b)
+{
+ struct bes *bes;
+ struct vbe_conn *vbe;
+
+ assert(b->refcount == 0);
+ CAST_OBJ_NOTNULL(bes, b->priv, BES_MAGIC);
+ free(bes->portname);
+ free(bes->hostname);
+ freeaddrinfo(bes->addr);
+ while (1) {
+ vbe = VTAILQ_FIRST(&bes->connlist);
+ if (vbe == NULL)
+ break;
+ VTAILQ_REMOVE(&bes->connlist, vbe, list);
+ if (vbe->fd >= 0)
+ AZ(close(vbe->fd));
+ FREE_OBJ(vbe);
+ }
+ FREE_OBJ(bes);
+}
+
+/*--------------------------------------------------------------------*/
+
+static const char *
+bes_GetHostname(const struct backend *b)
+{
+ struct bes *bes;
+
+ CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC);
+ CAST_OBJ_NOTNULL(bes, b->priv, BES_MAGIC);
+ return (bes->hostname);
+}
+
+/*--------------------------------------------------------------------*/
+
+struct backend_method backend_method_simple = {
+ .name = "simple",
+ .getfd = bes_GetFd,
+ .close = bes_ClosedFd,
+ .recycle = bes_RecycleFd,
+ .gethostname = bes_GetHostname,
+ .cleanup = bes_Cleanup,
+};
+
+/*--------------------------------------------------------------------*/
+
+void
+VRT_init_simple_backend(struct backend **bp, const struct vrt_simple_backend *t)
+{
+ struct backend *b;
+ struct bes *bes;
+ const char *p;
+
+ /*
+ * Scan existing backends to see if we can recycle one of them.
+ */
+ VTAILQ_FOREACH(b, &backendlist, list) {
+ CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC);
+ if (b->method != &backend_method_simple)
+ continue;
+ CAST_OBJ_NOTNULL(bes, b->priv, BES_MAGIC);
+ if (strcmp(bes->ident, t->ident))
+ continue;
+ b->refcount++;
+ *bp = b;
+ return;
+ }
+
+ b = VBE_NewBackend(&backend_method_simple);
+
+ bes = calloc(sizeof *bes, 1);
+ XXXAN(bes);
+ bes->magic = BES_MAGIC;
+
+ b->priv = bes;
+
+ bes->dnsttl = 300;
+
+ AN(t->ident);
+ REPLACE(bes->ident, t->ident);
+
+ AN(t->name);
+ REPLACE(b->vcl_name, t->name);
+
+ AN(t->port);
+ REPLACE(bes->portname, t->port);
+
+ AN(t->host);
+ REPLACE(bes->hostname, t->host);
+
+ /*
+ * The VCL compiler already did a lookup, but we'll do another one
+ * here, just in case...
+ */
+ LOCK(&b->mtx);
+ p = bes_dns_lookup(b);
+ UNLOCK(&b->mtx);
+ if (p != NULL)
+ printf("Warning: could not lookup backend %s (%s:%s): %s",
+ t->name, t->host, t->port, p);
+
+ *bp = b;
+}
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_ban.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_ban.c 2598 2008-03-12 14:07:08Z phk $
+ * $Id: cache_ban.c 2564 2008-03-08 13:38:23Z des $
*
* Ban processing
*/
@@ -40,7 +40,6 @@
#include <regex.h>
#include "shmlog.h"
-#include "cli.h"
#include "cli_priv.h"
#include "cache.h"
@@ -104,8 +103,8 @@
return (0);
}
-static void
-ccf_url_purge(struct cli *cli, const char * const *av, void *priv)
+void
+cli_func_url_purge(struct cli *cli, const char * const *av, void *priv)
{
(void)priv;
@@ -113,8 +112,8 @@
cli_out(cli, "PURGE %s\n", av[2]);
}
-static void
-ccf_hash_purge(struct cli *cli, const char * const *av, void *priv)
+void
+cli_func_hash_purge(struct cli *cli, const char * const *av, void *priv)
{
(void)priv;
@@ -122,16 +121,9 @@
cli_out(cli, "PURGE %s\n", av[2]);
}
-static struct cli_proto ban_cmds[] = {
- { CLI_URL_PURGE, ccf_url_purge },
- { CLI_HASH_PURGE, ccf_hash_purge },
- { NULL }
-};
-
void
BAN_Init(void)
{
- CLI_AddFuncs(PUBLIC_CLI, ban_cmds);
AddBan("\001", 0);
}
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_center.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_center.c 2631 2008-04-17 20:08:49Z phk $
+ * $Id: cache_center.c 2564 2008-03-08 13:38:23Z des $
*
* This file contains the central state machine for pushing requests.
*
@@ -71,6 +71,7 @@
#include "shmlog.h"
#include "vcl.h"
+#include "heritage.h"
#include "cache.h"
static unsigned xids;
@@ -151,10 +152,8 @@
CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
sp->t_resp = TIM_real();
- if (sp->obj->objhead != NULL) {
- sp->obj->last_use = sp->t_resp; /* XXX: locking ? */
+ if (sp->obj->objhead != NULL)
EXP_Touch(sp->obj, sp->t_resp);
- }
RES_BuildHttp(sp);
VCL_deliver_method(sp);
switch (sp->handling) {
@@ -169,13 +168,6 @@
INCOMPL();
}
- sp->director = NULL;
- sp->restarts = 0;
- sp->backend = NULL; /*
- * XXX: we may want to leave this
- * behind to hint directors ?
- */
-
RES_WriteObj(sp);
HSH_Deref(sp->obj);
sp->obj = NULL;
@@ -205,14 +197,8 @@
AZ(sp->obj);
AZ(sp->bereq);
- sp->director = NULL;
- sp->restarts = 0;
- sp->backend = NULL; /*
- * XXX: we may want to leave this
- * behind to hint directors ?
- */
-
- if (sp->vcl != NULL && sp->esis == 0) {
+ sp->backend = NULL;
+ if (sp->vcl != NULL) {
if (sp->wrk->vcl != NULL)
VCL_Rel(&sp->wrk->vcl);
sp->wrk->vcl = sp->vcl;
@@ -236,12 +222,7 @@
sp->t_open = sp->t_end;
sp->t_req = NAN;
sp->t_resp = NAN;
- WSL_Flush(sp->wrk, 0);
-
- /* If we did an ESI include, don't mess up our state */
- if (sp->esis > 0)
- return (1);
-
+ WSL_Flush(sp->wrk);
if (sp->fd >= 0 && sp->doclose != NULL)
vca_close_session(sp, sp->doclose);
if (sp->fd < 0) {
@@ -291,8 +272,7 @@
cnt_error(struct sess *sp)
{
- AZ(sp->obj);
- SYN_ErrorPage(sp, sp->err_code, sp->err_reason);
+ RES_Error(sp, sp->err_code, sp->err_reason);
sp->err_code = 0;
sp->err_reason = NULL;
sp->step = STP_DONE;
@@ -336,9 +316,9 @@
CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
AN(sp->bereq);
- CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC);
+ CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
i = Fetch(sp);
- CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC);
+ CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
if (!i)
RFC2616_cache_policy(sp, sp->obj->http); /* XXX -> VCL */
@@ -360,13 +340,12 @@
case VCL_RET_RESTART:
sp->obj->ttl = 0;
sp->obj->cacheable = 0;
- HSH_Unbusy(sp);
+ HSH_Unbusy(sp->obj);
HSH_Deref(sp->obj);
sp->obj = NULL;
if (sp->handling == VCL_RET_ERROR)
sp->step = STP_ERROR;
else {
- sp->director = NULL;
sp->restarts++;
sp->step = STP_RECV;
}
@@ -383,8 +362,8 @@
sp->obj->cacheable = 1;
if (sp->obj->objhead != NULL) {
VRY_Create(sp);
- EXP_Insert(sp->obj, sp->wrk->used);
- HSH_Unbusy(sp);
+ HSH_Ref(sp->obj); /* get another, STP_DELIVER will deref */
+ HSH_Unbusy(sp->obj);
}
sp->wrk->acct.fetch++;
sp->step = STP_DELIVER;
@@ -468,8 +447,6 @@
VCL_hit_method(sp);
if (sp->handling == VCL_RET_DELIVER) {
- /* Dispose of any body part of the request */
- FetchReqBody(sp);
sp->step = STP_DELIVER;
return (0);
}
@@ -558,10 +535,7 @@
* We hit a busy object, disembark worker thread and expect
* hash code to restart us, still in STP_LOOKUP, later.
*/
- spassert(sp->objhead != NULL);
- if (params->diag_bitmap & 0x20)
- WSP(sp, SLT_Debug,
- "on waiting list <%s>", sp->objhead->hash);
+ WSP(sp, SLT_Debug, "on waiting list on obj %u", sp->obj->xid);
/*
* There is a non-zero risk that we come here more than once
* before we get through, in that case cnt_recv must be set
@@ -630,12 +604,11 @@
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
- VBE_SelectBackend(sp);
http_FilterHeader(sp, HTTPH_R_FETCH);
VCL_miss_method(sp);
if (sp->handling == VCL_RET_ERROR) {
sp->obj->cacheable = 0;
- HSH_Unbusy(sp);
+ HSH_Unbusy(sp->obj);
HSH_Deref(sp->obj);
sp->obj = NULL;
VBE_free_bereq(sp->bereq);
@@ -645,7 +618,7 @@
}
if (sp->handling == VCL_RET_PASS) {
sp->obj->cacheable = 0;
- HSH_Unbusy(sp);
+ HSH_Unbusy(sp->obj);
HSH_Deref(sp->obj);
sp->obj = NULL;
sp->step = STP_PASS;
@@ -694,7 +667,6 @@
CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
AZ(sp->obj);
- VBE_SelectBackend(sp);
http_FilterHeader(sp, HTTPH_R_PASS);
VCL_pass_method(sp);
@@ -706,7 +678,6 @@
sp->obj = sp->wrk->nobj;
sp->wrk->nobj = NULL;
sp->obj->busy = 1;
- sp->sendbody = 1;
sp->step = STP_FETCH;
return (0);
}
@@ -744,7 +715,6 @@
CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
sp->wrk->acct.pipe++;
- VBE_SelectBackend(sp);
http_FilterHeader(sp, HTTPH_R_PIPE);
VCL_pipe_method(sp);
@@ -783,27 +753,15 @@
CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
AZ(sp->obj);
- /* By default we use the first backend */
- AZ(sp->director);
- sp->director = sp->vcl->director[0];
- CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC);
-
VCL_recv_method(sp);
sp->wantbody = (strcmp(sp->http->hd[HTTP_HDR_REQ].b, "HEAD") != 0);
- sp->sendbody = 0;
switch(sp->handling) {
case VCL_RET_LOOKUP:
/* XXX: discard req body, if any */
sp->step = STP_LOOKUP;
return (0);
case VCL_RET_PIPE:
- if (sp->esis > 0) {
- /* XXX: VSL something */
- INCOMPL();
- sp->step = STP_DONE;
- return (1);
- }
sp->step = STP_PIPE;
return (0);
case VCL_RET_PASS:
@@ -861,13 +819,18 @@
*sp->http0 = *sp->http;
if (done != 0) {
- SYN_ErrorPage(sp, done, NULL); /* XXX: STP_ERROR ? */
+ RES_Error(sp, done, NULL); /* XXX: STP_ERROR ? */
sp->step = STP_DONE;
return (0);
}
sp->doclose = http_DoConnection(sp->http);
+ /* By default we use the first backend */
+ AZ(sp->backend);
+ sp->backend = sp->vcl->backend[0];
+ CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
+
/* XXX: Handle TRACE & OPTIONS of Max-Forwards = 0 */
sp->step = STP_RECV;
@@ -881,21 +844,6 @@
*
*/
-static void
-cnt_diag(struct sess *sp, const char *state)
-{
- if (sp->wrk != NULL) {
- WSL(sp->wrk, SLT_Debug, sp->id,
- "thr %p STP_%s sp %p obj %p vcl %p",
- pthread_self(), state, sp, sp->obj, sp->vcl);
- WSL_Flush(sp->wrk, 0);
- } else {
- VSL(SLT_Debug, sp->id,
- "thr %p STP_%s sp %p obj %p vcl %p",
- pthread_self(), state, sp, sp->obj, sp->vcl);
- }
-}
-
void
CNT_Session(struct sess *sp)
{
@@ -917,15 +865,25 @@
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
CHECK_OBJ_ORNULL(w->nobj, OBJECT_MAGIC);
CHECK_OBJ_ORNULL(w->nobjhead, OBJHEAD_MAGIC);
- CHECK_OBJ_ORNULL(sp->director, DIRECTOR_MAGIC);
+ CHECK_OBJ_ORNULL(sp->backend, BACKEND_MAGIC);
switch (sp->step) {
+#ifdef DIAGNOSTICS
+#define STEP(l,u) \
+ case STP_##u: \
+ if (sp->wrk) \
+ WSL_Flush(sp->wrk); \
+ VSL(SLT_Debug, sp->id, \
+ "thr %p STP_%s sp %p obj %p vcl %p", \
+ pthread_self(), #u, sp, sp->obj, sp->vcl); \
+ done = cnt_##l(sp); \
+ break;
+#else
#define STEP(l,u) \
case STP_##u: \
- if (params->diag_bitmap & 0x01) \
- cnt_diag(sp, #u); \
done = cnt_##l(sp); \
break;
+#endif
#include "steps.h"
#undef STEP
default: INCOMPL();
@@ -934,7 +892,7 @@
CHECK_OBJ_ORNULL(w->nobjhead, OBJHEAD_MAGIC);
}
assert(!isnan(w->used));
- WSL_Flush(w, 0);
+ WSL_Flush(w);
}
/*
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_cli.c
^
|
@@ -26,14 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_cli.c 2598 2008-03-12 14:07:08Z phk $
- *
- * Caching process CLI handling.
- *
- * We only have one CLI source, the stdin/stdout pipes from the manager
- * process, but we complicate things by having undocumented commands that
- * we do not want to show in a plain help, and by having commands that the
- * manager has already shown in help before asking us.
+ * $Id: cache_cli.c 2567 2008-03-08 14:01:28Z des $
*/
#include "config.h"
@@ -50,93 +43,48 @@
#include "cli_priv.h"
#include "cli_common.h"
#include "cache.h"
-#include "vlu.h"
#include "vsb.h"
+#include "heritage.h"
-pthread_t cli_thread;
-static MTX cli_mtx;
-
-/*
- * The CLI commandlist is split in three:
- * - Commands we get from/share with the manager, we don't show these
- * in help, as the manager already did that.
- * - Cache process commands, show in help
- * - Undocumented debug commands, show in undocumented "help -d"
- */
-
-static struct cli_proto *ccf_master_cli, *ccf_public_cli, *ccf_debug_cli;
-
-/*--------------------------------------------------------------------
- * Add CLI functions to the appropriate command set
- */
+/*--------------------------------------------------------------------*/
-void
-CLI_AddFuncs(enum cli_set_e which, struct cli_proto *p)
+static void
+cli_func_start(struct cli *cli, const char * const *av, void *priv)
{
- struct cli_proto *c, **cp;
- switch (which) {
- case MASTER_CLI: cp = &ccf_master_cli; break;
- case PUBLIC_CLI: cp = &ccf_public_cli; break;
- case DEBUG_CLI: cp = &ccf_debug_cli; break;
- default: INCOMPL();
- }
- LOCK(&cli_mtx);
- c = cli_concat(*cp, p);
- AN(c);
- free(*cp);
- *cp = c;
- UNLOCK(&cli_mtx);
+ (void)cli;
+ (void)av;
+ (void)priv;
+ VCA_Init();
+ return;
}
-/*--------------------------------------------------------------------
- * Called when we have a full line, look through all three command
- * lists to find it.
- */
-static int
-cli_vlu(void *priv, const char *p)
-{
- struct cli *cli;
- int i;
+/*--------------------------------------------------------------------*/
- cli = priv;
- VSL(SLT_CLI, 0, "Rd %s", p);
- vsb_clear(cli->sb);
- LOCK(&cli_mtx);
- cli_dispatch(cli, ccf_master_cli, p);
- if (cli->result == CLIS_UNKNOWN) {
- vsb_clear(cli->sb);
- cli->result = CLIS_OK;
- cli_dispatch(cli, ccf_public_cli, p);
- }
- if (cli->result == CLIS_UNKNOWN) {
- vsb_clear(cli->sb);
- cli->result = CLIS_OK;
- cli_dispatch(cli, ccf_debug_cli, p);
- }
- UNLOCK(&cli_mtx);
- vsb_finish(cli->sb);
- AZ(vsb_overflowed(cli->sb));
- i = cli_writeres(heritage.fds[1], cli);
- if (i)
- VSL(SLT_Error, 0, "CLI write failed (errno=%d)", errno);
- else
- VSL(SLT_CLI, 0, "Wr %d %d %s",
- i, cli->result, vsb_data(cli->sb));
- return (0);
-}
+struct cli_proto CLI_cmds[] = {
+ { CLI_PING, cli_func_ping },
+ { CLI_SERVER_START, cli_func_start },
+#if 0
+ { CLI_URL_QUERY, cli_func_url_query },
+#endif
+ { CLI_URL_PURGE, cli_func_url_purge },
+ { CLI_HASH_PURGE, cli_func_hash_purge },
+ { CLI_VCL_LOAD, cli_func_config_load },
+ { CLI_VCL_LIST, cli_func_config_list },
+ { CLI_VCL_DISCARD, cli_func_config_discard },
+ { CLI_VCL_USE, cli_func_config_use },
-/*--------------------------------------------------------------------
- * Run CLI on stdin/stdout pipe from manager
- */
+ { NULL }
+};
void
-CLI_Run(void)
+CLI_Init(void)
{
struct pollfd pfd[1];
+ char *buf, *p;
+ unsigned nbuf, lbuf;
struct cli *cli, clis;
- struct vlu *vlu;
int i;
cli = &clis;
@@ -144,106 +92,49 @@
cli->sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND);
XXXAN(cli->sb);
- vlu = VLU_New(cli, cli_vlu, params->cli_buffer);
- XXXAN(vlu);
- printf("Ready\n");
+ lbuf = 4096;
+ buf = malloc(lbuf);
+ XXXAN(buf);
+ nbuf = 0;
+ printf("CLI ready\n");
while (1) {
pfd[0].fd = heritage.fds[2];
pfd[0].events = POLLIN;
i = poll(pfd, 1, 5000);
- if (i == 0) {
- VCL_Idle();
+ if (i == 0)
continue;
+ if ((nbuf + 2) >= lbuf) {
+ lbuf += lbuf;
+ buf = realloc(buf, lbuf);
+ XXXAN(buf);
}
- if (pfd[0].revents & POLLHUP) {
- fprintf(stderr,
- "EOF on CLI connection, exiting\n");
- break;
+ i = read(heritage.fds[2], buf + nbuf, lbuf - nbuf);
+ if (i <= 0) {
+ VSL(SLT_Error, 0, "CLI read %d (errno=%d)", i, errno);
+ free(buf);
+ return;
}
- i = VLU_Fd(heritage.fds[2], vlu);
+ nbuf += i;
+ p = strchr(buf, '\n');
+ if (p == NULL)
+ continue;
+ *p = '\0';
+ VSL(SLT_CLI, 0, "Rd %s", buf);
+ vsb_clear(cli->sb);
+ cli_dispatch(cli, CLI_cmds, buf);
+ vsb_finish(cli->sb);
+ i = cli_writeres(heritage.fds[1], cli);
if (i) {
- fprintf(stderr,
- "Error on CLI connection, exiting "
- "(VLU_Fd %d ev: %x)\n",
- i, pfd[0].revents);
- break;
+ VSL(SLT_Error, 0, "CLI write failed (errno=%d)", errno);
+ free(buf);
+ return;
}
+ VSL(SLT_CLI, 0, "Wr %d %d %s",
+ i, cli->result, vsb_data(cli->sb));
+ i = ++p - buf;
+ assert(i <= nbuf);
+ if (i < nbuf)
+ memcpy(buf, p, nbuf - i);
+ nbuf -= i;
}
}
-
-/*--------------------------------------------------------------------*/
-
-static void
-cli_debug_sizeof(struct cli *cli, const char * const *av, void *priv)
-{
- (void)av;
- (void)priv;
-
-#define SZOF(foo) cli_out(cli, \
- "sizeof(%s) = %zd = 0x%zx\n", #foo, sizeof(foo), sizeof(foo));
- SZOF(struct ws);
- SZOF(struct http);
- SZOF(struct http_conn);
- SZOF(struct acct);
- SZOF(struct worker);
- SZOF(struct workreq);
- SZOF(struct bereq);
- SZOF(struct storage);
- SZOF(struct object);
- SZOF(struct objhead);
- SZOF(struct sess);
- SZOF(struct vbe_conn);
-}
-
-/*--------------------------------------------------------------------*/
-
-static void
-ccf_help(struct cli *cli, const char * const *av, void *priv)
-{
-
- (void)priv;
- cli_func_help(cli, av, ccf_public_cli);
-
- if (av[2] != NULL && !strcmp(av[2], "-d")) {
- /* Also list undocumented commands */
- cli_out(cli, "\nDebugging commands:\n");
- cli_func_help(cli, av, ccf_debug_cli);
- } else if (cli->result == CLIS_UNKNOWN) {
- /* Otherwise, try the undocumented list */
- vsb_clear(cli->sb);
- cli->result = CLIS_OK;
- cli_func_help(cli, av, ccf_debug_cli);
- }
-}
-
-/*--------------------------------------------------------------------*/
-
-static struct cli_proto master_cmds[] = {
- { CLI_PING, cli_func_ping },
- { CLI_HELP, ccf_help, NULL },
- { NULL }
-};
-
-static struct cli_proto debug_cmds[] = {
- { "debug.sizeof", "debug.sizeof",
- "\tDump sizeof various data structures\n",
- 0, 0, cli_debug_sizeof },
- { NULL }
-};
-
-
-/*--------------------------------------------------------------------
- * Initialize the CLI subsystem
- */
-
-void
-CLI_Init(void)
-{
-
- MTX_INIT(&cli_mtx);
- cli_thread = pthread_self();
-
- CLI_AddFuncs(MASTER_CLI, master_cmds);
- CLI_AddFuncs(DEBUG_CLI, debug_cmds);
-}
-
|
[-]
[+]
|
Deleted |
varnish-20080428.tar.bz2/bin/varnishd/cache_dir_random.c
^
|
@@ -1,142 +0,0 @@
-/*-
- * Copyright (c) 2006 Verdens Gang AS
- * Copyright (c) 2006-2008 Linpro 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.
- *
- * $Id$
- *
- */
-
-#include "config.h"
-
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "shmlog.h"
-#include "cache.h"
-#include "vrt.h"
-
-/*--------------------------------------------------------------------*/
-
-struct vdi_random_host {
- struct backend *backend;
- unsigned weight;
-};
-
-struct vdi_random {
- unsigned magic;
-#define VDI_RANDOM_MAGIC 0x3771ae23
- struct director dir;
- struct backend *backend;
- struct vdi_random_host *hosts;
-};
-
-
-static struct backend *
-vdi_random_choose(struct sess *sp)
-{
- struct vdi_random *vs;
- uint32_t r;
- struct vdi_random_host *vh;
-
- CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC);
- CAST_OBJ_NOTNULL(vs, sp->director->priv, VDI_RANDOM_MAGIC);
- r = random();
- r &= 0x7fffffff;
-
- for (vh = vs->hosts; ; vh++)
- if (r < vh->weight)
- return (vh->backend);
- assert(0 == __LINE__);
- return (NULL);
-}
-
-static void
-vdi_random_fini(struct director *d)
-{
- struct vdi_random *vs;
-
- CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
- CAST_OBJ_NOTNULL(vs, d->priv, VDI_RANDOM_MAGIC);
-
- VBE_DropRef(vs->backend);
- free(vs->hosts);
- free(vs);
-}
-
-void
-VRT_init_dir_random(struct cli *cli, struct director **bp, const struct vrt_dir_random *t)
-{
- struct vdi_random *vs;
- const struct vrt_dir_random_entry *te;
- struct vdi_random_host *vh;
- double s, a, b;
- unsigned v;
- int i;
-
- (void)cli;
-
- vs = calloc(sizeof *vs, 1);
- XXXAN(vs);
- vs->hosts = calloc(sizeof *vh, t->nmember);
- XXXAN(vs->hosts);
-
- vs->magic = VDI_RANDOM_MAGIC;
- vs->dir.magic = DIRECTOR_MAGIC;
- vs->dir.priv = vs;
- vs->dir.name = "random";
- vs->dir.choose = vdi_random_choose;
- vs->dir.fini = vdi_random_fini;
-
- s = 0;
- vh = vs->hosts;
- te = t->members;
- for (i = 0; i < t->nmember; i++, vh++, te++) {
- assert(te->weight > 0.0);
- s += te->weight;
- vh->backend = VBE_AddBackend(cli, te->host);
- }
-
- /* Normalize weights */
- i = 0;
- a = 0.0;
- assert(s > 0.0);
- for (te = t->members; te->host != NULL; te++, i++) {
- /* First normalize the specified weight in FP */
- b = te->weight / s; /*lint !e795 not zero division */
- /* Then accumulate to eliminate rounding errors */
- a += b;
- /* Convert to unsigned in random() range */
- v = (unsigned)((1U<<31) * a);
- vs->hosts[i].weight = v;
- }
- *bp = &vs->dir;
-}
|
[-]
[+]
|
Deleted |
varnish-20080428.tar.bz2/bin/varnishd/cache_dir_simple.c
^
|
@@ -1,98 +0,0 @@
-/*-
- * Copyright (c) 2006 Verdens Gang AS
- * Copyright (c) 2006-2008 Linpro 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.
- *
- * $Id$
- *
- */
-
-#include "config.h"
-
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "shmlog.h"
-#include "cache.h"
-#include "vrt.h"
-
-/*--------------------------------------------------------------------*/
-
-struct vdi_simple {
- unsigned magic;
-#define VDI_SIMPLE_MAGIC 0x476d25b7
- struct director dir;
- struct backend *backend;
-};
-
-static struct backend *
-vdi_simple_choose(struct sess *sp)
-{
- struct vdi_simple *vs;
-
- CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC);
- CAST_OBJ_NOTNULL(vs, sp->director->priv, VDI_SIMPLE_MAGIC);
- return (vs->backend);
-}
-
-static void
-vdi_simple_fini(struct director *d)
-{
- struct vdi_simple *vs;
-
- CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
- CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC);
-
- VBE_DropRef(vs->backend);
- free(vs);
-}
-
-void
-VRT_init_dir_simple(struct cli *cli, struct director **bp, const struct vrt_dir_simple *t)
-{
- struct vdi_simple *vs;
-
- (void)cli;
-
- vs = calloc(sizeof *vs, 1);
- XXXAN(vs);
- vs->magic = VDI_SIMPLE_MAGIC;
- vs->dir.magic = DIRECTOR_MAGIC;
- vs->dir.priv = vs;
- vs->dir.name = "simple";
- vs->dir.choose = vdi_simple_choose;
- vs->dir.fini = vdi_simple_fini;
-
- vs->backend = VBE_AddBackend(cli, t->host);
-
- *bp = &vs->dir;
-}
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_expire.c
^
|
@@ -26,242 +26,149 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_expire.c 2603 2008-03-13 10:29:14Z phk $
+ * $Id: cache_expire.c 2564 2008-03-08 13:38:23Z des $
*
- * LRU and object timer handling.
+ * Expiry of cached objects and execution of prefetcher
*
- * We have two data structures, a LRU-list and a binary heap for the timers
- * and two ways to kill objects: TTL-timeouts and LRU cleanups.
- *
- * To avoid holding the mutex while we ponder the fate of objects, we
- * have the following prototol:
- *
- * Any object on the LRU is also on the binheap (normal case)
- *
- * An object is taken off only the binheap but left on the LRU during timer
- * processing because we have no easy way to put it back the right place
- * in the LRU list.
- *
- * An object is taken off both LRU and binheap for LRU processing, (which
- * implies that it must be on both, from where it follows that the timer
- * is not chewing on it) because we expect the majority of objects to be
- * discarded by LRU and save a lock cycle that way, and because we can
- * properly replace it's position in the binheap.
+ * XXX: Objects can linger on deathrow as long as a slow client
+ * XXX: tickles data away from it. With many slow clients this could
+ * XXX: possibly make deathrow very long and make the hangman waste
+ * XXX: time. The solution is to have another queue for such "pending
+ * XXX: cases" and have HSH_Deref() move them to deathrow when they
+ * XXX: are ready.
*/
#include "config.h"
#include <unistd.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include "shmlog.h"
#include "binary_heap.h"
#include "cache.h"
-
-/*
- * Objects have sideways references in the binary heap and the LRU list
- * and we want to avoid paging in a lot of objects just to move them up
- * or down the binheap or to move a unrelated object on the LRU list.
- * To avoid this we use a proxy object, objexp, to hold the relevant
- * housekeeping fields parts of an object.
- */
-
-static const char *tmr_prefetch = "prefetch";
-static const char *tmr_ttl = "ttl";
-
-struct objexp {
- unsigned magic;
-#define OBJEXP_MAGIC 0x4d301302
- struct object *obj;
- double timer_when;
- const char *timer_what;
- unsigned timer_idx;
- VTAILQ_ENTRY(objexp) list;
- int on_lru;
- double lru_stamp;
-};
+#include "heritage.h"
static pthread_t exp_thread;
static struct binheap *exp_heap;
static MTX exp_mtx;
-static VTAILQ_HEAD(,objexp) lru = VTAILQ_HEAD_INITIALIZER(lru);
+static unsigned expearly = 30;
+static VTAILQ_HEAD(,object) exp_deathrow = VTAILQ_HEAD_INITIALIZER(exp_deathrow);
+static VTAILQ_HEAD(,object) exp_lru = VTAILQ_HEAD_INITIALIZER(exp_lru);
/*
* This is a magic marker for the objects currently on the SIOP [look it up]
* so that other users of the object will not stumble trying to change the
* ttl or lru position.
*/
-#define BINHEAP_NOIDX 0
-
-/*--------------------------------------------------------------------
- * Add and Remove objexp's from objects.
- */
+static const unsigned lru_target = (unsigned)(-3);
-static void
-add_objexp(struct object *o)
-{
-
- CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
- AZ(o->objexp);
- assert(o->busy);
- assert(o->cacheable);
- o->objexp = calloc(sizeof *o->objexp, 1);
- AN(o->objexp);
- o->objexp->magic = OBJEXP_MAGIC;
- o->objexp->obj = o;
-}
+/*--------------------------------------------------------------------*/
-static void
-del_objexp(struct object *o)
+void
+EXP_Insert(struct object *o)
{
- struct objexp *oe;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
- oe = o->objexp;
- o->objexp = NULL;
- CHECK_OBJ_NOTNULL(oe, OBJEXP_MAGIC);
- assert(oe->timer_idx == BINHEAP_NOIDX);
- free(oe);
+ assert(o->heap_idx == 0);
+ LOCK(&exp_mtx);
+ binheap_insert(exp_heap, o);
+ VTAILQ_INSERT_TAIL(&exp_lru, o, deathrow);
+ UNLOCK(&exp_mtx);
}
-/*--------------------------------------------------------------------
- * When & why does the timer fire for this object ?
- */
-
-static void
-update_object_when(const struct object *o)
+void
+EXP_Touch(struct object *o, double now)
{
- struct objexp *oe;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
- oe = o->objexp;
- CHECK_OBJ_NOTNULL(oe, OBJEXP_MAGIC);
-
- if (o->prefetch < 0.0) {
- oe->timer_when = o->ttl + o->prefetch;
- oe->timer_what = tmr_prefetch;
- } else if (o->prefetch > 0.0) {
- assert(o->prefetch <= o->ttl);
- oe->timer_when = o->prefetch;
- oe->timer_what = tmr_prefetch;
- } else {
- oe->timer_when = o->ttl + o->grace;
- oe->timer_what = tmr_ttl;
+ if (o->lru_stamp + params->lru_timeout < now) {
+ LOCK(&exp_mtx); /* XXX: should be ..._TRY */
+ if (o->heap_idx != lru_target && o->heap_idx != 0) {
+ VTAILQ_REMOVE(&exp_lru, o, deathrow);
+ VTAILQ_INSERT_TAIL(&exp_lru, o, deathrow);
+ o->lru_stamp = now;
+ }
+ UNLOCK(&exp_mtx);
}
}
-/*--------------------------------------------------------------------
- * Object has been added to cache, record in lru & binheap.
- *
- * We grab a reference to the object, which will keep it around until
- * we decide its time to let it go.
- */
-
void
-EXP_Insert(struct object *o, double now)
+EXP_TTLchange(struct object *o)
{
- struct objexp *oe;
-
- CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
- assert(o->busy);
- assert(o->cacheable);
- HSH_Ref(o);
- add_objexp(o);
- oe = o->objexp;
- oe->lru_stamp = now;
- update_object_when(o);
LOCK(&exp_mtx);
- binheap_insert(exp_heap, oe);
- assert(oe->timer_idx != BINHEAP_NOIDX);
- VTAILQ_INSERT_TAIL(&lru, oe, list);
- oe->on_lru = 1;
- UNLOCK(&exp_mtx);
-}
-
-/*--------------------------------------------------------------------
- * Object was used, move to tail of LRU list.
- *
- * To avoid the exp_mtx becoming a hotspot, we only attempt to move
- * objects if they have not been moved recently and if the lock is available.
- * This optimization obviously leaves the LRU list imperfectly sorted, but
- * that can be worked around by examining obj.last_use in vcl_discard{}
- */
-
-void
-EXP_Touch(const struct object *o, double now)
-{
- int i;
- struct objexp *oe;
-
- CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
- oe = o->objexp;
- if (oe == NULL)
- return;
- CHECK_OBJ_NOTNULL(oe, OBJEXP_MAGIC);
- if (oe->lru_stamp + params->lru_timeout > now)
- return;
- TRYLOCK(&exp_mtx, i);
- if (i)
- return;
- if (oe->on_lru) {
- VTAILQ_REMOVE(&lru, oe, list);
- VTAILQ_INSERT_TAIL(&lru, oe, list);
- oe->lru_stamp = now;
- VSL_stats->n_lru_moved++;
+ if (o->heap_idx != lru_target) {
+ assert(o->heap_idx != 0);
+ binheap_delete(exp_heap, o->heap_idx);
+ binheap_insert(exp_heap, o);
}
UNLOCK(&exp_mtx);
}
/*--------------------------------------------------------------------
- * We have changed one or more of the object timers, shuffle it
- * accordingly in the binheap
- *
- * The VCL code can send us here on a non-cached object, just return.
- *
- * XXX: special case check for ttl = 0 ?
+ * This thread monitors deathrow and kills objects when they time out.
*/
-void
-EXP_Rearm(const struct object *o)
+static void *
+exp_hangman(void *arg)
{
- struct objexp *oe;
+ struct object *o;
+ double t;
- CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
- oe = o->objexp;
- if (oe == NULL)
- return;
- CHECK_OBJ_NOTNULL(oe, OBJEXP_MAGIC);
- update_object_when(o);
- LOCK(&exp_mtx);
- assert(oe->timer_idx != BINHEAP_NOIDX);
- binheap_delete(exp_heap, oe->timer_idx); /* XXX: binheap_shuffle() ? */
- assert(oe->timer_idx == BINHEAP_NOIDX);
- binheap_insert(exp_heap, oe);
- assert(oe->timer_idx != BINHEAP_NOIDX);
- UNLOCK(&exp_mtx);
-}
+ (void)arg;
+ t = TIM_real();
+ while (1) {
+ LOCK(&exp_mtx);
+ VTAILQ_FOREACH(o, &exp_deathrow, deathrow) {
+ CHECK_OBJ(o, OBJECT_MAGIC);
+ if (o->ttl >= t) {
+ o = NULL;
+ break;
+ }
+ if (o->busy) {
+ VSL(SLT_Debug, 0,
+ "Grim Reaper: Busy object xid %u", o->xid);
+ continue;
+ }
+ if (o->refcnt == 1)
+ break;
+ }
+ if (o == NULL) {
+ UNLOCK(&exp_mtx);
+ AZ(sleep(1));
+ t = TIM_real();
+ continue;
+ }
+ VTAILQ_REMOVE(&exp_deathrow, o, deathrow);
+ VSL_stats->n_deathrow--;
+ VSL_stats->n_expired++;
+ UNLOCK(&exp_mtx);
+ VSL(SLT_ExpKill, 0, "%u %d", o->xid, (int)(o->ttl - t));
+ HSH_Deref(o);
+ }
+}
/*--------------------------------------------------------------------
* This thread monitors the root of the binary heap and whenever an
* object gets close enough, VCL is asked to decide if it should be
* discarded or prefetched.
+ * If discarded, the object is put on deathrow where exp_hangman() will
+ * do what needs to be done.
+ * XXX: If prefetched pass to the pool for pickup.
*/
static void *
-exp_timer(void *arg)
+exp_prefetch(void *arg)
{
struct worker ww;
- struct objexp *oe;
struct object *o;
double t;
struct sess *sp;
+ struct object *o2;
unsigned char log[1024]; /* XXX size ? */
- THR_Name("cache-timeout");
(void)arg;
sp = SES_New(NULL, 0);
@@ -276,70 +183,64 @@
t = TIM_real();
while (1) {
LOCK(&exp_mtx);
- oe = binheap_root(exp_heap);
- CHECK_OBJ_ORNULL(oe, OBJEXP_MAGIC);
- if (oe == NULL || oe->timer_when > t) { /* XXX: > or >= ? */
+ o = binheap_root(exp_heap);
+ CHECK_OBJ_ORNULL(o, OBJECT_MAGIC);
+ if (o == NULL || o->ttl > t + expearly) {
UNLOCK(&exp_mtx);
- WSL_Flush(&ww, 0);
AZ(sleep(1));
VCL_Refresh(&sp->vcl);
t = TIM_real();
continue;
}
-
- o = oe->obj;
- CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
- assert(oe->timer_idx != BINHEAP_NOIDX);
- binheap_delete(exp_heap, oe->timer_idx);
- assert(oe->timer_idx == BINHEAP_NOIDX);
-
- { /* Sanity checking */
- struct objexp *oe2 = binheap_root(exp_heap);
- if (oe2 != NULL) {
- assert(oe2->timer_idx != BINHEAP_NOIDX);
- assert(oe2->timer_when >= oe->timer_when);
- }
- }
+ binheap_delete(exp_heap, o->heap_idx);
+ assert(o->heap_idx == 0);
+
+ /* Sanity check */
+ o2 = binheap_root(exp_heap);
+ if (o2 != NULL)
+ assert(o2->ttl >= o->ttl);
- assert(oe->on_lru);
UNLOCK(&exp_mtx);
+ WSL(&ww, SLT_ExpPick, 0, "%u", o->xid);
- WSL(&ww, SLT_ExpPick, 0, "%u %s", o->xid, oe->timer_what);
+ sp->obj = o;
+ VCL_timeout_method(sp);
- if (oe->timer_what == tmr_prefetch) {
- o->prefetch = 0.0;
- sp->obj = o;
- VCL_prefetch_method(sp);
- sp->obj = NULL;
- if (sp->handling == VCL_RET_FETCH) {
- WSL(&ww, SLT_Debug, 0, "Attempt Prefetch %u",
- o->xid);
- }
- update_object_when(o);
- LOCK(&exp_mtx);
- binheap_insert(exp_heap, oe);
- assert(oe->timer_idx != BINHEAP_NOIDX);
- UNLOCK(&exp_mtx);
- } else {
- assert(oe->timer_what == tmr_ttl);
- sp->obj = o;
- VCL_timeout_method(sp);
- sp->obj = NULL;
-
- assert(sp->handling == VCL_RET_DISCARD);
- WSL(&ww, SLT_ExpKill, 0,
- "%u %d", o->xid, (int)(o->ttl - t));
+ if (sp->handling == VCL_RET_DISCARD) {
LOCK(&exp_mtx);
- VTAILQ_REMOVE(&lru, o->objexp, list);
- oe->on_lru = 0;
- VSL_stats->n_expired++;
+ VTAILQ_REMOVE(&exp_lru, o, deathrow);
+ VTAILQ_INSERT_TAIL(&exp_deathrow, o, deathrow);
+ VSL_stats->n_deathrow++;
UNLOCK(&exp_mtx);
- del_objexp(o);
- HSH_Deref(o);
+ continue;
}
+ assert(sp->handling == VCL_RET_DISCARD);
}
}
+/*--------------------------------------------------------------------*/
+
+static int
+object_cmp(void *priv, void *a, void *b)
+{
+ struct object *aa, *bb;
+
+ (void)priv;
+
+ aa = a;
+ bb = b;
+ return (aa->ttl < bb->ttl);
+}
+
+static void
+object_update(void *priv, void *p, unsigned u)
+{
+ struct object *o = p;
+
+ (void)priv;
+ o->heap_idx = u;
+}
+
/*--------------------------------------------------------------------
* Attempt to make space by nuking, with VCLs permission, the oldest
* object on the LRU list which isn't in use.
@@ -349,61 +250,42 @@
int
EXP_NukeOne(struct sess *sp)
{
- struct objexp *oe;
- struct object *o;
+ struct object *o, *o2;
- /*
- * Find the first currently unused object on the LRU.
- *
- * Ideally we would have the refcnt in the objexp so we the object does
- * not need to get paged in for this check, but it does not pay off
- * the complexity: The chances of an object being in front of the LRU,
- * with active references, likely means that it is already in core. An
- * object with no active references will be prodded further anyway.
- *
- * NB: Checking refcount here is no guarantee that it does not gain
- * another ref while we ponder its destiny without the lock held.
- */
+ /* Find the first currently unused object on the LRU */
LOCK(&exp_mtx);
- VTAILQ_FOREACH(oe, &lru, list) {
- CHECK_OBJ_NOTNULL(oe, OBJEXP_MAGIC);
- if (oe->timer_idx == BINHEAP_NOIDX) /* exp_timer has it */
- continue;
- if (oe->obj->refcnt == 1)
+ VTAILQ_FOREACH(o, &exp_lru, deathrow)
+ if (o->refcnt == 1)
break;
- }
- if (oe != NULL) {
+ if (o != NULL) {
/*
- * We hazzard the guess that the object is more likely to
- * be tossed than kept, and forge ahead on the work to save
- * a lock cycle. If the object is kept, we reverse these
- * actions below.
+ * Take it off the binheap while we chew. This effectively
+ * means that we own the EXP refcnt on this object.
*/
- VTAILQ_REMOVE(&lru, oe, list);
- oe->on_lru = 0;
- binheap_delete(exp_heap, oe->timer_idx);
- assert(oe->timer_idx == BINHEAP_NOIDX);
- VSL_stats->n_lru_nuked++;
+ VTAILQ_REMOVE(&exp_lru, o, deathrow);
+ binheap_delete(exp_heap, o->heap_idx);
+ assert(o->heap_idx == 0);
+ o->heap_idx = lru_target;
+ VSL_stats->n_lru_nuked++; /* May be premature */
}
UNLOCK(&exp_mtx);
- if (oe == NULL)
+ if (o == NULL)
return (-1);
/*
- * Ask VCL in the context of the clients session, in order to allow
- * client QoS considerations to inform the decision. Temporarily
- * substitute the object we want to nuke for the sessions own object.
+ * Ask VCL in the context of the requestors session, in order to
+ * allow client QoS considerations to inform the decision.
+ * Temporarily substitute the object we want to nuke for the sessions
+ * own object.
*/
- o = sp->obj;
- sp->obj = oe->obj;
- VCL_discard_method(sp);
+ o2 = sp->obj;
sp->obj = o;
- o = oe->obj;
+ VCL_discard_method(sp);
+ sp->obj = o2;
if (sp->handling == VCL_RET_DISCARD) {
- WSL(sp->wrk, SLT_ExpKill, 0, "%u LRU", o->xid);
- del_objexp(o);
+ VSL(SLT_ExpKill, 0, "%u LRU", o->xid);
HSH_Deref(o);
return (1);
}
@@ -414,39 +296,14 @@
LOCK(&exp_mtx);
VSL_stats->n_lru_nuked--; /* It was premature */
VSL_stats->n_lru_saved++;
- binheap_insert(exp_heap, oe);
- assert(oe->timer_idx != BINHEAP_NOIDX);
- VTAILQ_INSERT_TAIL(&lru, oe, list);
- oe->on_lru = 1;
+ o->heap_idx = 0;
+ o->lru_stamp = sp->wrk->used;
+ binheap_insert(exp_heap, o);
+ VTAILQ_INSERT_TAIL(&exp_lru, o, deathrow);
UNLOCK(&exp_mtx);
return (0);
}
-/*--------------------------------------------------------------------
- * BinHeap helper functions for objexp.
- */
-
-static int
-object_cmp(void *priv, void *a, void *b)
-{
- struct objexp *aa, *bb;
-
- (void)priv;
- CAST_OBJ_NOTNULL(aa, a, OBJEXP_MAGIC);
- CAST_OBJ_NOTNULL(bb, b, OBJEXP_MAGIC);
- return (aa->timer_when < bb->timer_when);
-}
-
-static void
-object_update(void *priv, void *p, unsigned u)
-{
- struct objexp *oe;
-
- (void)priv;
- CAST_OBJ_NOTNULL(oe, p, OBJEXP_MAGIC);
- oe->timer_idx = u;
-}
-
/*--------------------------------------------------------------------*/
void
@@ -456,5 +313,6 @@
MTX_INIT(&exp_mtx);
exp_heap = binheap_new(NULL, object_cmp, object_update);
XXXAN(exp_heap);
- AZ(pthread_create(&exp_thread, NULL, exp_timer, NULL));
+ AZ(pthread_create(&exp_thread, NULL, exp_prefetch, NULL));
+ AZ(pthread_create(&exp_thread, NULL, exp_hangman, NULL));
}
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_fetch.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_fetch.c 2515 2008-02-19 11:52:27Z phk $
+ * $Id: cache_fetch.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
@@ -39,6 +39,7 @@
#include "shmlog.h"
#include "cache.h"
+#include "heritage.h"
#include "stevedore.h"
/*--------------------------------------------------------------------*/
@@ -247,49 +248,6 @@
return (1);
}
-/*--------------------------------------------------------------------
- * Fetch any body attached to the incoming request, and either write it
- * to the backend (if we pass) or discard it (anything else).
- * This is mainly a separate function to isolate the stack buffer and
- * to contain the complexity when we start handling chunked encoding.
- */
-
-int
-FetchReqBody(struct sess *sp)
-{
- unsigned long content_length;
- char buf[8192];
- char *ptr, *endp;
- int read;
-
- if (http_GetHdr(sp->http, H_Content_Length, &ptr)) {
-
- content_length = strtoul(ptr, &endp, 10);
- /* XXX should check result of conversion */
- while (content_length) {
- if (content_length > sizeof buf)
- read = sizeof buf;
- else
- read = content_length;
- read = HTC_Read(sp->htc, buf, read);
- if (read <= 0)
- return (1);
- content_length -= read;
- if (!sp->sendbody)
- continue;
- WRK_Write(sp->wrk, buf, read);
- if (WRK_Flush(sp->wrk))
- return (2);
- }
- }
- if (http_GetHdr(sp->http, H_Transfer_Encoding, NULL)) {
- /* XXX: Handle chunked encoding. */
- WSL(sp->wrk, SLT_Debug, sp->fd, "Transfer-Encoding in request");
- return (1);
- }
- return (0);
-}
-
/*--------------------------------------------------------------------*/
int
@@ -305,12 +263,13 @@
int mklen, is_head;
struct http_conn htc[1];
int i;
+ char *ptr, *endp;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
CHECK_OBJ_NOTNULL(sp->bereq, BEREQ_MAGIC);
- CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC);
+ CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
assert(sp->obj->busy != 0);
w = sp->wrk;
bereq = sp->bereq;
@@ -332,13 +291,31 @@
WRK_Reset(w, &vc->fd);
http_Write(w, hp, 0);
- /* Deal with any message-body the request might have */
- i = FetchReqBody(sp);
- if (i > 0) {
- if (i > 1)
- VBE_UpdateHealth(sp, vc, -1);
- VBE_ClosedFd(sp->wrk, vc);
- return (__LINE__);
+ /*
+ * If a POST request was passed to fetch, we must send any
+ * pipelined bytes to the backend as well
+ */
+ if (http_GetHdr(sp->http, H_Content_Length, &ptr)) {
+ unsigned long content_length;
+ char buf[8192];
+ int read;
+
+ content_length = strtoul(ptr, &endp, 10);
+ /* XXX should check result of conversion */
+ while (content_length) {
+ if (content_length > sizeof buf)
+ read = sizeof buf;
+ else
+ read = content_length;
+ read = HTC_Read(sp->htc, buf, read);
+ WRK_Write(w, buf, read);
+ if (WRK_Flush(w)) {
+ VBE_UpdateHealth(sp, vc, -1);
+ VBE_ClosedFd(sp->wrk, vc);
+ return (__LINE__);
+ }
+ content_length -= read;
+ }
}
if (WRK_Flush(w)) {
@@ -420,7 +397,6 @@
}
VBE_UpdateHealth(sp, vc, -4);
VBE_ClosedFd(sp->wrk, vc);
- sp->obj->len = 0;
return (__LINE__);
}
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_hash.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_hash.c 2614 2008-03-31 11:49:20Z phk $
+ * $Id: cache_hash.c 2564 2008-03-08 13:38:23Z des $
*
* This is the central hash-table code, it relies on a chosen hash
* implementation only for the actual hashing, all the housekeeping
@@ -62,6 +62,7 @@
#include "shmlog.h"
#include "cache.h"
+#include "heritage.h"
#include "stevedore.h"
static struct hash_slinger *hash;
@@ -82,13 +83,12 @@
XXXAN(w->nobjhead);
w->nobjhead->magic = OBJHEAD_MAGIC;
VTAILQ_INIT(&w->nobjhead->objects);
- VTAILQ_INIT(&w->nobjhead->waitinglist);
MTX_INIT(&w->nobjhead->mtx);
VSL_stats->n_objecthead++;
} else
CHECK_OBJ_NOTNULL(w->nobjhead, OBJHEAD_MAGIC);
if (w->nobj == NULL) {
- st = STV_alloc(sp, params->obj_workspace);
+ st = STV_alloc(sp, params->mem_workspace);
XXXAN(st);
assert(st->space > sizeof *w->nobj);
w->nobj = (void *)st->ptr; /* XXX: align ? */
@@ -100,7 +100,7 @@
w->nobj->busy = 1;
w->nobj->refcnt = 1;
VTAILQ_INIT(&w->nobj->store);
- VTAILQ_INIT(&w->nobj->esibits);
+ VTAILQ_INIT(&w->nobj->waitinglist);
VSL_stats->n_object++;
} else
CHECK_OBJ_NOTNULL(w->nobj, OBJECT_MAGIC);
@@ -145,6 +145,7 @@
assert(*b == '\0');
b++;
assert(b == obj->hash + obj->hashlen);
+ WSP(sp, SLT_Debug, "Hash Match: %s", obj->hash);
return (0);
}
@@ -163,6 +164,7 @@
*b++ = '#';
}
*b++ = '\0';
+ WSP(sp, SLT_Debug, "Hash: %s", obj->hash);
assert(b <= obj->hash + obj->hashlen);
}
@@ -172,7 +174,7 @@
struct worker *w;
struct http *h;
struct objhead *oh;
- struct object *o, *busy_o, *grace_o;
+ struct object *o;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
@@ -182,125 +184,78 @@
h = sp->http;
HSH_Prealloc(sp);
- if (sp->objhead != NULL) {
- CHECK_OBJ_NOTNULL(sp->objhead, OBJHEAD_MAGIC);
- oh = sp->objhead;
- sp->objhead = NULL;
- CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
- LOCK(&oh->mtx);
- } else {
- oh = hash->lookup(sp, w->nobjhead);
+ if (sp->obj != NULL) {
+ CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
+ o = sp->obj;
+ oh = o->objhead;
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
- if (oh == w->nobjhead)
- w->nobjhead = NULL;
LOCK(&oh->mtx);
+ goto were_back;
}
- busy_o = NULL;
- grace_o = NULL;
+ oh = hash->lookup(sp, w->nobjhead);
+ CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
+ if (oh == w->nobjhead)
+ w->nobjhead = NULL;
+ LOCK(&oh->mtx);
VTAILQ_FOREACH(o, &oh->objects, list) {
+ o->refcnt++;
if (o->busy) {
- busy_o = o;
- continue;
+ VTAILQ_INSERT_TAIL(&o->waitinglist, sp, list);
+ sp->obj = o;
+ UNLOCK(&oh->mtx);
+ return (NULL);
}
- if (!o->cacheable)
- continue;
- if (o->ttl == 0)
- continue;
- if (BAN_CheckObject(o, h->hd[HTTP_HDR_URL].b, oh->hash)) {
+ were_back:
+ if (!o->cacheable) {
+ /* ignore */
+ } else if (o->ttl == 0) {
+ /* Object banned but not reaped yet */
+ } else if (o->ttl <= sp->t_req) {
+ /* Object expired */
+ } else if (BAN_CheckObject(o,
+ h->hd[HTTP_HDR_URL].b, oh->hash)) {
o->ttl = 0;
WSP(sp, SLT_ExpBan, "%u was banned", o->xid);
- EXP_Rearm(o);
- continue;
- }
- if (o->vary != NULL && !VRY_Match(sp, o->vary))
- continue;
-
- /* If still valid, use it */
- if (o->ttl >= sp->t_req)
+ if (o->heap_idx != 0)
+ EXP_TTLchange(o);
+ } else if (o->vary == NULL || VRY_Match(sp, o->vary))
break;
-
- /* Remember any matching objects inside their grace period */
- if (o->ttl + o->grace >= sp->t_req)
- grace_o = o;
+ o->refcnt--;
}
-
- /*
- * If we have a object in grace and being fetched,
- * use it, if req.grace is also satisified.
- */
- if (o == NULL && grace_o != NULL &&
- grace_o->child != NULL &&
- grace_o->ttl + sp->grace >= sp->t_req)
- o = grace_o;
-
if (o != NULL) {
- /* We found an object we like */
- o->refcnt++;
UNLOCK(&oh->mtx);
(void)hash->deref(oh);
return (o);
}
- if (busy_o != NULL) {
- /* There are one or more busy objects, wait for them */
- VTAILQ_INSERT_TAIL(&oh->waitinglist, sp, list);
- sp->objhead = oh;
- UNLOCK(&oh->mtx);
- return (NULL);
- }
-
/* Insert (precreated) object in objecthead */
o = w->nobj;
w->nobj = NULL;
o->objhead = oh;
- /* XXX: Should this not be ..._HEAD now ? */
VTAILQ_INSERT_TAIL(&oh->objects, o, list);
/* NB: do not deref objhead the new object inherits our reference */
- if (grace_o != NULL) {
- grace_o->child = o;
- o->parent = grace_o;
- grace_o->refcnt++;
- }
UNLOCK(&oh->mtx);
BAN_NewObj(o);
+ /*
+ * It's cheaper to copy the timestamp here, than to get a new one
+ * in EXP_Insert().
+ */
+ o->lru_stamp = w->used;
return (o);
}
-static void
-hsh_rush(struct objhead *oh)
-{
- unsigned u;
- struct sess *sp;
-
- for (u = 0; u < params->rush_exponent; u++) {
- sp = VTAILQ_FIRST(&oh->waitinglist);
- if (sp == NULL)
- return;
- VTAILQ_REMOVE(&oh->waitinglist, sp, list);
- DSL(0x20, SLT_Debug, sp->id, "off waiting list");
- WRK_QueueSession(sp);
- }
-}
-
void
-HSH_Unbusy(struct sess *sp)
+HSH_Unbusy(struct object *o)
{
- struct object *o;
struct objhead *oh;
- struct object *parent;
+ struct sess *sp;
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- o = sp->obj;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
assert(o->busy);
assert(o->refcnt > 0);
- if (o->ws_o->overflow)
- VSL_stats->n_objoverflow++;
- if (params->diag_bitmap & 0x40)
- WSP(sp, SLT_Debug,
- "Object %u workspace free %u", o->xid, WS_Free(o->ws_o));
-
+ if (o->cacheable)
+ EXP_Insert(o);
oh = o->objhead;
if (oh != NULL) {
CHECK_OBJ(oh, OBJHEAD_MAGIC);
@@ -308,15 +263,14 @@
}
o->busy = 0;
if (oh != NULL)
- hsh_rush(oh);
- parent = o->parent;
- o->parent = NULL;
- if (parent != NULL)
- parent->child = NULL;
- if (oh != NULL)
UNLOCK(&oh->mtx);
- if (parent != NULL)
- HSH_Deref(parent);
+ while (1) {
+ sp = VTAILQ_FIRST(&o->waitinglist);
+ if (sp == NULL)
+ break;
+ VTAILQ_REMOVE(&o->waitinglist, sp, list);
+ WRK_QueueSession(sp);
+ }
}
void
@@ -352,8 +306,6 @@
}
assert(o->refcnt > 0);
r = --o->refcnt;
- if (oh != NULL)
- hsh_rush(oh);
if (oh != NULL) {
if (!r)
VTAILQ_REMOVE(&oh->objects, o, list);
@@ -364,13 +316,9 @@
if (r != 0)
return;
- DSL(0x40, SLT_Debug, 0, "Object %u workspace min free %u",
- o->xid, WS_Free(o->ws_o));
-
if (o->vary != NULL)
free(o->vary);
- ESI_Destroy(o);
HSH_Freestore(o);
STV_free(o->objstore);
VSL_stats->n_object--;
@@ -383,7 +331,6 @@
assert(VTAILQ_EMPTY(&oh->objects));
MTX_DESTROY(&oh->mtx);
VSL_stats->n_objecthead--;
- free(oh->hash);
FREE_OBJ(oh);
}
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_http.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_http.c 2633 2008-04-21 07:01:20Z phk $
+ * $Id: cache_http.c 2564 2008-03-08 13:38:23Z des $
*
* HTTP request storage and manipulation
*/
@@ -42,6 +42,7 @@
#include <string.h>
#include <strings.h>
+#include "heritage.h"
#include "shmlog.h"
#include "cache.h"
@@ -65,12 +66,7 @@
[' '] = C_SP,
};
-static int
-vctyp(unsigned char x, unsigned char y)
-{
-
- return (vctyptab[x] & (y));
-}
+#define vctyp(x, y) (vctyptab[(int)(x)] & (y))
#define LOGMTX2(ax, bx, cx) [bx] = SLT_##ax##cx
@@ -231,16 +227,13 @@
hdr++;
u = http_findhdr(hp, l - 1, hdr);
if (u == 0) {
- if (ptr != NULL)
- *ptr = NULL;
+ *ptr = NULL;
return (0);
}
- if (ptr != NULL) {
- p = hp->hd[u].b + l;
- while (isspace(*p))
- p++;
- *ptr = p;
- }
+ p = hp->hd[u].b + l;
+ while (isspace(*p))
+ p++;
+ *ptr = p;
return (1);
}
@@ -372,6 +365,7 @@
hp->nhd = HTTP_HDR_FIRST;
hp->conds = 0;
r = NULL; /* For FlexeLint */
+ assert(p <= t.e); /* http_header_complete() guarantees this */
for (; p < t.e; p = r) {
/* XXX: handle continuation lines */
q = strchr(p, '\n');
@@ -450,9 +444,6 @@
if (vctyp(*p, C_CTL))
return (400);
hp->hd[h3].e = p;
- } else {
- hp->hd[h3].b = p;
- hp->hd[h3].e = p;
}
/* Skip CRLF */
@@ -522,13 +513,6 @@
hp->status =
strtoul(hp->hd[HTTP_HDR_STATUS].b, NULL /* XXX */, 10);
}
- if (!Tlen(hp->hd[HTTP_HDR_RESPONSE])) {
- /* Backend didn't send a response string, use the standard */
- hp->hd[HTTP_HDR_RESPONSE].b =
- TRUST_ME(http_StatusMessage(hp->status));
- hp->hd[HTTP_HDR_RESPONSE].e =
- strchr(hp->hd[HTTP_HDR_RESPONSE].b, '\0');
- }
return (i);
}
@@ -540,8 +524,8 @@
assert(n < HTTP_HDR_MAX);
AN(fm);
- to->hd[n].b = TRUST_ME(fm);
- to->hd[n].e = strchr(to->hd[n].b, '\0');
+ to->hd[n].b = (void*)(uintptr_t)fm;
+ to->hd[n].e = (void*)(uintptr_t)strchr(fm, '\0');
to->hdf[n] = 0;
}
@@ -657,11 +641,12 @@
http_PrintfHeader(sp->wrk, sp->fd, hp,
"X-Forwarded-for: %s", sp->addr);
+ /* XXX: This really ought to go into the default VCL */
+ if (!http_GetHdr(hp, H_Host, &b)) {
+ http_PrintfHeader(sp->wrk, sp->fd, hp, "Host: %s",
+ sp->backend->method->gethostname(sp->backend));
+ }
sp->bereq = bereq;
-
- /* XXX: This possibly ought to go into the default VCL */
- if (!http_GetHdr(hp, H_Host, &b))
- VBE_AddHostHeader(sp);
}
/*--------------------------------------------------------------------
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_httpconn.c
^
|
@@ -88,7 +88,7 @@
htc->magic = HTTP_CONN_MAGIC;
htc->ws = ws;
htc->fd = fd;
- (void)WS_Reserve(htc->ws, (htc->ws->e - htc->ws->s) / 2);
+ WS_Reserve(htc->ws, (htc->ws->e - htc->ws->s) / 2);
htc->rxbuf.b = ws->f;
htc->rxbuf.e = ws->f;
htc->pipeline.b = NULL;
@@ -108,7 +108,7 @@
int i;
CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
- (void)WS_Reserve(htc->ws, (htc->ws->e - htc->ws->s) / 2);
+ WS_Reserve(htc->ws, (htc->ws->e - htc->ws->s) / 2);
htc->rxbuf.b = htc->ws->f;
htc->rxbuf.e = htc->ws->f;
if (htc->pipeline.b != NULL) {
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_main.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_main.c 2598 2008-03-12 14:07:08Z phk $
+ * $Id: cache_main.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
@@ -38,26 +38,10 @@
#include "shmlog.h"
#include "cache.h"
+#include "heritage.h"
#include "stevedore.h"
/*--------------------------------------------------------------------
- * Name threads if our pthreads implementation supports it.
- */
-
-void
-THR_Name(const char *name)
-{
-#ifdef HAVE_PTHREAD_SET_NAME_NP
- pthread_set_name_np(pthread_self(), name);
-#else
- /*
- * XXX: we could stash it somewhere else (TLS ?)
- */
- (void)name;
-#endif
-}
-
-/*--------------------------------------------------------------------
* XXX: Think more about which order we start things
*/
@@ -69,10 +53,6 @@
setbuf(stderr, NULL);
printf("Child starts\n");
- THR_Name("cache-main");
-
- CLI_Init();
-
CNT_Init();
VCL_Init();
@@ -87,13 +67,12 @@
HSH_Init();
BAN_Init();
- VCA_Init();
-
STV_open();
+ printf("Ready\n");
VSL_stats->start_time = (time_t)TIM_real();
- CLI_Run();
+ CLI_Init();
printf("Child dies\n");
}
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_panic.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_panic.c 2527 2008-02-21 20:55:08Z des $
+ * $Id: cache_panic.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
@@ -34,35 +34,23 @@
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
-#include <stdlib.h>
#include "cache.h"
-#include "vcl.h"
#ifndef WITHOUT_ASSERTS
-/*
- * The panic string is constructed in memory, then printed to stderr. It
- * can be extracted post-mortem from a core dump using gdb:
- *
- * (gdb) printf "%s", panicstr
- */
+/* panic string */
char panicstr[65536];
static char *pstr = panicstr;
-#define fp(...) \
- do { \
- pstr += snprintf(pstr, \
- (panicstr + sizeof panicstr) - pstr, \
- __VA_ARGS__); \
- } while (0)
-
-#define vfp(fmt, ap) \
- do { \
- pstr += vsnprintf(pstr, \
- (panicstr + sizeof panicstr) - pstr, \
- (fmt), (ap)); \
- } while (0)
+#define fp(...) \
+ pstr += snprintf(pstr, \
+ (panicstr + sizeof panicstr) - pstr, \
+ __VA_ARGS__)
+#define vfp(fmt, ap) \
+ pstr += vsnprintf(pstr, \
+ (panicstr + sizeof panicstr) - pstr, \
+ (fmt), (ap))
/* step names */
static const char *steps[] = {
@@ -72,20 +60,6 @@
};
static int nsteps = sizeof steps / sizeof *steps;
-/* dump a struct VCL_conf */
-static void
-dump_vcl(const struct VCL_conf *vcl)
-{
- int i;
-
- fp(" vcl = {\n");
- fp(" srcname = {\n");
- for (i = 0; i < vcl->nsrc; ++i)
- fp(" \"%s\",\n", vcl->srcname[i]);
- fp(" },\n");
- fp(" },\n");
-}
-
/* dump a struct storage */
static void
dump_storage(const struct storage *st)
@@ -95,9 +69,8 @@
#define MAX_BYTES (4*16)
#define show(ch) (((ch) > 31 && (ch) < 127) ? (ch) : '.')
- fp(" %u {\n", st->len);
for (i = 0; i < MAX_BYTES && i < st->len; i += 16) {
- fp(" ");
+ fp(" ");
for (j = 0; j < 16; ++j) {
if (i + j < st->len)
fp("%02x ", st->ptr[i + j]);
@@ -111,8 +84,7 @@
fp("|\n");
}
if (st->len > MAX_BYTES)
- fp(" [%u more]\n", st->len - MAX_BYTES);
- fp(" },\n");
+ fp(" [%u more]\n", st->len - MAX_BYTES);
#undef show
#undef MAX_BYTES
@@ -145,7 +117,6 @@
fp(" obj = %p {\n", o);
fp(" refcnt = %u, xid = %u,\n", o->refcnt, o->xid);
dump_http(o->http);
- fp(" len = %u,\n", o->len);
fp(" store = {\n");
VTAILQ_FOREACH(st, &o->store, list) {
dump_storage(st);
@@ -154,7 +125,6 @@
fp(" },\n");
}
-#if 0
/* dump a struct backend */
static void
dump_backend(const struct backend *be)
@@ -165,17 +135,13 @@
be->vcl_name ? be->vcl_name : "(null)");
fp(" },\n");
}
-#endif
/* dump a struct sess */
static void
dump_sess(const struct sess *sp)
{
-#if 0
const struct backend *be = sp->backend;
-#endif
const struct object *obj = sp->obj;
- const struct VCL_conf *vcl = sp->vcl;
fp("sp = %p {\n", sp);
fp(" fd = %d, id = %d, xid = %u,\n", sp->fd, sp->id, sp->xid);
@@ -190,14 +156,8 @@
fp(" err_code = %d, err_reason = %s,\n", sp->err_code,
sp->err_reason ? sp->err_reason : "(null)");
- if (VALID_OBJ(vcl, VCL_CONF_MAGIC))
- dump_vcl(vcl);
-
-#if 0
if (VALID_OBJ(be, BACKEND_MAGIC))
dump_backend(be);
- INCOMPL():
-#endif
if (VALID_OBJ(obj, OBJECT_MAGIC))
dump_object(obj);
@@ -220,23 +180,11 @@
if (VALID_OBJ(sp, SESS_MAGIC))
dump_sess(sp);
- (void)fputs(panicstr, stderr);
+ fputs(panicstr, stderr);
/* I wish there was a way to flush the log buffers... */
- (void)signal(SIGABRT, SIG_DFL);
-#ifdef HAVE_ABORT2
- {
- void *arg[1];
- char *p;
-
- for (p = panicstr; *p; p++)
- if (*p == '\n')
- *p = ' ';
- arg[0] = panicstr;
- abort2(panicstr, 1, arg);
- }
-#endif
- (void)raise(SIGABRT);
+ signal(SIGABRT, SIG_DFL);
+ raise(SIGABRT);
}
#endif
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_pipe.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_pipe.c 2515 2008-02-19 11:52:27Z phk $
+ * $Id: cache_pipe.c 2564 2008-03-08 13:38:23Z des $
*
* XXX: charge bytes to srcaddr
*/
@@ -41,6 +41,7 @@
#include <sys/socket.h>
#include "shmlog.h"
+#include "heritage.h"
#include "cache.h"
static int
@@ -56,8 +57,10 @@
j = write(fd1, p, i);
if (j <= 0)
return (1);
- if (i != j)
- (void)usleep(100000); /* XXX hack */
+ if (i != j) {
+ printf("flunk %d %d\n", i, j);
+ usleep(100000); /* XXX hack */
+ }
}
return (0);
}
@@ -82,11 +85,10 @@
return;
WRK_Reset(w, &vc->fd);
- w->acct.hdrbytes += http_Write(w, bereq->http, 0);
+ http_Write(w, bereq->http, 0);
if (sp->htc->pipeline.b != NULL)
- w->acct.bodybytes +=
- WRK_Write(w, sp->htc->pipeline.b, Tlen(sp->htc->pipeline));
+ WRK_Write(w, sp->htc->pipeline.b, Tlen(sp->htc->pipeline));
if (WRK_Flush(w)) {
vca_close_session(sp, "pipe");
@@ -112,25 +114,25 @@
if (i < 1)
break;
if (fds[0].revents && rdf(vc->fd, sp->fd)) {
- (void)shutdown(vc->fd, SHUT_RD);
- (void)shutdown(sp->fd, SHUT_WR);
+ shutdown(vc->fd, SHUT_RD);
+ shutdown(sp->fd, SHUT_WR);
fds[0].events = 0;
fds[0].fd = -1;
}
if (fds[1].revents && rdf(sp->fd, vc->fd)) {
- (void)shutdown(sp->fd, SHUT_RD);
- (void)shutdown(vc->fd, SHUT_WR);
+ shutdown(sp->fd, SHUT_RD);
+ shutdown(vc->fd, SHUT_WR);
fds[1].events = 0;
fds[1].fd = -1;
}
}
if (fds[0].fd >= 0) {
- (void)shutdown(vc->fd, SHUT_RD);
- (void)shutdown(sp->fd, SHUT_WR);
+ shutdown(vc->fd, SHUT_RD);
+ shutdown(sp->fd, SHUT_WR);
}
if (fds[1].fd >= 0) {
- (void)shutdown(sp->fd, SHUT_RD);
- (void)shutdown(vc->fd, SHUT_WR);
+ shutdown(sp->fd, SHUT_RD);
+ shutdown(vc->fd, SHUT_WR);
}
vca_close_session(sp, "pipe");
VBE_ClosedFd(sp->wrk, vc);
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_pool.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_pool.c 2605 2008-03-13 12:49:36Z phk $
+ * $Id: cache_pool.c 2567 2008-03-08 14:01:28Z des $
*
* XXX: automatic thread-pool size adaptation.
*/
@@ -36,7 +36,7 @@
#include <sys/types.h>
#include <sys/uio.h>
-#ifdef SENDFILE_WORKS
+#ifdef HAVE_SENDFILE
#if defined(__FreeBSD__)
#include <sys/socket.h>
#elif defined(__linux__)
@@ -44,7 +44,7 @@
#else
#error Unknown sendfile() implementation
#endif
-#endif /* SENDFILE_WORKS */
+#endif /* HAVE_SENDFILE */
#include <errno.h>
#include <stdio.h>
@@ -53,6 +53,7 @@
#include <string.h>
#include <unistd.h>
+#include "heritage.h"
#include "shmlog.h"
#include "vcl.h"
#include "cli_priv.h"
@@ -99,11 +100,11 @@
ssize_t i;
CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
- if (*w->wfd >= 0 && w->niov > 0 && w->werr == 0) {
- i = writev(*w->wfd, w->iov, w->niov);
- if (i != w->liov)
- w->werr++;
- }
+ if (*w->wfd < 0 || w->niov == 0 || w->werr)
+ return (w->werr);
+ i = writev(*w->wfd, w->iov, w->niov);
+ if (i != w->liov)
+ w->werr++;
w->liov = 0;
w->niov = 0;
return (w->werr);
@@ -136,14 +137,14 @@
len = strlen(ptr);
if (w->niov == MAX_IOVS)
(void)WRK_Flush(w);
- w->iov[w->niov].iov_base = TRUST_ME(ptr);
+ w->iov[w->niov].iov_base = (void*)(uintptr_t)ptr;
w->iov[w->niov].iov_len = len;
w->liov += len;
w->niov++;
return (len);
}
-#ifdef SENDFILE_WORKS
+#ifdef HAVE_SENDFILE
void
WRK_Sendfile(struct worker *w, int fd, off_t off, unsigned len)
{
@@ -175,7 +176,7 @@
#error Unknown sendfile() implementation
#endif
}
-#endif /* SENDFILE_WORKS */
+#endif /* HAVE_SENDFILE */
/*--------------------------------------------------------------------*/
@@ -203,9 +204,9 @@
{
struct worker *w, ww;
struct wq *qp;
+ char c;
unsigned char wlog[8192]; /* XXX: size */
- THR_Name("cache-worker");
w = &ww;
qp = priv;
memset(w, 0, sizeof *w);
@@ -213,7 +214,7 @@
w->used = TIM_real();
w->wlb = w->wlp = wlog;
w->wle = wlog + sizeof wlog;
- AZ(pthread_cond_init(&w->cond, NULL));
+ AZ(pipe(w->pipe));
VSL(SLT_WorkThread, 0, "%p start", w);
LOCK(&tmtx);
@@ -239,8 +240,8 @@
if (w->wrq == NULL) {
LOCK(&qp->mtx);
VTAILQ_INSERT_HEAD(&qp->idle, w, list);
- AZ(pthread_cond_wait(&w->cond, &qp->mtx));
UNLOCK(&qp->mtx);
+ assert(1 == read(w->pipe[0], &c, 1));
}
if (w->wrq == NULL)
break;
@@ -255,7 +256,8 @@
VSL(SLT_WorkThread, 0, "%p end", w);
if (w->vcl != NULL)
VCL_Rel(&w->vcl);
- AZ(pthread_cond_destroy(&w->cond));
+ AZ(close(w->pipe[0]));
+ AZ(close(w->pipe[1]));
if (w->srcaddr != NULL)
free(w->srcaddr);
if (w->nobjhead != NULL) {
@@ -293,7 +295,7 @@
VTAILQ_REMOVE(&qp->idle, w, list);
UNLOCK(&qp->mtx);
w->wrq = &sp->workreq;
- AZ(pthread_cond_signal(&w->cond));
+ assert(1 == write(w->pipe[1], w, 1));
return;
}
@@ -314,13 +316,6 @@
UNLOCK(&tmtx);
sp->t_end = TIM_real();
vca_close_session(sp, "dropped");
- if(sp->vcl != NULL) {
- /*
- * A session parked on a busy object can come here
- * after it wakes up. Loose the VCL reference.
- */
- VCL_Rel(&sp->vcl);
- }
SES_Delete(sp);
return;
}
@@ -421,7 +416,7 @@
if (w == NULL)
continue;
AZ(w->wrq);
- AZ(pthread_cond_signal(&w->cond));
+ assert(1 == write(w->pipe[1], w, 1));
}
}
}
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_response.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_response.c 2515 2008-02-19 11:52:27Z phk $
+ * $Id: cache_response.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
@@ -38,10 +38,34 @@
#include <stdlib.h>
#include "shmlog.h"
+#include "heritage.h"
#include "cache.h"
/*--------------------------------------------------------------------*/
+void
+RES_Error(struct sess *sp, int code, const char *reason)
+{
+
+ /* get a pristine object */
+ HSH_Prealloc(sp);
+ sp->obj = sp->wrk->nobj;
+ sp->wrk->nobj = NULL;
+ sp->obj->busy = 1;
+
+ /* synthesize error page and send it */
+ SYN_ErrorPage(sp, code, reason, 0);
+ RES_BuildHttp(sp);
+ RES_WriteObj(sp);
+
+ /* GC the error page */
+ HSH_Unbusy(sp->obj);
+ HSH_Deref(sp->obj);
+ sp->obj = NULL;
+}
+
+/*--------------------------------------------------------------------*/
+
static void
res_do_304(struct sess *sp)
{
@@ -128,30 +152,20 @@
{
struct storage *st;
unsigned u = 0;
- char lenbuf[20];
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
WRK_Reset(sp->wrk, &sp->fd);
- if (sp->esis == 0)
- sp->wrk->acct.hdrbytes += http_Write(sp->wrk, sp->http, 1);
-
- if (sp->wantbody && !VTAILQ_EMPTY(&sp->obj->esibits)) {
- ESI_Deliver(sp);
- } else if (sp->wantbody) {
- if (sp->esis > 0) {
- sprintf(lenbuf, "%x\r\n", sp->obj->len);
- sp->wrk->acct.hdrbytes +=
- WRK_Write(sp->wrk, lenbuf, -1);
- }
+ sp->wrk->acct.hdrbytes += http_Write(sp->wrk, sp->http, 1);
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ if (sp->wantbody) {
VTAILQ_FOREACH(st, &sp->obj->store, list) {
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
u += st->len;
sp->wrk->acct.bodybytes += st->len;
-#ifdef SENDFILE_WORKS
+#ifdef HAVE_SENDFILE
/*
* XXX: the overhead of setting up sendfile is not
* XXX: epsilon and maybe not even delta, so avoid
@@ -165,13 +179,11 @@
st->where, st->len);
continue;
}
-#endif /* SENDFILE_WORKS */
+#endif /* HAVE_SENDFILE */
VSL_stats->n_objwrite++;
WRK_Write(sp->wrk, st->ptr, st->len);
}
spassert(u == sp->obj->len);
- if (sp->esis > 0)
- WRK_Write(sp->wrk, "\r\n", -1);
}
if (WRK_Flush(sp->wrk))
vca_close_session(sp, "remote closed");
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_session.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_session.c 2559 2008-03-07 11:13:11Z phk $
+ * $Id: cache_session.c 2564 2008-03-08 13:38:23Z des $
*
* Session and Client management.
*
@@ -56,6 +56,7 @@
#include <sys/uio.h>
#include <sys/socket.h>
+#include "heritage.h"
#include "shmlog.h"
#include "cache.h"
@@ -129,7 +130,7 @@
sp->srcaddr = NULL;
return;
}
- SPAZ(sp->srcaddr);
+ AZ(sp->srcaddr);
u = crc32_l(sp->addr, strlen(sp->addr));
v = u % nsrchash;
ch = &srchash[v];
@@ -289,7 +290,7 @@
* need to cache it locally, to make sure we get a
* consistent view of it.
*/
- u = params->sess_workspace;
+ u = params->mem_workspace;
sm = malloc(sizeof *sm + u);
if (sm == NULL)
return (NULL);
@@ -336,8 +337,8 @@
sm = sp->mem;
CHECK_OBJ_NOTNULL(sm, SESSMEM_MAGIC);
- SPAZ(sp->obj);
- SPAZ(sp->vcl);
+ AZ(sp->obj);
+ AZ(sp->vcl);
VSL_stats->n_sess--;
ses_relsrcaddr(sp);
assert(!isnan(b->first));
@@ -346,7 +347,7 @@
sp->addr, sp->port, sp->t_end - b->first,
b->sess, b->req, b->pipe, b->pass,
b->fetch, b->hdrbytes, b->bodybytes);
- if (sm->workspace != params->sess_workspace) {
+ if (sm->workspace != params->mem_workspace) {
VSL_stats->n_sess_mem--;
free(sm);
} else {
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_synthetic.c
^
|
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_synthetic.c 2557 2008-03-07 10:58:12Z phk $
+ * $Id: cache_synthetic.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
@@ -37,67 +37,71 @@
#include "shmlog.h"
#include "cache.h"
+#include "heritage.h"
#include "stevedore.h"
/*
- * Synthesize an error page including headers.
- * XXX: For now close the connection. Long term that should probably
- * XXX: be either a paramter or VCL decision.
- * XXX: VCL should get a shot at generating the page.
+ * Synthesize an error page. This assumes the session already has an
+ * object - if it doesn't, you need to either call HSH_Lookup(), or call
+ * HSH_Prealloc() and grab sp->obj->nobj, before calling this.
*/
-
void
-SYN_ErrorPage(struct sess *sp, int status, const char *reason)
+SYN_ErrorPage(struct sess *sp, int status, const char *reason, int ttl)
{
- struct http *h;
+ struct storage *st;
+ struct object *o;
struct worker *w;
+ struct http *h;
+ struct vsb vsb;
const char *msg;
char date[40];
double now;
- unsigned u;
- struct vsb vsb;
int fd;
- int ttl = 0; /* XXX: ?? */
- WSL_Flush(sp->wrk, 0);
+ WSL_Flush(sp->wrk);
assert(status >= 100 && status <= 999);
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
+ CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
+ CHECK_OBJ_NOTNULL(sp->obj->http, HTTP_MAGIC);
+ assert(sp->obj->busy > 0);
/* shortcuts */
w = sp->wrk;
- h = sp->http;
fd = sp->fd;
- now = TIM_real(); /* XXX: use cached val ? */
-
- WRK_Reset(w, &sp->fd);
+ o = sp->obj;
+ h = o->http;
+ now = TIM_real();
+
+ /* Set up obj's workspace */
+ st = o->objstore;
+ WS_Init(o->ws_o, "obj", st->ptr + st->len, st->space - st->len);
+ st->len = st->space;
+ WS_Assert(o->ws_o);
+ http_Setup(o->http, o->ws_o);
/* look up HTTP response */
msg = http_StatusMessage(status);
- AN(msg);
if (reason == NULL)
reason = msg;
+ AN(reason);
+ AN(msg);
- /* generate header */
- http_ClrHeader(h);
- h->logtag = HTTP_Tx;
- http_PutProtocol(w, fd, h, "HTTP/1.0"); /* XXX */
- http_PutStatus(w, fd, h, status);
- http_PutResponse(w, fd, h, msg);
- TIM_format(now, date);
- http_PrintfHeader(w, fd, h, "Date: %s", date);
- http_PrintfHeader(w, fd, h, "Server: Varnish");
- http_PrintfHeader(w, fd, h, "Retry-After: %d", ttl);
- http_PrintfHeader(w, fd, h, "Content-Type: text/html; charset=utf-8");
- http_PrintfHeader(w, sp->fd, sp->http, "X-Varnish: %u", sp->xid);
- http_PrintfHeader(w, fd, h, "Connection: close");
-
- w->acct.hdrbytes += http_Write(w, h, 1);
+ /* populate metadata */
+ o->response = status;
+ o->valid = 1;
+ o->entered = now;
+ o->ttl = now + ttl;
+ o->last_modified = now;
+ o->xid = sp->xid;
+
+ /* allocate space for body */
+ /* XXX what if the object already has a body? */
+ st = STV_alloc(sp, 1024);
+ VTAILQ_INSERT_TAIL(&sp->obj->store, st, list);
/* generate body */
- /* XXX: VCL should do this */
- u = WS_Reserve(h->ws, 0);
- AN(vsb_new(&vsb, h->ws->f, u, VSB_FIXEDLEN));
+ AN(vsb_new(&vsb, (char *)st->ptr, st->space, VSB_FIXEDLEN));
vsb_printf(&vsb,
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n"
@@ -119,9 +123,23 @@
" </body>\n"
"</html>\n");
vsb_finish(&vsb);
- AZ(vsb_overflowed(&vsb));
- w->acct.hdrbytes = WRK_Write(w, vsb_data(&vsb), vsb_len(&vsb));
- (void)WRK_Flush(w);
+ o->len = st->len = vsb_len(&vsb);
vsb_delete(&vsb);
- vca_close_session(sp, "error returned");
+
+ /* allocate space for header */
+
+ WS_Init(h->ws, "error", malloc(1024), 1024);
+
+ /* generate header */
+ http_ClrHeader(h);
+ http_PutProtocol(w, fd, h, "HTTP/1.0"); /* XXX */
+ http_PutStatus(w, fd, h, status);
+ http_PutResponse(w, fd, h, msg);
+ TIM_format(now, date);
+ http_PrintfHeader(w, fd, h, "Date: %s", date);
+ http_PrintfHeader(w, fd, h, "Server: Varnish");
+ http_PrintfHeader(w, fd, h, "Retry-After: %ju", (uintmax_t)ttl);
+ http_PrintfHeader(w, fd, h, "Content-Type: text/html; charset=utf-8");
+ http_PrintfHeader(w, fd, h, "Content-Length: %u", o->len);
+ /* DO NOT generate X-Varnish header, RES_BuildHttp will */
}
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_vary.c
^
|
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_vary.c 2613 2008-03-31 11:47:15Z phk $
+ * $Id: cache_vary.c 2564 2008-03-08 13:38:23Z des $
*
* Do Vary processing.
*
@@ -69,10 +69,6 @@
struct vsb *sb, *sbh;
unsigned l;
- /* No Vary: header, no worries */
- if (!http_GetHdr(sp->obj->http, H_Vary, &v))
- return;
-
/* For vary matching string */
sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND);
AN(sb);
@@ -81,6 +77,10 @@
sbh = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND);
AN(sbh);
+ /* No Vary: header, no worries */
+ if (!http_GetHdr(sp->obj->http, H_Vary, &v))
+ return;
+
for (p = v; *p; p++) {
/* Find next header-name */
@@ -93,7 +93,6 @@
vsb_clear(sbh);
vsb_printf(sbh, "%c%.*s:%c", 1 + (q - p), q - p, p, 0);
vsb_finish(sbh);
- AZ(vsb_overflowed(sbh));
/* Append to vary matching string */
vsb_bcat(sb, vsb_data(sbh), vsb_len(sbh));
@@ -125,14 +124,10 @@
vsb_printf(sb, "%c", 0);
vsb_finish(sb);
- AZ(vsb_overflowed(sb));
l = vsb_len(sb);
sp->obj->vary = malloc(l);
AN(sp->obj->vary);
memcpy(sp->obj->vary, vsb_data(sb), l);
-
- vsb_delete(sb);
- vsb_delete(sbh);
}
int
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_vcl.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_vcl.c 2598 2008-03-12 14:07:08Z phk $
+ * $Id: cache_vcl.c 2564 2008-03-08 13:38:23Z des $
*
* Interface *to* compiled VCL code: Loading, unloading, calling into etc.
*
@@ -49,9 +49,10 @@
struct vcls {
VTAILQ_ENTRY(vcls) list;
- char *name;
+ const char *name;
void *dlh;
struct VCL_conf *conf;
+ int discard;
};
/*
@@ -62,9 +63,10 @@
VTAILQ_HEAD_INITIALIZER(vcl_head);
-static MTX vcl_mtx;
static struct vcls *vcl_active; /* protected by vcl_mtx */
+static MTX vcl_mtx;
+
/*--------------------------------------------------------------------*/
void
@@ -85,7 +87,6 @@
AN(vcl_active);
*vcc = vcl_active->conf;
AN(*vcc);
- AZ((*vcc)->discard);
(*vcc)->busy++;
UNLOCK(&vcl_mtx);
}
@@ -93,6 +94,7 @@
void
VCL_Rel(struct VCL_conf **vcc)
{
+ struct vcls *vcl;
struct VCL_conf *vc;
vc = *vcc;
@@ -101,11 +103,19 @@
LOCK(&vcl_mtx);
assert(vc->busy > 0);
vc->busy--;
- /*
- * We do not garbage collect discarded VCL's here, that happens
- * in VCL_Idle() which is called from the CLI thread.
- */
+ vcl = vc->priv; /* XXX miniobj */
+ if (vc->busy == 0 && vcl_active != vcl) {
+ /* XXX: purge backends */
+ }
+ if (vc->busy == 0 && vcl->discard) {
+ VTAILQ_REMOVE(&vcl_head, vcl, list);
+ } else {
+ vcl = NULL;
+ }
UNLOCK(&vcl_mtx);
+ if (vcl != NULL) {
+ /* XXX: dispose of vcl */
+ }
}
/*--------------------------------------------------------------------*/
@@ -115,13 +125,9 @@
{
struct vcls *vcl;
- ASSERT_CLI();
- VTAILQ_FOREACH(vcl, &vcl_head, list) {
- if (vcl->conf->discard)
- continue;
+ VTAILQ_FOREACH(vcl, &vcl_head, list)
if (!strcmp(vcl->name, name))
return (vcl);
- }
return (NULL);
}
@@ -130,10 +136,12 @@
{
struct vcls *vcl;
- ASSERT_CLI();
vcl = vcl_find(name);
if (vcl != NULL) {
- cli_out(cli, "Config '%s' already loaded", name);
+ if (cli == NULL)
+ fprintf(stderr, "Config '%s' already loaded", name);
+ else
+ cli_out(cli, "Config '%s' already loaded", name);
return (1);
}
@@ -143,20 +151,29 @@
vcl->dlh = dlopen(fn, RTLD_NOW | RTLD_LOCAL);
if (vcl->dlh == NULL) {
- cli_out(cli, "dlopen(%s): %s\n", fn, dlerror());
+ if (cli == NULL)
+ fprintf(stderr, "dlopen(%s): %s\n", fn, dlerror());
+ else
+ cli_out(cli, "dlopen(%s): %s\n", fn, dlerror());
free(vcl);
return (1);
}
vcl->conf = dlsym(vcl->dlh, "VCL_conf");
if (vcl->conf == NULL) {
- cli_out(cli, "No VCL_conf symbol\n");
+ if (cli == NULL)
+ fprintf(stderr, "No VCL_conf symbol\n");
+ else
+ cli_out(cli, "No VCL_conf symbol\n");
(void)dlclose(vcl->dlh);
free(vcl);
return (1);
}
if (vcl->conf->magic != VCL_CONF_MAGIC) {
- cli_out(cli, "Wrong VCL_CONF_MAGIC\n");
+ if (cli == NULL)
+ fprintf(stderr, "Wrong VCL_CONF_MAGIC\n");
+ else
+ cli_out(cli, "Wrong VCL_CONF_MAGIC\n");
(void)dlclose(vcl->dlh);
free(vcl);
return (1);
@@ -169,53 +186,23 @@
if (vcl_active == NULL)
vcl_active = vcl;
UNLOCK(&vcl_mtx);
- cli_out(cli, "Loaded \"%s\" as \"%s\"\n", fn , name);
- vcl->conf->init_func(cli);
+ if (cli == NULL)
+ fprintf(stderr, "Loaded \"%s\" as \"%s\"\n", fn , name);
+ else
+ cli_out(cli, "Loaded \"%s\" as \"%s\"\n", fn , name);
+ vcl->conf->init_func();
return (0);
}
-/*--------------------------------------------------------------------
- * This function is polled from the CLI thread to dispose of any non-busy
- * VCLs * which have been discarded.
- */
-
-static void
-VCL_Nuke(struct vcls *vcl)
-{
-
- ASSERT_CLI();
- assert(vcl != vcl_active);
- assert(vcl->conf->discard);
- assert(vcl->conf->busy == 0);
- VTAILQ_REMOVE(&vcl_head, vcl, list);
- vcl->conf->fini_func(NULL);
- free(vcl->name);
- free(vcl);
-}
-
/*--------------------------------------------------------------------*/
void
-VCL_Idle(void)
-{
- struct vcls *vcl, *vcl2;
-
- ASSERT_CLI();
- VTAILQ_FOREACH_SAFE(vcl, &vcl_head, list, vcl2)
- if (vcl->conf->discard && vcl->conf->busy == 0)
- VCL_Nuke(vcl);
-}
-
-/*--------------------------------------------------------------------*/
-
-static void
-ccf_config_list(struct cli *cli, const char * const *av, void *priv)
+cli_func_config_list(struct cli *cli, const char * const *av, void *priv)
{
struct vcls *vcl;
(void)av;
(void)priv;
- ASSERT_CLI();
VTAILQ_FOREACH(vcl, &vcl_head, list) {
cli_out(cli, "%s %6u %s\n",
vcl == vcl_active ? "* " : " ",
@@ -224,24 +211,22 @@
}
}
-static void
-ccf_config_load(struct cli *cli, const char * const *av, void *priv)
+void
+cli_func_config_load(struct cli *cli, const char * const *av, void *priv)
{
(void)av;
(void)priv;
- ASSERT_CLI();
if (VCL_Load(av[3], av[2], cli))
cli_result(cli, CLIS_PARAM);
return;
}
-static void
-ccf_config_discard(struct cli *cli, const char * const *av, void *priv)
+void
+cli_func_config_discard(struct cli *cli, const char * const *av, void *priv)
{
struct vcls *vcl;
- ASSERT_CLI();
(void)av;
(void)priv;
vcl = vcl_find(av[2]);
@@ -250,6 +235,11 @@
cli_out(cli, "VCL '%s' unknown", av[2]);
return;
}
+ if (vcl->discard) {
+ cli_result(cli, CLIS_PARAM);
+ cli_out(cli, "VCL %s already discarded", av[2]);
+ return;
+ }
LOCK(&vcl_mtx);
if (vcl == vcl_active) {
UNLOCK(&vcl_mtx);
@@ -257,14 +247,19 @@
cli_out(cli, "VCL %s is the active VCL", av[2]);
return;
}
- vcl->conf->discard = 1;
- UNLOCK(&vcl_mtx);
+ vcl->discard = 1;
if (vcl->conf->busy == 0)
- VCL_Nuke(vcl);
+ VTAILQ_REMOVE(&vcl_head, vcl, list);
+ else
+ vcl = NULL;
+ UNLOCK(&vcl_mtx);
+ if (vcl != NULL) {
+ /* XXX dispose of vcl */
+ }
}
-static void
-ccf_config_use(struct cli *cli, const char * const *av, void *priv)
+void
+cli_func_config_use(struct cli *cli, const char * const *av, void *priv)
{
struct vcls *vcl;
@@ -276,6 +271,11 @@
cli_result(cli, CLIS_PARAM);
return;
}
+ if (vcl->discard) {
+ cli_out(cli, "VCL '%s' has been discarded", av[2]);
+ cli_result(cli, CLIS_PARAM);
+ return;
+ }
LOCK(&vcl_mtx);
vcl_active = vcl;
UNLOCK(&vcl_mtx);
@@ -321,18 +321,9 @@
/*--------------------------------------------------------------------*/
-static struct cli_proto vcl_cmds[] = {
- { CLI_VCL_LOAD, ccf_config_load },
- { CLI_VCL_LIST, ccf_config_list },
- { CLI_VCL_DISCARD, ccf_config_discard },
- { CLI_VCL_USE, ccf_config_use },
- { NULL }
-};
-
void
VCL_Init()
{
- CLI_AddFuncs(MASTER_CLI, vcl_cmds);
MTX_INIT(&vcl_mtx);
}
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_vrt.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_vrt.c 2554 2008-03-04 11:42:00Z des $
+ * $Id: cache_vrt.c 2564 2008-03-08 13:38:23Z des $
*
* Runtime support for compiled VCL programs
*/
@@ -37,7 +37,6 @@
#include <sys/socket.h>
#include <netinet/in.h>
-#include <arpa/inet.h>
#include <stdio.h>
#include <string.h>
@@ -45,6 +44,7 @@
#include <stdarg.h>
#include "shmlog.h"
+#include "heritage.h"
#include "vrt.h"
#include "vrt_obj.h"
#include "vcl.h"
@@ -294,7 +294,8 @@
if (a < 0)
a = 0;
sp->obj->ttl = sp->t_req + a;
- EXP_Rearm(sp->obj);
+ if (sp->obj->heap_idx != 0)
+ EXP_TTLchange(sp->obj);
}
double
@@ -305,66 +306,6 @@
return (sp->obj->ttl - sp->t_req);
}
-/*--------------------------------------------------------------------
- * obj.grace is relative to obj.ttl, so no special magic is necessary.
- */
-
-void
-VRT_l_obj_grace(const struct sess *sp, double a)
-{
-
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */
- if (a < 0)
- a = 0;
- sp->obj->grace = a;
- EXP_Rearm(sp->obj);
-}
-
-double
-VRT_r_obj_grace(const struct sess *sp)
-{
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */
- return (sp->obj->grace);
-}
-
-/*--------------------------------------------------------------------*/
-
-/* XXX: the VCL_info messages has unexpected fractions on the ttl */
-
-void
-VRT_l_obj_prefetch(const struct sess *sp, double a)
-{
-
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */
- sp->obj->prefetch = 0.0;
- if (a == 0.0)
- sp->obj->prefetch = a;
- else if (a > 0.0 && a + sp->t_req <= sp->obj->ttl)
- sp->obj->prefetch = a + sp->t_req;
- else if (a < 0.0 && a + sp->obj->ttl > sp->t_req)
- sp->obj->prefetch = a;
- else if (a > 0.0)
- WSL(sp->wrk, SLT_VCL_info, sp->id,
- "XID %u: obj.prefetch (%g) after TTL (%g), ignored.",
- sp->obj->xid, a, sp->obj->ttl - sp->t_req);
- else /* if (a < 0.0) */
- WSL(sp->wrk, SLT_VCL_info, sp->id,
- "XID %u: obj.prefetch (%g) less than ttl (%g), ignored.",
- sp->obj->xid, a, sp->obj->ttl - sp->t_req);
- EXP_Rearm(sp->obj);
-}
-
-double
-VRT_r_obj_prefetch(const struct sess *sp)
-{
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */
- return (sp->obj->prefetch - sp->t_req);
-}
-
/*--------------------------------------------------------------------*/
#define VOBJ(type,onm,field) \
@@ -390,17 +331,17 @@
/*--------------------------------------------------------------------*/
void
-VRT_l_req_backend(struct sess *sp, struct director *be)
+VRT_l_req_backend(struct sess *sp, struct backend *be)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- sp->director = be;
+ sp->backend = be;
}
-struct director *
+struct backend *
VRT_r_req_backend(struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- return (sp->director);
+ return (sp->backend);
}
/*--------------------------------------------------------------------*/
@@ -428,27 +369,6 @@
return (sp->restarts);
}
-/*--------------------------------------------------------------------
- * req.grace
- */
-
-void
-VRT_l_req_grace(struct sess *sp, double a)
-{
-
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- if (a < 0)
- a = 0;
- sp->grace = a;
-}
-
-double
-VRT_r_req_grace(struct sess *sp)
-{
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- return (sp->grace);
-}
-
/*--------------------------------------------------------------------*/
const char *
@@ -527,7 +447,7 @@
{
(void)sp;
- return (TIM_real());
+ return (TIM_mono());
}
double
@@ -536,34 +456,16 @@
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */
- return (TIM_real() - sp->obj->last_use);
-}
-
-const char *
-VRT_r_obj_hash(const struct sess *sp)
-{
-
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- if (sp->obj == NULL)
- return (NULL);
- CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
- if (sp->obj->objhead == NULL)
- return (NULL);
- CHECK_OBJ_NOTNULL(sp->obj->objhead, OBJHEAD_MAGIC);
- return (sp->obj->objhead->hash);
+ return (TIM_mono() - sp->obj->lru_stamp);
}
int
VRT_r_backend_health(const struct sess *sp)
{
+
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-#if 0
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
return (sp->backend->health);
-#else
- INCOMPL();
- return (0);
-#endif
}
/*--------------------------------------------------------------------*/
@@ -571,52 +473,42 @@
char *
VRT_IP_string(const struct sess *sp, const struct sockaddr *sa)
{
- char *p;
- const void *addr;
- int len;
+ char h[64], p[8], *q;
+ socklen_t len = 0;
+ /* XXX can't rely on sockaddr.sa_len */
switch (sa->sa_family) {
case AF_INET:
- len = INET_ADDRSTRLEN;
- addr = &((const struct sockaddr_in *)sa)->sin_addr;
+ len = sizeof(struct sockaddr_in);
break;
case AF_INET6:
- len = INET_ADDRSTRLEN;
- addr = &((const struct sockaddr_in6 *)sa)->sin6_addr;
+ len = sizeof(struct sockaddr_in6);
break;
default:
INCOMPL();
}
XXXAN(len);
- AN(p = WS_Alloc(sp->http->ws, len));
- AN(inet_ntop(sa->sa_family, addr, p, len));
- return (p);
+ TCP_name(sa, len, h, sizeof h, p, sizeof p);
+ q = WS_Alloc(sp->http->ws, strlen(h) + strlen(p) + 2);
+ AN(q);
+ strcpy(q, h);
+ strcat(q, ":");
+ strcat(q, p);
+ return (q);
}
char *
VRT_int_string(const struct sess *sp, int num)
{
char *p;
- int size;
-
- size = snprintf(NULL, 0, "%d", num) + 1;
- AN(p = WS_Alloc(sp->http->ws, size));
+ int size = 12;
+
+ p = WS_Alloc(sp->http->ws, size);
+ AN(p);
assert(snprintf(p, size, "%d", num) < size);
return (p);
}
-char *
-VRT_double_string(const struct sess *sp, double num)
-{
- char *p;
- int size;
-
- size = snprintf(NULL, 0, "%.3f", num) + 1;
- AN(p = WS_Alloc(sp->http->ws, size));
- assert(snprintf(p, size, "%.3f", num) < size);
- return (p);
-}
-
/*--------------------------------------------------------------------*/
void
@@ -648,3 +540,14 @@
return (strcmp(s1, s2));
}
+
+/*--------------------------------------------------------------------
+ * Backend stuff
+ */
+
+void
+VRT_fini_backend(struct backend *b)
+{
+
+ VBE_DropRef(b);
+}
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_vrt_acl.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_vrt_acl.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: cache_vrt_acl.c 2564 2008-03-08 13:38:23Z des $
*
* Runtime support for compiled VCL programs, ACLs
*
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_vrt_esi.c
^
|
@@ -28,23 +28,12 @@
*
* $Id: cache_vrt.c 2067 2007-09-30 20:57:30Z phk $
*
- * Runtime support for compiled VCL programs ESI processing.
- *
- * The basic ESI 1.0 is a very simple specification:
- * http://www.w3.org/TR/esi-lang
- * But it seems that Oracle and Akamai has embrodiered it to be almost a new
- * layer of scripting language in HTTP transmission chains.
- *
- * It is not obvious how much help the "advanced" features of ESI really
- * are to users, so our aim is to pick the fruit starting with the lowest
- * hanging, esi:include
+ * Runtime support for compiled VCL programs
*/
#include "config.h"
#include <stdio.h>
-#include <unistd.h>
-#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
@@ -54,756 +43,12 @@
#include "vcl.h"
#include "cache.h"
-#define NDEFELEM 10
-
-/*--------------------------------------------------------------------*/
-
-struct esi_bit {
- VTAILQ_ENTRY(esi_bit) list;
- char chunk_length[20];
- txt verbatim;
- txt host;
- txt include;
- int free_this;
-};
-
-VTAILQ_HEAD(esibithead, esi_bit);
-
-struct esi_work {
- struct sess *sp;
- size_t off;
- txt t;
- txt o;
- txt dst;
- struct esi_bit *eb;
- struct esi_bit *ebl; /* list of */
- int neb;
- int is_esi;
- int remflg; /* inside <esi:remove> </esi:remove> */
- int incmt; /* inside <!--esi ... --> comment */
- int incdata; /* inside <![CCDATA[ ... ]]> */
-};
-
-/*--------------------------------------------------------------------
- * Report a parsing error
- */
-
-static void
-esi_error(const struct esi_work *ew, const char *p, int i, const char *err)
-{
- int ellipsis = 0;
- char buf[256], *q;
- txt t;
-
- if (i == 0)
- i = p - ew->t.b;
- if (i > 20) {
- i = 20;
- ellipsis = 1;
- }
- q = buf;
- q += sprintf(buf, "at %zd: %s \"", ew->off + (p - ew->t.b), err);
- while (i > 0) {
- if (*p >= ' ' && *p <= '~') {
- *q++ = *p;
- } else if (*p == '\n') {
- *q++ = '\\';
- *q++ = 'n';
- } else if (*p == '\r') {
- *q++ = '\\';
- *q++ = 'r';
- } else if (*p == '\t') {
- *q++ = '\\';
- *q++ = 't';
- } else {
- /* XXX: use %%%02x instead ? */
- q += sprintf(q, "\\x%02x", *p);
- }
- p++;
- i--;
- }
- if (ellipsis) {
- *q++ = '[';
- *q++ = '.';
- *q++ = '.';
- *q++ = '.';
- *q++ = ']';
- }
- *q++ = '"';
- *q++ = '\0';
- t.b = buf;
- t.e = q;
- WSPR(ew->sp, SLT_ESI_xmlerror, t);
-}
-
-/*--------------------------------------------------------------------
- * Add ESI bit to object
- */
-
-static struct esi_bit *
-esi_addbit(struct esi_work *ew)
-{
-
- if (ew->neb == 0) {
- ew->ebl = calloc(NDEFELEM, sizeof(struct esi_bit));
- XXXAN(ew->ebl);
- ew->neb = NDEFELEM;
- ew->ebl->free_this = 1;
- }
- ew->eb = ew->ebl;
- ew->ebl++;
- ew->neb--;
-
-
- VTAILQ_INSERT_TAIL(&ew->sp->obj->esibits, ew->eb, list);
- ew->eb->verbatim = ew->dst;
- sprintf(ew->eb->chunk_length, "%x\r\n", Tlen(ew->dst));
- VSL(SLT_Debug, ew->sp->fd, "AddBit: %d <%.*s>",
- Tlen(ew->dst), Tlen(ew->dst), ew->dst.b);
- return(ew->eb);
-}
-
-
-/*--------------------------------------------------------------------
- * Add verbatim piece to output
- */
-
-static void
-esi_addverbatim(struct esi_work *ew)
-{
-
- VSL(SLT_Debug, ew->sp->fd, "AddVer: %d <%.*s>",
- Tlen(ew->o), Tlen(ew->o), ew->o.b);
- if (ew->o.b != ew->dst.e)
- memmove(ew->dst.e, ew->o.b, Tlen(ew->o));
- ew->dst.e += Tlen(ew->o);
-}
-
-/*--------------------------------------------------------------------
- * Tease the next attribute and value out of an XML element.
- *
- * XXX: is the syntax correct ?
- */
-
-static int
-esi_attrib(const struct esi_work *ew, txt *in, txt *attrib, txt *val)
-{
-
- /* Skip leading blanks */
- while(in->b < in->e && isspace(*in->b))
- in->b++;
-
- /* Nothing found */
- if (in->b >= in->e)
- return (0);
-
- if (!isalpha(*in->b)) {
- /* XXX error */
- esi_error(ew, in->b, 1, "XML 1.0 Illegal attribute character");
- return (-1);
- }
-
- /* Attribute name until '=' or space */
- *attrib = *in;
- while(in->b < in->e && *in->b != '=' && !isspace(*in->b)) {
- if (!isalnum(*in->b)) {
- esi_error(ew, attrib->b, 1 + (in->b - attrib->b),
- "XML 1.0 Illegal attribute character");
- return (-1);
- }
- in->b++;
- }
- attrib->e = in->b;
-
- if (in->b >= in->e || isspace(*in->b)) {
- /* Attribute without value */
- val->b = val->e = in->b;
- return (1);
- }
-
- /* skip '=' */
- in->b++;
-
- /* Value, if any ? */
- *val = *in;
- if (in->b >= in->e)
- return (1);
-
- if (*in->b == '"') {
- /* Skip quote */
- in->b++;
- val->b++;
-
- /* Anything goes, until next quote */
- while(in->b < in->e && *in->b != '"')
- in->b++;
- val->e = in->b;
-
- if (in->b >= in->e) {
- esi_error(ew, val->b, in->e - val->b,
- "XML 1.0 missing ending quote");
- return (-1);
- }
-
- /* Skip quote */
- in->b++;
- } else {
- /* Anything until whitespace */
- while(in->b < in->e && !isspace(*in->b))
- in->b++;
- val->e = in->b;
- }
- *val->e = '\0';
- return (1);
-}
-
-/*--------------------------------------------------------------------
- * Add one piece to the output, either verbatim or include
- */
-
-static void
-esi_addinclude(struct esi_work *ew, txt t)
-{
- struct esi_bit *eb;
- char *p, *q;
- txt tag;
- txt val;
- unsigned u, v;
- struct ws *ws;
-
- VSL(SLT_Debug, 0, "Incl \"%.*s\"", t.e - t.b, t.b);
- eb = esi_addbit(ew);
- while (esi_attrib(ew, &t, &tag, &val) == 1) {
- VSL(SLT_Debug, 0, "<%.*s> -> <%.*s>",
- tag.e - tag.b, tag.b,
- val.e - val.b, val.b);
- if (Tlen(tag) != 3 && memcmp(tag.b, "src", 3))
- continue;
-
- assert(Tlen(val) > 0); /* XXX */
-
- if (Tlen(val) > 7 && !memcmp(val.b, "http://", 7)) {
- /* Rewrite to Host: header inplace */
- eb->host.b = val.b;
- memcpy(eb->host.b, "Host: ", 6);
- q = eb->host.b + 6;
- for (p = eb->host.b + 7; p < val.e && *p != '/'; p++)
- *q++ = *p;
- *q++ = '\0';
- eb->host.e = q;
- assert(*p == '/'); /* XXX */
- /* The rest is the URL */
- eb->include.b = p;
- eb->include.e = val.e;
- } else if (Tlen(val) > 0 && *val.b == '/') {
- /* Absolute on this host */
- eb->include = val;
- } else {
-
- /*
- * Decision: We interpret the relative URL against
- * the actual URL we asked the backend for.
- * The client's request URL may be entirely
- * different and have been rewritten underway.
- */
- CHECK_OBJ_NOTNULL(ew->sp, SESS_MAGIC);
- CHECK_OBJ_NOTNULL(ew->sp->bereq, BEREQ_MAGIC);
- CHECK_OBJ_NOTNULL(ew->sp->bereq->http, HTTP_MAGIC);
- tag = ew->sp->bereq->http->hd[HTTP_HDR_URL];
-
- /* Use the objects WS to store the result */
- CHECK_OBJ_NOTNULL(ew->sp->obj, OBJECT_MAGIC);
- ws = ew->sp->obj->ws_o;
- WS_Assert(ws);
-
- /* Look for the last '/' before a '?' */
- q = NULL;
- for (p = tag.b; p < tag.e && *p != '?'; p++)
- if (*p == '/')
- q = p;
- if (q != NULL)
- tag.e = q + 1;
-
- u = WS_Reserve(ws, 0);
- v = snprintf(ws->f, u - 1, "%.*s%.*s",
- pdiff(tag.b, tag.e), tag.b,
- pdiff(val.b, val.e), val.b);
- v++;
- xxxassert(v < u);
- eb->include.b = ws->f;
- eb->include.e = ws->f + v;
- WS_Release(ws, v);
- }
- }
-}
-
-/*--------------------------------------------------------------------
- * Zoom over a piece of object and dike out all releveant esi: pieces.
- * The entire txt may not be processed because an interesting part
- * could possibly span into the next chunk of storage.
- * Return value: number of bytes processed.
- */
-
-static char *
-esi_parse2(struct esi_work *ew)
-{
- char *p, *q, *r;
- txt t;
- int celem; /* closing element */
- int i;
-
- t = ew->t;
- ew->dst.b = t.b;
- ew->dst.e = t.b;
- ew->o.b = t.b;
- ew->o.e = t.b;
- for (p = t.b; p < t.e; ) {
- assert(p >= t.b);
- assert(p < t.e);
- if (ew->incdata) {
- /*
- * We are inside an <![CDATA[ constuct and mus skip
- * to the end marker ]]>.
- */
- if (*p != ']') {
- p++;
- } else {
- if (p + 2 >= t.e)
- return (p);
- if (!memcmp(p, "]]>", 3)) {
- ew->incdata = 0;
- p += 3;
- } else
- p++;
- }
- continue;
- }
- if (ew->incmt && *p == '-') {
- /*
- * We are inside an <!--esi comment and need to zap
- * the end comment marker --> when we see it.
- */
- if (p + 2 >= t.e)
- return (p);
- if (!memcmp(p, "-->", 3)) {
- ew->incmt = 0;
- ew->o.e = p;
- esi_addverbatim(ew);
- p += 3;
- ew->o.b = p;
- } else
- p++;
- continue;
- }
-
- if (*p != '<') {
- /* nothing happens until next element or comment */
- p++;
- continue;
- }
-
- i = t.e - p;
-
- if (i < 2)
- return (p);
-
- if (ew->remflg == 0 && !memcmp(p, "<!--esi", i > 7 ? 7 : i)) {
- /*
- * ESI comment. <!--esi...-->
- * at least 10 char, but we only test on the
- * first seven because the tail is handled
- * by the ew->incmt flag.
- */
- ew->is_esi++;
- if (i < 7)
- return (p);
-
- ew->o.e = p;
- esi_addverbatim(ew);
-
- p += 7;
- ew->o.b = p;
- ew->incmt = 1;
- continue;
- }
-
- if (!memcmp(p, "<!--", i > 4 ? 4 : i)) {
- /*
- * plain comment <!--...--> at least 7 char
- */
- if (i < 7)
- return (p);
- for (q = p + 4; ; q++) {
- if (q + 2 >= t.e)
- return (p);
- if (!memcmp(q, "-->", 3))
- break;
- }
- p = q + 3;
- continue;
- }
-
- if (!memcmp(p, "<![CDATA[", i > 9 ? 9 : i)) {
- /*
- * cdata <![CDATA[ at least 9 char
- */
- if (i < 9)
- return (p);
- ew->incdata = 1;
- p += 9;
- continue;
- }
-
- /* Find end of this element */
- for (q = p + 1; q < t.e && *q != '>'; q++)
- continue;
- if (q >= t.e || *q != '>')
- return (p);
-
- /* Opening/empty or closing element ? */
- if (p[1] == '/') {
- celem = 1;
- r = p + 2;
- if (q[-1] == '/') {
- esi_error(ew, p, 1 + q - p,
- "XML 1.0 empty and closing element");
- }
- } else {
- celem = 0;
- r = p + 1;
- }
-
- VSL(SLT_Debug, ew->sp->fd, "Element: clos=%d [%.*s]",
- celem, q - r, r);
-
- if (r + 9 < q && !memcmp(r, "esi:remove", 10)) {
-
- ew->is_esi++;
-
- if (celem != ew->remflg) {
- /*
- * ESI 1.0 violation, ignore element
- */
- esi_error(ew, p, 1 + q - p, ew->remflg ?
- "ESI 1.0 forbids nested esi:remove"
- : "ESI 1.0 esi:remove not opened");
-
- if (!ew->remflg) {
- ew->o.e = p;
- esi_addverbatim(ew);
- }
- } else if (!celem && q[-1] == '/') {
- /* empty element */
- ew->o.e = p;
- esi_addverbatim(ew);
- } else if (!celem) {
- /* open element */
- ew->o.e = p;
- esi_addverbatim(ew);
- ew->remflg = !celem;
- } else {
- /* close element */
- ew->remflg = !celem;
- }
- p = q + 1;
- ew->o.b = p;
- continue;
- }
-
- if (ew->remflg && r + 3 < q && !memcmp(r, "esi:", 4)) {
- /*
- * ESI 1.0 violation, no esi: elements in esi:remove
- */
- esi_error(ew, p, 1 + q - p,
- "ESI 1.0 forbids esi: elements inside esi:remove");
- p = q + 1;
- continue;
- }
- ew->is_esi++;
-
- if (r + 10 < q && !memcmp(r, "esi:comment", 11)) {
-
- ew->o.e = p;
- esi_addverbatim(ew);
-
- if (celem == 1) {
- esi_error(ew, p, 1 + q - p,
- "ESI 1.0 closing esi:comment illegal");
- } else if (q[-1] != '/') {
- esi_error(ew, p, 1 + q - p,
- "ESI 1.0 wants empty esi:comment");
- }
- p = q + 1;
- ew->o.b = p;
- continue;
- }
- if (r + 10 < q && !memcmp(r, "esi:include", 11)) {
-
- ew->o.e = p;
- esi_addverbatim(ew);
-
- if (celem == 0) {
- ew->o.b = r + 11;
- if (q[-1] != '/') {
- esi_error(ew, p, 1 + q - p,
- "ESI 1.0 wants empty esi:include");
- ew->o.e = q;
- } else {
- ew->o.e = q - 1;
- }
- esi_addinclude(ew, ew->o);
- ew->dst.b = q + 1;
- ew->dst.e = q + 1;
- } else {
- esi_error(ew, p, 1 + q - p,
- "ESI 1.0 closing esi:include illegal");
- }
- p = q + 1;
- ew->o.b = p;
- continue;
- }
-
- if (r + 3 < q && !memcmp(r, "esi:", 4)) {
- /*
- * Unimplemented ESI element, ignore
- */
- esi_error(ew, p, 1 + q - p,
- "ESI 1.0 unimplemented element");
- ew->o.e = p;
- esi_addverbatim(ew);
- p = q + 1;
- ew->o.b = p;
- continue;
- }
-
- /* Not an element we care about */
- assert(q < t.e);
- p = q + 1;
- }
- assert(p == t.e);
- return (p);
-}
-
-static char *
-esi_parse(struct esi_work *ew)
-{
- char *p;
-
- VSL(SLT_Debug, ew->sp->fd, "Parse: %d <%.*s>",
- Tlen(ew->t), Tlen(ew->t), ew->t.b);
- p = esi_parse2(ew);
- assert(ew->o.b >= ew->t.b);
- assert(ew->o.e <= ew->t.e);
- ew->o.e = p;
- if (Tlen(ew->o) && !ew->remflg)
- esi_addverbatim(ew);
- if (Tlen(ew->dst))
- esi_addbit(ew);
- ew->off += (p - ew->t.b);
- return (p);
-}
-
/*--------------------------------------------------------------------*/
void
VRT_ESI(struct sess *sp)
{
- struct storage *st, *st2;
- struct esi_work *ew, eww[1];
- txt t;
- unsigned u;
- char *p, *q;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- assert(sp->obj->busy);
- if (sp->cur_method != VCL_MET_FETCH) {
- /* XXX: we should catch this at compile time */
- WSP(sp, SLT_VCL_error,
- "esi can only be called from vcl_fetch");
- return;
- }
-
- CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
-
- /* XXX: only if GET ? */
- ew = eww;
- memset(eww, 0, sizeof eww);
- ew->sp = sp;
- ew->off = 1;
-
- p = NULL;
- VTAILQ_FOREACH(st, &sp->obj->store, list) {
- if (p != NULL) {
- assert ((void*)p > (void *)st->ptr);
- assert ((void*)p <= (void *)(st->ptr + st->len));
- if (p == (void*)(st->ptr + st->len))
- break;
- ew->t.b = p;
- p = NULL;
- } else
- ew->t.b = (void *)st->ptr;
- ew->t.e = (void *)(st->ptr + st->len);
- p = esi_parse(ew);
- if (p == ew->t.e) {
- p = NULL;
- continue;
- }
-
- if (VTAILQ_NEXT(st, list) == NULL) {
- /*
- * XXX: illegal XML input, but did we handle
- * XXX: all of it, or do we leave the final
- * XXX: element dangling ?
- */
- esi_error(ew, p, ew->t.e -p,
- "XML 1.0 incomplete language element");
- ew->dst.b = p;
- ew->dst.e = ew->t.e;
- esi_addbit(ew);
- break;
- }
-
- /* Move remainder to workspace */
- u = ew->t.e - p;
- t.b = sp->obj->ws_o->f;
- t.e = t.b + WS_Reserve(sp->obj->ws_o, 0);
- if (t.b + u >= t.e) {
- esi_error(ew, p, ew->t.e - p,
- "XML 1.0 unreasonably long element");
- WS_Release(sp->obj->ws_o, 0);
- ew->dst.b = p;
- ew->dst.e = ew->t.e;
- esi_addbit(ew);
- p = NULL;
- continue;
- }
- assert(t.e > t.b + u); /* XXX incredibly long element ? */
- memcpy(t.b, p, u);
-
- /* Peel start off next chunk, until and including '<' */
- st2 = VTAILQ_NEXT(st, list);
- AN(st2);
- q = t.b + u;
- p = (void*)st2->ptr;
- while (1) {
- if (p >= (char *)st2->ptr + st2->len || q >= t.e) {
- esi_error(ew, t.b, q - t.b,
- "XML 1.0 unreasonably long element");
- WS_Release(sp->obj->ws_o, 0);
- ew->dst.b = t.b;
- ew->dst.e = q;
- esi_addbit(ew);
- p = NULL;
- break;
- }
- *q = *p++;
- if (*q++ == '>')
- break;
- }
- if (p == NULL)
- continue;
- WS_ReleaseP(sp->obj->ws_o, q);
- t.e = q;
-
- /* Parse this bit */
- ew->t = t;
- q = esi_parse(ew);
- assert(q == ew->t.e); /* XXX */
-
- /* 'p' is cached starting point for next storage part */
- }
-
- /*
- * XXX: we could record the starting point of these elements
- * XXX: so that the char-index were more useful, but we are
- * XXX: not trivially able to print their contents, so leave
- * XXX: it like this for now, pending more thought about the
- * XXX: proper way to report these errors.
- */
- if (ew->incdata)
- esi_error(ew, ew->t.e, -1,
- "ESI 1.0 unterminated <![CDATA[ element");
- if (ew->remflg)
- esi_error(ew, ew->t.e, -1,
- "ESI 1.0 unterminated <esi:remove> element");
- if (ew->incmt)
- esi_error(ew, ew->t.e, -1,
- "ESI 1.0 unterminated <!--esi comment");
-
- if (!ew->is_esi) {
- ESI_Destroy(sp->obj);
- return;
- }
-
- /*
- * Our ESI implementation needs chunked encoding
- * XXX: We should only do this if we find any ESI directives
- */
- http_Unset(sp->obj->http, H_Content_Length);
- http_PrintfHeader(sp->wrk, sp->fd, sp->obj->http,
- "Transfer-Encoding: chunked");
-
+ INCOMPL();
}
-
-/*--------------------------------------------------------------------*/
-
-void
-ESI_Deliver(struct sess *sp)
-{
-
- struct esi_bit *eb;
- struct object *obj;
-
- VTAILQ_FOREACH(eb, &sp->obj->esibits, list) {
- WRK_Write(sp->wrk, eb->chunk_length, -1);
- WRK_Write(sp->wrk, eb->verbatim.b, Tlen(eb->verbatim));
- WRK_Write(sp->wrk, "\r\n", -1);
- if (eb->include.b == NULL ||
- sp->esis >= params->max_esi_includes)
- continue;
-
- /*
- * We flush here, because the next transaction is
- * quite likely to take some time, so we should get
- * as many bits to the client as we can already
- */
- WRK_Flush(sp->wrk);
-
- sp->esis++;
- obj = sp->obj;
- sp->obj = NULL;
- *sp->http = *sp->http0;
- /* XXX: reset sp->ws */
- http_SetH(sp->http, HTTP_HDR_URL, eb->include.b);
- if (eb->host.b != NULL) {
- http_Unset(sp->http, H_Host);
- http_SetHeader(sp->wrk, sp->fd, sp->http, eb->host.b);
- }
- sp->step = STP_RECV;
- CNT_Session(sp);
- sp->esis--;
- sp->obj = obj;
-
- }
- if (sp->esis == 0)
- WRK_Write(sp->wrk, "0\r\n\r\n", -1);
-}
-
-/*--------------------------------------------------------------------*/
-
-void
-ESI_Destroy(struct object *o)
-{
- struct esi_bit *eb;
-
- /*
- * Delete esi_bits from behind and free(3) the ones that want to be.
- */
- while (!VTAILQ_EMPTY(&o->esibits)) {
- eb = VTAILQ_LAST(&o->esibits, esibithead);
- VTAILQ_REMOVE(&o->esibits, eb, list);
- if (eb->free_this)
- free(eb);
- }
-}
-
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_vrt_re.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_vrt_re.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: cache_vrt_re.c 2564 2008-03-08 13:38:23Z des $
*
* Runtime support for compiled VCL programs, regexps
*/
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/cache_ws.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cache_ws.c 2603 2008-03-13 10:29:14Z phk $
+ * $Id: cache_ws.c 2564 2008-03-08 13:38:23Z des $
*
*/
@@ -41,17 +41,25 @@
#include <string.h>
#include <unistd.h>
+#include "heritage.h"
#include "shmlog.h"
#include "vcl.h"
#include "cli_priv.h"
#include "cache.h"
+/* Enable this to get detailed logging of WS usage */
+#ifdef DIAGNOSTICS
+# define WS_DEBUG(fmt, ...) VSL(SLT_Debug, 0, fmt, __VA_ARGS__)
+#else
+# define WS_DEBUG(fmt, ...) /* nothing */
+#endif
+
void
WS_Assert(const struct ws *ws)
{
CHECK_OBJ_NOTNULL(ws, WS_MAGIC);
- DSL(0x02, SLT_Debug, 0, "WS(%p = (%s, %p %u %u %u)",
+ WS_DEBUG("WS(%p = (%s, %p %u %u %u)",
ws, ws->id, ws->s, pdiff(ws->s, ws->f),
ws->r == NULL ? 0 : pdiff(ws->f, ws->r),
pdiff(ws->s, ws->e));
@@ -70,8 +78,7 @@
WS_Init(struct ws *ws, const char *id, void *space, unsigned len)
{
- DSL(0x02, SLT_Debug, 0,
- "WS_Init(%p, \"%s\", %p, %u)", ws, id, space, len);
+ WS_DEBUG("WS_Init(%p, \"%s\", %p, %u)", ws, id, space, len);
assert(space != NULL);
memset(ws, 0, sizeof *ws);
ws->magic = WS_MAGIC;
@@ -87,7 +94,7 @@
{
WS_Assert(ws);
- DSL(0x02, SLT_Debug, 0, "WS_Reset(%p, %p)", ws, p);
+ WS_DEBUG("WS_Reset(%p, %p)", ws, p);
assert(ws->r == NULL);
if (p == NULL)
ws->f = ws->s;
@@ -105,13 +112,11 @@
WS_Assert(ws);
assert(ws->r == NULL);
- if (ws->f + bytes > ws->e) {
- ws->overflow++;
+ if (ws->f + bytes > ws->e)
return(NULL);
- }
r = ws->f;
ws->f += bytes;
- DSL(0x02, SLT_Debug, 0, "WS_Alloc(%p, %u) = %p", ws, bytes, r);
+ WS_DEBUG("WS_Alloc(%p, %u) = %p", ws, bytes, r);
return (r);
}
@@ -125,25 +130,17 @@
p = WS_Alloc(ws, l);
if (p != NULL)
memcpy(p, s, l);
- DSL(0x02, SLT_Debug, 0, "WS_Dup(%p, \"%s\") = %p", ws, s, p);
+ WS_DEBUG("WS_Dup(%p, \"%s\") = %p", ws, s, p);
return (p);
}
-unsigned
-WS_Free(struct ws *ws)
-{
-
- WS_Assert(ws);
- return(ws->e - ws->f);
-}
-
char *
WS_Snapshot(struct ws *ws)
{
WS_Assert(ws);
assert(ws->r == NULL);
- DSL(0x02, SLT_Debug, 0, "WS_Snapshot(%p) = %p", ws, ws->f);
+ WS_DEBUG("WS_Snapshot(%p) = %p", ws, ws->f);
return (ws->f);
}
@@ -158,7 +155,7 @@
b2 = ws->e - ws->f;
xxxassert(ws->f + b2 <= ws->e);
ws->r = ws->f + b2;
- DSL(0x02, SLT_Debug, 0, "WS_Reserve(%p, %u/%u) = %u",
+ WS_DEBUG("WS_Reserve(%p, %u/%u) = %u",
ws, b2, bytes, pdiff(ws->f, ws->r));
return (pdiff(ws->f, ws->r));
}
@@ -167,7 +164,7 @@
WS_Release(struct ws *ws, unsigned bytes)
{
WS_Assert(ws);
- DSL(0x02, SLT_Debug, 0, "WS_Release(%p, %u)", ws, bytes);
+ WS_DEBUG("WS_Release(%p, %u)", ws, bytes);
assert(ws->r != NULL);
assert(ws->f + bytes <= ws->r);
ws->f += bytes;
@@ -178,7 +175,7 @@
WS_ReleaseP(struct ws *ws, char *ptr)
{
WS_Assert(ws);
- DSL(0x02, SLT_Debug, 0, "WS_ReleaseP(%p, %p)", ws, ptr);
+ WS_DEBUG("WS_ReleaseP(%p, %p)", ws, ptr);
assert(ws->r != NULL);
assert(ptr >= ws->f);
assert(ptr <= ws->r);
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/common.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: common.h 2415 2008-01-31 11:57:51Z des $
+ * $Id: common.h 2496 2008-02-17 09:26:32Z des $
*/
struct cli;
@@ -44,5 +44,3 @@
void TCP_name(const struct sockaddr *addr, unsigned l, char *abuf, unsigned alen, char *pbuf, unsigned plen);
void TCP_myname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen);
int TCP_filter_http(int sock);
-
-#define TRUST_ME(ptr) ((void*)(uintptr_t)(ptr))
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/flint.lnt
^
|
@@ -9,13 +9,11 @@
-emacro(736, isnan) // isnanf
-// -header(../../config.h)
+-header(../../config.h)
// Fix strchr() semtics, it can only return NULL if arg2 != 0
-sem(strchr, 1p, type(1), 2n == 0 ? (@p < 1p) : (@p < 1p || @p == 0 ))
--sem(vsb_new, @p == malloc(1))
--sem(vsb_delete, custodial(1))
-sem(lbv_assert, r_no)
-sem(lbv_xxxassert, r_no)
-sem(WS_Init, custodial(2))
@@ -55,8 +53,6 @@
-emacro(506, isnan) // constant value boolean
-emacro(747, isnan) // significant coersion
-emacro(506, assert) // constant value boolean
--emacro(827, assert) // loop not reachable
--emacro(774, assert) // booelan always true
-emacro(774, HTTPH) // always false
// cache.h
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/flint.sh
^
|
@@ -5,8 +5,6 @@
-I/usr/include \
-I. \
-I../../include \
- -I../.. \
- -DVARNISH_STATE_DIR=\"foo\" \
flint.lnt \
*.c > $T 2>&1
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/hash_classic.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: hash_classic.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: hash_classic.c 2564 2008-03-08 13:38:23Z des $
*
* A classic bucketed hash
*/
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/hash_simple_list.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: hash_simple_list.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: hash_simple_list.c 2564 2008-03-08 13:38:23Z des $
*
* This is the reference hash(/lookup) implementation
*/
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/hash_slinger.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: hash_slinger.h 2415 2008-01-31 11:57:51Z des $
+ * $Id: hash_slinger.h 2496 2008-02-17 09:26:32Z des $
*/
struct sess;
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/heritage.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: heritage.h 2559 2008-03-07 11:13:11Z phk $
+ * $Id: heritage.h 2496 2008-02-17 09:26:32Z des $
*
* This file contains the heritage passed when mgt forks cache
*/
@@ -85,8 +85,7 @@
unsigned overflow_max;
/* Memory allocation hints */
- unsigned sess_workspace;
- unsigned obj_workspace;
+ unsigned mem_workspace;
/* Acceptor hints */
unsigned sess_timeout;
@@ -99,10 +98,8 @@
/* Fetcher hints */
unsigned fetch_chunksize;
-#ifdef SENDFILE_WORKS
/* Sendfile object minimum size */
unsigned sendfile_threshold;
-#endif
/* VCL traces */
unsigned vcl_trace;
@@ -131,20 +128,6 @@
/* Maximum restarts allowed */
unsigned max_restarts;
- /* Maximum esi:include depth allowed */
- unsigned max_esi_includes;
-
- /* Rush exponent */
- unsigned rush_exponent;
-
- /* Cache vbe_conns */
- unsigned cache_vbe_conns;
-
- /* CLI buffer size */
- unsigned cli_buffer;
-
- /* Control diagnostic code */
- unsigned diag_bitmap;
};
extern volatile struct params *params;
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/mgt.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: mgt.h 2598 2008-03-12 14:07:08Z phk $
+ * $Id: mgt.h 2496 2008-02-17 09:26:32Z des $
*/
#include "common.h"
@@ -44,7 +44,8 @@
/* mgt_cli.c */
-void mgt_cli_setup(int fdi, int fdo, int verbose, const char *ident);
+void mgt_cli_init(void);
+void mgt_cli_setup(int fdi, int fdo, int verbose);
int mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...);
void mgt_cli_start_child(int fdi, int fdo);
void mgt_cli_stop_child(void);
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/mgt_child.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: mgt_child.c 2483 2008-02-15 12:59:59Z phk $
+ * $Id: mgt_child.c 2564 2008-03-08 13:38:23Z des $
*
* The mechanics of handling the child process
*/
@@ -39,7 +39,6 @@
#include <fcntl.h>
#include <stdlib.h>
#include <signal.h>
-#include <syslog.h>
#include <errno.h>
#include <poll.h>
#include <sys/types.h>
@@ -55,7 +54,6 @@
#include "cli_priv.h"
#include "mgt_cli.h"
#include "mgt_event.h"
-#include "vlu.h"
#include "vss.h"
pid_t mgt_pid;
@@ -81,36 +79,28 @@
struct evbase *mgt_evb;
static struct ev *ev_poker;
static struct ev *ev_listen;
-static struct vlu *vlu;
-
-/*--------------------------------------------------------------------*/
-
-static int
-child_line(void *priv, const char *p)
-{
- (void)priv;
-
- fprintf(stderr, "Child said (%d, %d): <<%s>>\n",
- child_state, child_pid, p);
- syslog(LOG_NOTICE, "Child (%d) said <<%s>>", child_pid, p);
- return (0);
-}
/*--------------------------------------------------------------------*/
static int
child_listener(const struct ev *e, int what)
{
+ int i;
+ char buf[BUFSIZ];
(void)e;
if ((what & ~EV_RD)) {
ev_listen = NULL;
return (1);
}
- if (VLU_Fd(child_fds[0], vlu)) {
+ i = read(child_fds[0], buf, sizeof buf - 1);
+ if (i <= 0) {
ev_listen = NULL;
return (1);
}
+ buf[i] = '\0';
+ fprintf(stderr, "Child said (%d, %d): <<%s>>\n",
+ child_state, child_pid, buf);
return (0);
}
@@ -126,7 +116,7 @@
return (1);
if (child_pid > 0 && mgt_cli_askchild(NULL, NULL, "ping\n")) {
fprintf(stderr, "Child not responding to ping\n");
- (void)kill(child_pid, SIGKILL);
+ kill(child_pid, SIGKILL);
}
return (0);
}
@@ -168,7 +158,7 @@
VTAILQ_FOREACH(ls, &heritage.socks, list) {
if (ls->sock < 0)
continue;
- (void)close(ls->sock);
+ close(ls->sock);
ls->sock = -1;
}
}
@@ -220,8 +210,8 @@
setproctitle("Varnish-Chld %s", heritage.name);
- (void)signal(SIGINT, SIG_DFL);
- (void)signal(SIGTERM, SIG_DFL);
+ signal(SIGINT, SIG_DFL);
+ signal(SIGTERM, SIG_DFL);
child_main();
exit(1);
@@ -232,9 +222,6 @@
AZ(close(child_fds[1]));
child_fds[1] = -1;
- vlu = VLU_New(NULL, child_line, 0);
- AN(vlu);
-
AZ(ev_listen);
e = ev_new();
XXXAN(e);
@@ -370,7 +357,7 @@
(void)e;
(void)what;
fprintf(stderr, "Manager got SIGINT\n");
- (void)fflush(stdout);
+ fflush(stdout);
if (child_pid >= 0)
stop_child();
exit (2);
@@ -395,7 +382,7 @@
XXXAN(mgt_evb);
if (dflag)
- mgt_cli_setup(0, 1, 1, "debug");
+ mgt_cli_setup(0, 1, 1);
if (T_arg)
mgt_cli_telnet(T_arg);
@@ -435,9 +422,6 @@
fprintf(stderr, "rolling(2)...\n");
if (!dflag)
start_child();
- else
- fprintf(stderr,
- "Debugging mode, enter \"start\" to start child\n");
i = ev_schedule(mgt_evb);
fprintf(stderr, "ev_schedule = %d\n", i);
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/mgt_cli.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: mgt_cli.c 2595 2008-03-12 10:25:51Z phk $
+ * $Id: mgt_cli.c 2564 2008-03-08 13:38:23Z des $
*
* The management process' CLI handling
*/
@@ -57,7 +57,6 @@
#include "mgt_event.h"
#include "shmlog.h"
-#include "vlu.h"
#include "vss.h"
static int cli_i = -1, cli_o = -1;
@@ -78,30 +77,72 @@
#undef MAC_STAT
}
+
+/*--------------------------------------------------------------------
+ * Passthru of cli commands. It is more or less just undoing what
+ * the cli parser did, but such is life...
+ */
+
static void
-mcf_help(struct cli *cli, const char * const *av, void *priv)
+mcf_passthru(struct cli *cli, const char * const *av, void *priv)
{
+ struct vsb *sb;
+ const char *p;
+ char *q;
unsigned u;
- char *p;
+ int i;
- cli_func_help(cli, av, priv);
- if (cli_o >= 0 && (av[2] == NULL || *av[2] == '-')) {
- p = NULL;
- if (!mgt_cli_askchild(&u, &p,
- "help %s\n", av[2] != NULL ? av[2] : "")) {
- cli_out(cli, "%s", p);
- cli_result(cli, u);
- }
- free(p);
+ (void)priv;
+
+ /* Request */
+ if (cli_o <= 0) {
+ cli_result(cli, CLIS_CANT);
+ cli_out(cli, "Cache process not running");
+ return;
}
+ sb = vsb_new(NULL, NULL, 64, VSB_AUTOEXTEND);
+ XXXAN(sb);
+ for (u = 1; av[u] != NULL; u++) {
+ if (u > 1)
+ vsb_putc(sb, ' ');
+ vsb_putc(sb, '"');
+ for (p = av[u]; *p; p++) {
+ switch (*p) {
+ case '\\':
+ vsb_cat(sb, "\\\\");
+ break;
+ case '\n':
+ vsb_cat(sb, "\\n");
+ break;
+ case '"':
+ vsb_cat(sb, "\\\"");
+ break;
+ default:
+ vsb_putc(sb, *p);
+ }
+ }
+ vsb_putc(sb, '"');
+ }
+ vsb_putc(sb, '\n');
+ xxxassert(!vsb_overflowed(sb));
+ vsb_finish(sb);
+ i = write(cli_o, vsb_data(sb), vsb_len(sb));
+ xxxassert(i == vsb_len(sb));
+ vsb_delete(sb);
+
+ i = cli_readres(cli_i, &u, &q, params->cli_timeout);
+ cli_result(cli, u);
+ cli_out(cli, "%s", q);
+ free(q);
+
}
/*--------------------------------------------------------------------*/
+static struct cli_proto *cli_proto;
/* XXX: what order should this list be in ? */
-static struct cli_proto cli_proto[] = {
- { CLI_HELP, mcf_help, cli_proto },
+static struct cli_proto mgt_cli_proto[] = {
{ CLI_PING, cli_func_ping },
{ CLI_SERVER_STATUS, mcf_server_status, NULL },
{ CLI_SERVER_START, mcf_server_startstop, NULL },
@@ -115,6 +156,7 @@
{ CLI_VCL_SHOW, mcf_config_show, NULL },
{ CLI_PARAM_SHOW, mcf_param_show, NULL },
{ CLI_PARAM_SET, mcf_param_set, NULL },
+ { CLI_HELP, cli_func_help, NULL },
#if 0
{ CLI_SERVER_RESTART },
{ CLI_ZERO },
@@ -126,13 +168,59 @@
{ NULL }
};
+
+/*--------------------------------------------------------------------*/
+
+void
+mgt_cli_init(void)
+{
+ struct cli_proto *cp;
+ unsigned u, v;
+
+ /*
+ * Build the joint cli_proto by combining the manager process
+ * entries with with the cache process entries. The latter
+ * get a "passthough" function in the joint list
+ */
+ u = 0;
+ for (cp = mgt_cli_proto; cp->request != NULL; cp++)
+ u++;
+ for (cp = CLI_cmds; cp->request != NULL; cp++)
+ u++;
+ cli_proto = calloc(sizeof *cli_proto, u + 1);
+ XXXAN(cli_proto);
+ u = 0;
+ for (cp = mgt_cli_proto; cp->request != NULL; cp++)
+ cli_proto[u++] = *cp;
+ for (cp = CLI_cmds; cp->request != NULL; cp++) {
+ /* Skip any cache commands we already have in the manager */
+ for (v = 0; v < u; v++)
+ if (!strcmp(cli_proto[v].request, cp->request))
+ break;
+ if (v < u)
+ continue;
+ cli_proto[u] = *cp;
+ cli_proto[u].func = mcf_passthru;
+ u++;
+ }
+
+ /* Fixup the entry for 'help' entry */
+ for (u = 0; cli_proto[u].request != NULL; u++) {
+ if (!strcmp(cli_proto[u].request, "help")) {
+ cli_proto[u].priv = cli_proto;
+ break;
+ }
+ }
+}
+
/*--------------------------------------------------------------------
* Ask the child something over CLI, return zero only if everything is
* happy happy.
*/
int
-mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...) {
+mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...)
+{
char *p;
int i, j;
va_list ap;
@@ -199,115 +287,99 @@
int fdi;
int fdo;
int verbose;
- struct vlu *vlu;
+ char *buf;
+ int nbuf; /* next free position in buf */
+ int lbuf; /* length of buf */
struct cli cli[1];
- char *name;
+ char name[30];
};
static int
-mgt_cli_close(const struct cli_port *cp)
+mgt_cli_callback(const struct ev *e, int what)
{
+ struct cli_port *cp;
+ char *p, *q;
+ int i;
+
+ CAST_OBJ_NOTNULL(cp, e->priv, CLI_PORT_MAGIC);
+
+ if (what & (EV_ERR | EV_HUP))
+ goto cli_close;
+
+ /* grow the buffer if it is full */
+ if (cp->nbuf == cp->lbuf) {
+ cp->lbuf += cp->lbuf;
+ cp->buf = realloc(cp->buf, cp->lbuf);
+ XXXAN(cp->buf);
+ }
+
+ /* read more data into the buffer */
+ i = read(cp->fdi, cp->buf + cp->nbuf, cp->lbuf - cp->nbuf);
+ if (i <= 0)
+ goto cli_close;
+ cp->nbuf += i;
+
+ for (p = q = cp->buf; q < cp->buf + cp->nbuf; ++q) {
+ if (*q != '\n')
+ continue;
+ /* got a newline == got a command */
+ *q = '\0';
+ vsb_clear(cp->cli->sb);
+ cli_dispatch(cp->cli, cli_proto, p);
+ vsb_finish(cp->cli->sb);
+
+ /* send the result back */
+ if (cli_writeres(cp->fdo, cp->cli))
+ goto cli_close;
- CHECK_OBJ_NOTNULL(cp, CLI_PORT_MAGIC);
- fprintf(stderr, "CLI closing: %s\n", cp->name);
+ /* ready for next command */
+ p = q + 1;
+ }
+
+ /* see if there's any data left in the buffer */
+ if (p != q) {
+ assert(q == cp->buf + cp->nbuf);
+ cp->nbuf -= (p - cp->buf);
+ memmove(cp->buf, p, cp->nbuf);
+ } else
+ cp->nbuf = 0;
+ return (0);
+
+cli_close:
vsb_delete(cp->cli->sb);
- VLU_Destroy(cp->vlu);
- free(cp->name);
+ free(cp->buf);
(void)close(cp->fdi);
if (cp->fdi == 0)
assert(open("/dev/null", O_RDONLY) == 0);
(void)close(cp->fdo);
if (cp->fdo == 1) {
assert(open("/dev/null", O_WRONLY) == 1);
- (void)close(2);
+ close(2);
assert(open("/dev/null", O_WRONLY) == 2);
}
+ free(cp);
return (1);
}
-static int
-mgt_cli_vlu(void *priv, const char *p)
-{
- struct cli_port *cp;
- char *q;
- unsigned u;
- int i;
-
- CAST_OBJ_NOTNULL(cp, priv, CLI_PORT_MAGIC);
- vsb_clear(cp->cli->sb);
- cli_dispatch(cp->cli, cli_proto, p);
- vsb_finish(cp->cli->sb);
- AZ(vsb_overflowed(cp->cli->sb));
- if (cp->cli->result == CLIS_UNKNOWN) {
- /*
- * Command not recognized in master, try cacher if it is
- * running.
- */
- vsb_clear(cp->cli->sb);
- cp->cli->result = CLIS_OK;
- if (cli_o <= 0) {
- cli_result(cp->cli, CLIS_UNKNOWN);
- cli_out(cp->cli,
- "Unknown request in manager process "
- "(child not running).\n"
- "Type 'help' for more info.");
- } else {
- i = write(cli_o, p, strlen(p));
- xxxassert(i == strlen(p));
- i = write(cli_o, "\n", 1);
- xxxassert(i == 1);
- i = cli_readres(cli_i, &u, &q, params->cli_timeout);
- cli_result(cp->cli, u);
- cli_out(cp->cli, "%s", q);
- free(q);
- }
- vsb_finish(cp->cli->sb);
- AZ(vsb_overflowed(cp->cli->sb));
- }
-
- /* send the result back */
- if (cli_writeres(cp->fdo, cp->cli))
- return (mgt_cli_close(cp));
- return (0);
-}
-
-static int
-mgt_cli_callback(const struct ev *e, int what)
-{
- struct cli_port *cp;
- int i;
-
- CAST_OBJ_NOTNULL(cp, e->priv, CLI_PORT_MAGIC);
-
- if (what & (EV_ERR | EV_HUP | EV_GONE))
- return (mgt_cli_close(cp));
-
- i = VLU_Fd(cp->fdi, cp->vlu);
- if (i != 0) {
- mgt_cli_close(cp);
- return (1);
- }
- return (0);
-}
-
void
-mgt_cli_setup(int fdi, int fdo, int verbose, const char *ident)
+mgt_cli_setup(int fdi, int fdo, int verbose)
{
struct cli_port *cp;
cp = calloc(sizeof *cp, 1);
XXXAN(cp);
- cp->vlu = VLU_New(cp, mgt_cli_vlu, params->cli_buffer);
- asprintf(&cp->name, "cli %s fds{%d,%d}", ident, fdi, fdo);
- XXXAN(cp->name);
- fprintf(stderr, "CLI opened: %s\n", cp->name);
+ sprintf(cp->name, "cli %d->%d", fdi, fdo);
cp->magic = CLI_PORT_MAGIC;
cp->fdi = fdi;
cp->fdo = fdo;
cp->verbose = verbose;
+ cp->lbuf = 4096;
+ cp->buf = malloc(cp->lbuf);
+ XXXAN(cp->buf);
+
cp->cli->sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND);
XXXAN(cp->cli->sb);
@@ -317,7 +389,7 @@
cp->ev->fd_flags = EV_RD;
cp->ev->callback = mgt_cli_callback;
cp->ev->priv = cp;
- AZ(ev_add(mgt_evb, cp->ev));
+ ev_add(mgt_evb, cp->ev);
}
static int
@@ -326,9 +398,6 @@
struct sockaddr_storage addr;
socklen_t addrlen;
int i;
- char abuf1[TCP_ADDRBUFSIZE], abuf2[TCP_ADDRBUFSIZE];
- char pbuf1[TCP_PORTBUFSIZE], pbuf2[TCP_PORTBUFSIZE];
- char *p;
(void)what;
addrlen = sizeof addr;
@@ -336,14 +405,7 @@
if (i < 0)
return (0);
- TCP_myname(ev->fd, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1);
- TCP_name((void*)&addr, addrlen, abuf2, sizeof abuf2,
- pbuf2, sizeof pbuf2);
- asprintf(&p, "telnet{%s:%s,%s:%s}", abuf2, pbuf2, abuf1, pbuf1);
- XXXAN(p);
-
- mgt_cli_setup(i, i, 0, p);
- free(p);
+ mgt_cli_setup(i, i, 0);
return (0);
}
@@ -355,7 +417,7 @@
int i, n;
XXXAZ(VSS_parse(T_arg, &addr, &port));
- n = VSS_resolve(addr, port, &ta);
+ XXXAN(n = VSS_resolve(addr, port, &ta));
free(addr);
free(port);
if (n == 0) {
@@ -369,7 +431,7 @@
ev->fd = sock;
ev->fd_flags = POLLIN;
ev->callback = telnet_accept;
- AZ(ev_add(mgt_evb, ev));
+ ev_add(mgt_evb, ev);
free(ta[i]);
ta[i] = NULL;
}
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/mgt_cli.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: mgt_cli.h 2415 2008-01-31 11:57:51Z des $
+ * $Id: mgt_cli.h 2496 2008-02-17 09:26:32Z des $
*/
/* mgt_child.c */
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/mgt_event.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: mgt_event.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: mgt_event.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
@@ -38,7 +38,6 @@
#include <signal.h>
#include <string.h>
#include <stdlib.h>
-#include <pthread.h>
#include "mgt.h"
#include "mgt_event.h"
@@ -71,7 +70,6 @@
unsigned char compact_pfd;
unsigned char disturbed;
unsigned psig;
- pthread_t thread;
};
/*--------------------------------------------------------------------*/
@@ -179,7 +177,6 @@
evb->magic = EVBASE_MAGIC;
VTAILQ_INIT(&evb->events);
evb->binheap = binheap_new(evb, ev_bh_cmp, ev_bh_update);
- evb->thread = pthread_self();
return (evb);
}
@@ -189,7 +186,6 @@
ev_destroy_base(struct evbase *evb)
{
CHECK_OBJ_NOTNULL(evb, EVBASE_MAGIC);
- assert(evb->thread == pthread_self());
evb->magic = 0;
free(evb);
}
@@ -221,7 +217,6 @@
assert(e->sig >= 0);
assert(e->timeout >= 0.0);
assert(e->fd < 0 || e->fd_flags);
- assert(evb->thread == pthread_self());
if (e->sig > 0 && ev_get_sig(e->sig))
return (ENOMEM);
@@ -288,7 +283,6 @@
CHECK_OBJ_NOTNULL(evb, EVBASE_MAGIC);
CHECK_OBJ_NOTNULL(e, EV_MAGIC);
assert(evb == e->__evb);
- assert(evb->thread == pthread_self());
if (e->__binheap_idx != 0)
binheap_delete(evb->binheap, e->__binheap_idx);
@@ -331,7 +325,6 @@
int i;
CHECK_OBJ_NOTNULL(evb, EVBASE_MAGIC);
- assert(evb->thread == pthread_self());
do
i = ev_schedule_one(evb);
while (i == 1);
@@ -418,7 +411,6 @@
struct pollfd *pfd;
CHECK_OBJ_NOTNULL(evb, EVBASE_MAGIC);
- assert(evb->thread == pthread_self());
e = binheap_root(evb->binheap);
if (e != NULL) {
CHECK_OBJ_NOTNULL(e, EV_MAGIC);
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/mgt_event.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: mgt_event.h 2415 2008-01-31 11:57:51Z des $
+ * $Id: mgt_event.h 2496 2008-02-17 09:26:32Z des $
*/
#include <poll.h>
@@ -50,7 +50,6 @@
#define EV_WR POLLOUT
#define EV_ERR POLLERR
#define EV_HUP POLLHUP
-#define EV_GONE POLLNVAL
#define EV_SIG -1
int sig;
unsigned sig_flags;
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/mgt_param.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: mgt_param.c 2560 2008-03-07 11:36:52Z phk $
+ * $Id: mgt_param.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
@@ -57,14 +57,11 @@
struct parspec;
-typedef void tweak_t(struct cli *, const struct parspec *, const char *arg);
+typedef void tweak_t(struct cli *, struct parspec *, const char *arg);
struct parspec {
const char *name;
tweak_t *func;
- volatile void *priv;
- unsigned umin;
- unsigned umax;
const char *descr;
int flags;
#define DELAYED_EFFECT 1
@@ -99,18 +96,6 @@
/*--------------------------------------------------------------------*/
static void
-tweak_timeout(struct cli *cli, const struct parspec *par, const char *arg)
-{
- volatile unsigned *dest;
-
- dest = par->priv;
- tweak_generic_timeout(cli, dest, arg);
-}
-
-
-/*--------------------------------------------------------------------*/
-
-static void
tweak_generic_bool(struct cli *cli, volatile unsigned *dest, const char *arg)
{
if (arg != NULL) {
@@ -138,17 +123,6 @@
/*--------------------------------------------------------------------*/
static void
-tweak_bool(struct cli *cli, const struct parspec *par, const char *arg)
-{
- volatile unsigned *dest;
-
- dest = par->priv;
- tweak_generic_bool(cli, dest, arg);
-}
-
-/*--------------------------------------------------------------------*/
-
-static void
tweak_generic_uint(struct cli *cli, volatile unsigned *dest, const char *arg, unsigned min, unsigned max)
{
unsigned u;
@@ -159,12 +133,12 @@
else
u = strtoul(arg, NULL, 0);
if (u < min) {
- cli_out(cli, "Must be at least %u\n", min);
+ cli_out(cli, "Must be at least %u", min);
cli_result(cli, CLIS_PARAM);
return;
}
if (u > max) {
- cli_out(cli, "Must be no more than %u\n", max);
+ cli_out(cli, "Must be no more than %u", max);
cli_result(cli, CLIS_PARAM);
return;
}
@@ -176,17 +150,6 @@
}
}
-/*--------------------------------------------------------------------*/
-
-static void
-tweak_uint(struct cli *cli, const struct parspec *par, const char *arg)
-{
- volatile unsigned *dest;
-
- dest = par->priv;
- tweak_generic_uint(cli, dest, arg, par->umin, par->umax);
-}
-
/*--------------------------------------------------------------------
* XXX: slightly magic. We want to initialize to "nobody" (XXX: shouldn't
* XXX: that be something autocrap found for us ?) but we don't want to
@@ -196,7 +159,7 @@
*/
static void
-tweak_user(struct cli *cli, const struct parspec *par, const char *arg)
+tweak_user(struct cli *cli, struct parspec *par, const char *arg)
{
struct passwd *pw;
struct group *gr;
@@ -237,7 +200,7 @@
*/
static void
-tweak_group(struct cli *cli, const struct parspec *par, const char *arg)
+tweak_group(struct cli *cli, struct parspec *par, const char *arg)
{
struct group *gr;
@@ -270,7 +233,29 @@
/*--------------------------------------------------------------------*/
static void
-tweak_thread_pool_min(struct cli *cli, const struct parspec *par, const char *arg)
+tweak_default_ttl(struct cli *cli, struct parspec *par, const char *arg)
+{
+
+ (void)par;
+ tweak_generic_uint(cli, &master.default_ttl, arg, 0, UINT_MAX);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+tweak_thread_pools(struct cli *cli, struct parspec *par, const char *arg)
+{
+
+ (void)par;
+ tweak_generic_uint(cli, &master.wthread_pools, arg,
+ 1, UINT_MAX);
+}
+
+
+/*--------------------------------------------------------------------*/
+
+static void
+tweak_thread_pool_min(struct cli *cli, struct parspec *par, const char *arg)
{
(void)par;
@@ -281,7 +266,7 @@
/*--------------------------------------------------------------------*/
static void
-tweak_thread_pool_max(struct cli *cli, const struct parspec *par, const char *arg)
+tweak_thread_pool_max(struct cli *cli, struct parspec *par, const char *arg)
{
(void)par;
@@ -292,6 +277,115 @@
/*--------------------------------------------------------------------*/
static void
+tweak_thread_pool_timeout(struct cli *cli, struct parspec *par, const char *arg)
+{
+
+ (void)par;
+ tweak_generic_timeout(cli, &master.wthread_timeout, arg);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+tweak_overflow_max(struct cli *cli, struct parspec *par, const char *arg)
+{
+
+ (void)par;
+ tweak_generic_uint(cli, &master.overflow_max, arg, 0, UINT_MAX);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+tweak_http_workspace(struct cli *cli, struct parspec *par, const char *arg)
+{
+
+ (void)par;
+ tweak_generic_uint(cli, &master.mem_workspace, arg,
+ 1024, UINT_MAX);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+tweak_sess_timeout(struct cli *cli, struct parspec *par, const char *arg)
+{
+ (void)par;
+ tweak_generic_timeout(cli, &master.sess_timeout, arg);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+tweak_pipe_timeout(struct cli *cli, struct parspec *par, const char *arg)
+{
+ (void)par;
+ tweak_generic_timeout(cli, &master.pipe_timeout, arg);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+tweak_send_timeout(struct cli *cli, struct parspec *par, const char *arg)
+{
+ (void)par;
+ tweak_generic_timeout(cli, &master.send_timeout, arg);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+tweak_lru_timeout(struct cli *cli, struct parspec *par, const char *arg)
+{
+ (void)par;
+ tweak_generic_timeout(cli, &master.lru_timeout, arg);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+tweak_auto_restart(struct cli *cli, struct parspec *par, const char *arg)
+{
+
+ (void)par;
+ tweak_generic_bool(cli, &master.auto_restart, arg);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+tweak_fetch_chunksize(struct cli *cli, struct parspec *par, const char *arg)
+{
+
+ (void)par;
+ tweak_generic_uint(cli, &master.fetch_chunksize, arg,
+ 4, UINT_MAX / 1024);
+}
+
+#ifdef HAVE_SENDFILE
+/*--------------------------------------------------------------------*/
+
+static void
+tweak_sendfile_threshold(struct cli *cli, struct parspec *par, const char *arg)
+{
+
+ (void)par;
+ tweak_generic_uint(cli, &master.sendfile_threshold, arg, 0, UINT_MAX);
+}
+#endif /* HAVE_SENDFILE */
+
+/*--------------------------------------------------------------------*/
+
+static void
+tweak_vcl_trace(struct cli *cli, struct parspec *par, const char *arg)
+{
+ (void)par;
+ tweak_generic_bool(cli, &master.vcl_trace, arg);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
clean_listen_sock_head(struct listen_sock_head *lsh)
{
struct listen_sock *ls, *ls2;
@@ -304,7 +398,7 @@
}
static void
-tweak_listen_address(struct cli *cli, const struct parspec *par, const char *arg)
+tweak_listen_address(struct cli *cli, struct parspec *par, const char *arg)
{
char **av;
int i;
@@ -384,7 +478,70 @@
/*--------------------------------------------------------------------*/
static void
-tweak_cc_command(struct cli *cli, const struct parspec *par, const char *arg)
+tweak_listen_depth(struct cli *cli, struct parspec *par, const char *arg)
+{
+ (void)par;
+ tweak_generic_uint(cli, &master.listen_depth, arg, 0, UINT_MAX);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+tweak_srcaddr_hash(struct cli *cli, struct parspec *par, const char *arg)
+{
+ (void)par;
+ tweak_generic_uint(cli, &master.srcaddr_hash, arg, 63, UINT_MAX);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+tweak_srcaddr_ttl(struct cli *cli, struct parspec *par, const char *arg)
+{
+ (void)par;
+ tweak_generic_uint(cli, &master.srcaddr_ttl, arg, 0, UINT_MAX);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+tweak_backend_http11(struct cli *cli, struct parspec *par, const char *arg)
+{
+ (void)par;
+ tweak_generic_bool(cli, &master.backend_http11, arg);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+tweak_client_http11(struct cli *cli, struct parspec *par, const char *arg)
+{
+ (void)par;
+ tweak_generic_bool(cli, &master.client_http11, arg);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+tweak_cli_timeout(struct cli *cli, struct parspec *par, const char *arg)
+{
+ (void)par;
+ tweak_generic_timeout(cli, &master.cli_timeout, arg);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+tweak_ping_interval(struct cli *cli, struct parspec *par, const char *arg)
+{
+ (void)par;
+ tweak_generic_uint(cli, &master.ping_interval, arg, 0, UINT_MAX);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+tweak_cc_command(struct cli *cli, struct parspec *par, const char *arg)
{
/* XXX should have tweak_generic_string */
@@ -398,20 +555,12 @@
}
}
-/*--------------------------------------------------------------------*/
-
static void
-tweak_diag_bitmap(struct cli *cli, const struct parspec *par, const char *arg)
+tweak_max_restarts(struct cli *cli, struct parspec *par, const char *arg)
{
- unsigned u;
(void)par;
- if (arg != NULL) {
- u = strtoul(arg, NULL, 0);
- master.diag_bitmap = u;
- } else {
- cli_out(cli, "0x%x", master.diag_bitmap);
- }
+ tweak_generic_uint(cli, &master.max_restarts, arg, 0, UINT_MAX);
}
/*--------------------------------------------------------------------*/
@@ -440,17 +589,17 @@
* Remember to update varnishd.1 whenever you add / remove a parameter or
* change its default value.
*/
-static const struct parspec parspec[] = {
- { "user", tweak_user, NULL, 0, 0,
+static struct parspec parspec[] = {
+ { "user", tweak_user,
"The unprivileged user to run as. Setting this will "
"also set \"group\" to the specified user's primary group.",
MUST_RESTART,
MAGIC_INIT_STRING },
- { "group", tweak_group, NULL, 0, 0,
+ { "group", tweak_group,
"The unprivileged group to run as.",
MUST_RESTART,
MAGIC_INIT_STRING },
- { "default_ttl", tweak_uint, &master.default_ttl, 0, UINT_MAX,
+ { "default_ttl", tweak_default_ttl,
"The TTL assigned to objects if neither the backend nor "
"the VCL code assigns one.\n"
"Objects already cached will not be affected by changes "
@@ -459,7 +608,7 @@
"flush of the cache use \"url.purge .\"",
0,
"120", "seconds" },
- { "thread_pools", tweak_uint, &master.wthread_pools, 1, UINT_MAX,
+ { "thread_pools", tweak_thread_pools,
"Number of worker pools. "
"Increasing number of worker pools decreases lock "
"contention but increases the number of threads as well. "
@@ -467,74 +616,57 @@
"restart to take effect.",
EXPERIMENTAL,
"1", "pools" },
- { "thread_pool_max", tweak_thread_pool_max, NULL, 0, 0,
+ { "thread_pool_max", tweak_thread_pool_max,
"The maximum number of threads in the total worker pool.\n"
"-1 is unlimited.",
EXPERIMENTAL | DELAYED_EFFECT,
"1000", "threads" },
- { "thread_pool_min", tweak_thread_pool_min, NULL, 0, 0,
+ { "thread_pool_min", tweak_thread_pool_min,
"The minimum number of threads in the worker pool.\n"
"Minimum is 1 thread.",
EXPERIMENTAL | DELAYED_EFFECT,
"1", "threads" },
- { "thread_pool_timeout", tweak_timeout, &master.wthread_timeout, 0, 0,
+ { "thread_pool_timeout", tweak_thread_pool_timeout,
"Thread dies after this many seconds of inactivity.\n"
"Minimum is 1 second.",
EXPERIMENTAL | DELAYED_EFFECT,
"120", "seconds" },
- { "overflow_max", tweak_uint, &master.overflow_max, 0, UINT_MAX,
+ { "overflow_max", tweak_overflow_max,
"Limit on overflow queue length in percent of "
"thread_pool_max parameter.",
EXPERIMENTAL,
"100", "%" },
- { "rush_exponent", tweak_uint, &master.rush_exponent, 2, UINT_MAX,
- "How many parked request we start for each completed "
- "request on the object.\n"
- "NB: Even with the implict delay of delivery, "
- "this parameter controls an exponential increase in "
- "number of worker threads. ",
- EXPERIMENTAL,
- "3", "requests per request" },
- { "sess_workspace", tweak_uint, &master.sess_workspace, 1024, UINT_MAX,
- "Bytes of HTTP protocol workspace allocated for sessions. "
+ { "http_workspace", tweak_http_workspace,
+ "Bytes of HTTP protocol workspace allocated. "
"This space must be big enough for the entire HTTP protocol "
"header and any edits done to it in the VCL code.\n"
"Minimum is 1024 bytes.",
DELAYED_EFFECT,
"8192", "bytes" },
- { "obj_workspace", tweak_uint, &master.obj_workspace, 1024, UINT_MAX,
- "Bytes of HTTP protocol workspace allocated for objects. "
- "This space must be big enough for the entire HTTP protocol "
- "header and any edits done to it in the VCL code while it "
- "is cached.\n"
- "Minimum is 1024 bytes.",
- DELAYED_EFFECT,
- "8192", "bytes" },
- { "sess_timeout", tweak_timeout, &master.sess_timeout, 0, 0,
+ { "sess_timeout", tweak_sess_timeout,
"Idle timeout for persistent sessions. "
"If a HTTP request has not been received in this many "
"seconds, the session is closed.",
0,
"5", "seconds" },
- { "pipe_timeout", tweak_timeout, &master.pipe_timeout, 0, 0,
+ { "pipe_timeout", tweak_pipe_timeout,
"Idle timeout for PIPE sessions. "
"If nothing have been received in either direction for "
"this many seconds, the session is closed.\n",
0,
"60", "seconds" },
- { "send_timeout", tweak_timeout, &master.send_timeout, 0, 0,
+ { "send_timeout", tweak_send_timeout,
"Send timeout for client connections. "
"If no data has been sent to the client in this many seconds, "
"the session is closed.\n"
"See setsockopt(2) under SO_SNDTIMEO for more information.",
DELAYED_EFFECT,
"600", "seconds" },
- { "auto_restart", tweak_bool, &master.auto_restart, 0, 0,
+ { "auto_restart", tweak_auto_restart,
"Restart child process automatically if it dies.\n",
0,
"on", "bool" },
- { "fetch_chunksize",
- tweak_uint, &master.fetch_chunksize, 4, UINT_MAX / 1024,
+ { "fetch_chunksize", tweak_fetch_chunksize,
"The default chunksize used by fetcher. "
"This should be bigger than the majority of objects with "
"short TTLs.\n"
@@ -542,14 +674,13 @@
"above 128kb a dubious idea.",
EXPERIMENTAL,
"128", "kilobytes" },
-#ifdef SENDFILE_WORKS
- { "sendfile_threshold",
- tweak_uint, &master.sendfile_threshold, 0, UINT_MAX,
+#ifdef HAVE_SENDFILE
+ { "sendfile_threshold", tweak_sendfile_threshold,
"The minimum size of objects transmitted with sendfile.",
EXPERIMENTAL,
"-1", "bytes" },
-#endif /* SENDFILE_WORKS */
- { "vcl_trace", tweak_bool, &master.vcl_trace, 0, 0,
+#endif /* HAVE_SENDFILE */
+ { "vcl_trace", tweak_vcl_trace,
"Trace VCL execution in the shmlog.\n"
"Enabling this will allow you to see the path each "
"request has taken through the VCL program.\n"
@@ -557,50 +688,50 @@
"default.",
0,
"off", "bool" },
- { "listen_address", tweak_listen_address, NULL, 0, 0,
+ { "listen_address", tweak_listen_address,
"Whitespace separated list of network endpoints where "
"Varnish will accept requests.\n"
"Possible formats: host, host:port, :port",
MUST_RESTART,
":80" },
- { "listen_depth", tweak_uint, &master.listen_depth, 0, UINT_MAX,
+ { "listen_depth", tweak_listen_depth,
"Listen queue depth.",
MUST_RESTART,
"1024", "connections" },
- { "srcaddr_hash", tweak_uint, &master.srcaddr_hash, 63, UINT_MAX,
+ { "srcaddr_hash", tweak_srcaddr_hash,
"Number of source address hash buckets.\n"
"Powers of two are bad, prime numbers are good.",
EXPERIMENTAL | MUST_RESTART,
"1049", "buckets" },
- { "srcaddr_ttl", tweak_uint, &master.srcaddr_ttl, 0, UINT_MAX,
+ { "srcaddr_ttl", tweak_srcaddr_ttl,
"Lifetime of srcaddr entries.\n"
"Zero will disable srcaddr accounting entirely.",
EXPERIMENTAL,
"30", "seconds" },
- { "backend_http11", tweak_bool, &master.backend_http11, 0, 0,
+ { "backend_http11", tweak_backend_http11,
"Force all backend requests to be HTTP/1.1.\n"
"By default we copy the protocol version from the "
"incoming client request.",
EXPERIMENTAL,
"off", "bool" },
- { "client_http11", tweak_bool, &master.client_http11, 0, 0,
+ { "client_http11", tweak_client_http11,
"Force all client responses to be HTTP/1.1.\n"
"By default we copy the protocol version from the "
"backend response.",
EXPERIMENTAL,
"off", "bool" },
- { "cli_timeout", tweak_timeout, &master.cli_timeout, 0, 0,
+ { "cli_timeout", tweak_cli_timeout,
"Timeout for the childs replies to CLI requests from "
"the master.",
0,
"5", "seconds" },
- { "ping_interval", tweak_uint, &master.ping_interval, 0, UINT_MAX,
+ { "ping_interval", tweak_ping_interval,
"Interval between pings from parent to child.\n"
"Zero will disable pinging entirely, which makes "
"it possible to attach a debugger to the child.",
MUST_RESTART,
"3", "seconds" },
- { "lru_interval", tweak_timeout, &master.lru_timeout, 0, 0,
+ { "lru_interval", tweak_lru_timeout,
"Grace period before object moves on LRU list.\n"
"Objects are only moved to the front of the LRU "
"list if they have not been moved there already inside "
@@ -608,7 +739,7 @@
"operations necessary for LRU list access.",
EXPERIMENTAL,
"2", "seconds" },
- { "cc_command", tweak_cc_command, NULL, 0, 0,
+ { "cc_command", tweak_cc_command,
"Command used for compiling the C source code to a "
"dlopen(3) loadable object. Any occurrence of %s in "
"the string will be replaced with the source file name, "
@@ -620,42 +751,15 @@
"exec cc -fpic -shared -Wl,-x -o %o %s"
#endif
, NULL },
- { "max_restarts", tweak_uint, &master.max_restarts, 0, UINT_MAX,
+ { "max_restarts", tweak_max_restarts,
"Upper limit on how many times a request can restart."
+#ifdef NOT_YET
+ " ESI:include counts as a restart in this context."
+#endif
"\nBe aware that restarts are likely to cause a hit against "
"the backend, so don't increase thoughtlessly.\n",
0,
"4", "restarts" },
- { "max_esi_includes",
- tweak_uint, &master.max_esi_includes, 0, UINT_MAX,
- "Maximum depth of esi:include processing."
- "\nBe aware that restarts are likely to cause a hit against "
- "the backend, so don't increase thoughtlessly.\n",
- 0,
- "5", "restarts" },
- { "cache_vbe_conns", tweak_bool, &master.cache_vbe_conns, 0, 0,
- "Cache vbe_conn's or rely on malloc, that's the question.",
- EXPERIMENTAL,
- "off", "bool" },
- { "cli_buffer", tweak_uint, &master.cli_buffer, 4096, UINT_MAX,
- "Size of buffer for CLI input."
- "\nYou may need to increase this if you have big VCL files "
- "and use the vcl.inline CLI command.\n"
- "NB: Must be specified with -p to have effect.\n",
- 0,
- "8192", "bytes" },
- { "diag_bitmap", tweak_diag_bitmap, 0, 0, 0,
- "Bitmap controlling diagnostics code:\n"
- " 0x00000001 - CNT_Session states.\n"
- " 0x00000002 - workspace debugging.\n"
- " 0x00000004 - kqueue debugging.\n"
- " 0x00000008 - mutex logging.\n"
- " 0x00000010 - mutex contests.\n"
- " 0x00000020 - waiting list.\n"
- " 0x00000040 - object workspace.\n"
- "Use 0x notation and do the bitor in your head :-)\n",
- 0,
- "0", "bitmap" },
{ NULL, NULL, NULL }
};
@@ -690,7 +794,7 @@
void
mcf_param_show(struct cli *cli, const char * const *av, void *priv)
{
- const struct parspec *pp;
+ struct parspec *pp;
int lfmt;
(void)priv;
@@ -752,19 +856,17 @@
void
MCF_ParamSet(struct cli *cli, const char *param, const char *val)
{
- const struct parspec *pp;
+ struct parspec *pp;
for (pp = parspec; pp->name != NULL; pp++) {
if (!strcmp(pp->name, param)) {
pp->func(cli, pp, val);
- if (cli->result != CLIS_OK) {
- } else if (child_pid >= 0 && pp->flags & MUST_RESTART) {
- cli_out(cli, "Change will take effect"
+ if (pp->flags & MUST_RESTART)
+ cli_out(cli, "change will take effect"
" when child is restarted");
- } else if (pp->flags & MUST_RELOAD) {
- cli_out(cli, "Change will take effect"
+ if (pp->flags & MUST_RELOAD)
+ cli_out(cli, "change will take effect"
" when VCL script is reloaded");
- }
MCF_ParamSync();
return;
}
@@ -789,7 +891,7 @@
void
MCF_ParamInit(struct cli *cli)
{
- const struct parspec *pp;
+ struct parspec *pp;
for (pp = parspec; pp->name != NULL; pp++) {
cli_out(cli, "Set Default for %s = %s\n", pp->name, pp->def);
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/mgt_vcc.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: mgt_vcc.c 2613 2008-03-31 11:47:15Z phk $
+ * $Id: mgt_vcc.c 2564 2008-03-08 13:38:23Z des $
*
* VCL compiler stuff
*/
@@ -79,26 +79,13 @@
*/
static const char *default_vcl =
"sub vcl_recv {\n"
- " if (req.request != \"GET\" &&\n"
- " req.request != \"HEAD\" &&\n"
- " req.request != \"PUT\" &&\n"
- " req.request != \"POST\" &&\n"
- " req.request != \"TRACE\" &&\n"
- " req.request != \"OPTIONS\" &&\n"
- " req.request != \"DELETE\") {\n"
- " /* Non-RFC2616 or CONNECT which is weird. */\n"
+ " if (req.request != \"GET\" && req.request != \"HEAD\") {\n"
" pipe;\n"
" }\n"
" if (req.http.Expect) {\n"
- " /* Expect is just too hard at present. */\n"
" pipe;\n"
" }\n"
- " if (req.request != \"GET\" && req.request != \"HEAD\") {\n"
- " /* We only deal with GET and HEAD by default */\n"
- " pass;\n"
- " }\n"
- " if (req.http.Authorization || req.http.Cookie) {\n"
- " /* Not cacheable by default */\n"
+ " if (req.http.Authenticate || req.http.Cookie) {\n"
" pass;\n"
" }\n"
" lookup;\n"
@@ -143,7 +130,6 @@
" if (obj.http.Set-Cookie) {\n"
" pass;\n"
" }\n"
- " set obj.prefetch = -30s;"
" insert;\n"
"}\n"
"sub vcl_deliver {\n"
@@ -152,9 +138,6 @@
"sub vcl_discard {\n"
" discard;\n"
"}\n"
- "sub vcl_prefetch {\n"
- " fetch;\n"
- "}\n"
"sub vcl_timeout {\n"
" discard;\n"
"}\n";
@@ -236,49 +219,45 @@
of = strdup(sf);
XXXAN(of);
of[sizeof sf - 2] = 'o';
- AN(vsb_new(&cmdsb, cmdline, sizeof cmdline, 0));
+ vsb_new(&cmdsb, cmdline, sizeof cmdline, 0);
mgt_make_cc_cmd(&cmdsb, sf, of);
vsb_finish(&cmdsb);
- AZ(vsb_overflowed(&cmdsb));
/* XXX check vsb state */
if (pipe(p) < 0) {
vsb_printf(sb, "%s(): pipe() failed: %s",
__func__, strerror(errno));
- (void)unlink(sf);
+ unlink(sf);
free(of);
return (NULL);
}
if ((pid = fork()) < 0) {
vsb_printf(sb, "%s(): fork() failed: %s",
__func__, strerror(errno));
- AZ(close(p[0]));
- AZ(close(p[1]));
- (void)unlink(sf);
+ close(p[0]);
+ close(p[1]);
+ unlink(sf);
free(of);
return (NULL);
}
if (pid == 0) {
- AZ(close(p[0]));
- AZ(close(STDIN_FILENO));
+ close(p[0]);
+ close(STDIN_FILENO);
assert(open("/dev/null", O_RDONLY) == STDIN_FILENO);
assert(dup2(p[1], STDOUT_FILENO) == STDOUT_FILENO);
assert(dup2(p[1], STDERR_FILENO) == STDERR_FILENO);
- (void)execl("/bin/sh", "/bin/sh", "-c", cmdline, NULL);
+ execl("/bin/sh", "/bin/sh", "-c", cmdline, NULL);
_exit(1);
}
- AZ(close(p[1]));
- do {
- status = read(p[0], buf, sizeof buf);
- if (status > 0)
- vsb_printf(sb, "C-Compiler said: %.*s", status, buf);
- } while (status > 0);
- AZ(close(p[0]));
- (void)unlink(sf);
+ close(p[1]);
+ while (read(p[0], buf, sizeof buf) > 0)
+ /* XXX nothing */ ;
+ close(p[0]);
+ unlink(sf);
if (waitpid(pid, &status, 0) < 0) {
vsb_printf(sb, "%s(): waitpid() failed: %s",
__func__, strerror(errno));
- (void)unlink(of);
+ unlink(of);
free(of);
return (NULL);
}
@@ -290,7 +269,7 @@
vsb_printf(sb, ", signal %d", WTERMSIG(status));
if (WCOREDUMP(status))
vsb_printf(sb, ", core dumped");
- (void)unlink(of);
+ unlink(of);
free(of);
return (NULL);
}
@@ -298,9 +277,9 @@
/* Next, try to load the object into the management process */
if ((dlh = dlopen(of, RTLD_NOW | RTLD_LOCAL)) == NULL) {
vsb_printf(sb,
- "%s(): failed to load compiled VCL program:\n %s",
+ "%s(): failed to load compiled VCL program: %s",
__func__, dlerror());
- (void)unlink(of);
+ unlink(of);
free(of);
return (NULL);
}
@@ -341,7 +320,7 @@
csrc = VCC_CompileFile(sb, fn, fd);
if (csrc != NULL) {
if (C_flag)
- (void)fputs(csrc, stdout);
+ fputs(csrc, stdout);
vf = mgt_run_cc(csrc, sb);
if (C_flag && vf != NULL)
AZ(unlink(vf));
@@ -423,15 +402,14 @@
*/
free(port);
fprintf(stderr, "invalid backend address\n");
- vsb_delete(sb);
return (1);
}
buf = NULL;
asprintf(&buf,
"backend default {\n"
- " .host = \"%s\";\n"
- " .port = \"%s\";\n"
+ " set backend.host = \"%s\";\n"
+ " set backend.port = \"%s\";\n"
"}\n", addr, port ? port : "http");
free(addr);
free(port);
@@ -442,16 +420,14 @@
vf = mgt_VccCompileFile(sb, f_arg, C_flag, f_fd);
}
vsb_finish(sb);
- AZ(vsb_overflowed(sb));
- if (vsb_len(sb) > 0)
+ if (vsb_len(sb) > 0) {
fprintf(stderr, "%s", vsb_data(sb));
+ vsb_delete(sb);
+ return (1);
+ }
vsb_delete(sb);
if (C_flag)
return (0);
- if (vf == NULL) {
- fprintf(stderr, "\nVCL compilation failed\n");
- return (1);
- }
vp = mgt_vcc_add("boot", vf);
vp->active = 1;
return (0);
@@ -514,7 +490,7 @@
void
mcf_config_inline(struct cli *cli, const char * const *av, void *priv)
{
- char *vf, *p = NULL;
+ char *vf, *p;
struct vsb *sb;
unsigned status;
@@ -524,24 +500,21 @@
XXXAN(sb);
vf = mgt_VccCompile(sb, av[3], NULL, 0);
vsb_finish(sb);
- AZ(vsb_overflowed(sb));
- if (vsb_len(sb) > 0)
+ if (vsb_len(sb) > 0) {
cli_out(cli, "%s", vsb_data(sb));
- vsb_delete(sb);
- if (vf == NULL) {
- cli_out(cli, "VCL compilation failed");
+ vsb_delete(sb);
cli_result(cli, CLIS_PARAM);
return;
}
- cli_out(cli, "VCL compiled.");
+ vsb_delete(sb);
if (child_pid >= 0 &&
mgt_cli_askchild(&status, &p, "vcl.load %s %s\n", av[2], vf)) {
cli_result(cli, status);
cli_out(cli, "%s", p);
- } else {
- (void)mgt_vcc_add(av[2], vf);
+ free(p);
+ return;
}
- free(p);
+ (void)mgt_vcc_add(av[2], vf);
}
void
@@ -550,7 +523,7 @@
char *vf;
struct vsb *sb;
unsigned status;
- char *p = NULL;
+ char *p;
(void)priv;
@@ -558,24 +531,21 @@
XXXAN(sb);
vf = mgt_VccCompileFile(sb, av[3], 0, -1);
vsb_finish(sb);
- AZ(vsb_overflowed(sb));
- if (vsb_len(sb) > 0)
+ if (vsb_len(sb) > 0) {
cli_out(cli, "%s", vsb_data(sb));
- vsb_delete(sb);
- if (vf == NULL) {
- cli_out(cli, "VCL compilation failed");
+ vsb_delete(sb);
cli_result(cli, CLIS_PARAM);
return;
}
- cli_out(cli, "VCL compiled.");
+ vsb_delete(sb);
if (child_pid >= 0 &&
mgt_cli_askchild(&status, &p, "vcl.load %s %s\n", av[2], vf)) {
cli_result(cli, status);
cli_out(cli, "%s", p);
- } else {
- (void)mgt_vcc_add(av[2], vf);
+ free(p);
+ return;
}
- free(p);
+ (void)mgt_vcc_add(av[2], vf);
}
static struct vclprog *
@@ -585,46 +555,46 @@
VTAILQ_FOREACH(vp, &vclhead, list)
if (!strcmp(vp->name, name))
- return (vp);
- cli_result(cli, CLIS_PARAM);
- cli_out(cli, "No configuration named %s known.", name);
- return (NULL);
+ break;
+ if (vp == NULL) {
+ cli_result(cli, CLIS_PARAM);
+ cli_out(cli, "No configuration named %s known.", name);
+ }
+ return (vp);
}
void
mcf_config_use(struct cli *cli, const char * const *av, void *priv)
{
unsigned status;
- char *p = NULL;
+ char *p;
struct vclprog *vp;
(void)priv;
vp = mcf_find_vcl(cli, av[2]);
- if (vp == NULL)
- return;
- if (vp->active != 0)
- return;
- if (child_pid >= 0 &&
- mgt_cli_askchild(&status, &p, "vcl.use %s\n", av[2])) {
- cli_result(cli, status);
- cli_out(cli, "%s", p);
- } else {
- vp->active = 2;
- VTAILQ_FOREACH(vp, &vclhead, list) {
- if (vp->active == 1)
- vp->active = 0;
- else if (vp->active == 2)
- vp->active = 1;
+ if (vp != NULL && vp->active == 0) {
+ if (child_pid >= 0 &&
+ mgt_cli_askchild(&status, &p, "vcl.use %s\n", av[2])) {
+ cli_result(cli, status);
+ cli_out(cli, "%s", p);
+ free(p);
+ } else {
+ vp->active = 2;
+ VTAILQ_FOREACH(vp, &vclhead, list) {
+ if (vp->active == 1)
+ vp->active = 0;
+ else if (vp->active == 2)
+ vp->active = 1;
+ }
}
}
- free(p);
}
void
mcf_config_discard(struct cli *cli, const char * const *av, void *priv)
{
unsigned status;
- char *p = NULL;
+ char *p;
struct vclprog *vp;
(void)priv;
@@ -638,11 +608,11 @@
"vcl.discard %s\n", av[2])) {
cli_result(cli, status);
cli_out(cli, "%s", p);
+ free(p);
} else {
AZ(mgt_vcc_delbyname(av[2]));
}
}
- free(p);
}
void
@@ -655,10 +625,9 @@
(void)av;
(void)priv;
if (child_pid >= 0) {
- if (!mgt_cli_askchild(&status, &p, "vcl.list\n")) {
- cli_result(cli, status);
- cli_out(cli, "%s", p);
- }
+ mgt_cli_askchild(&status, &p, "vcl.list\n");
+ cli_result(cli, status);
+ cli_out(cli, "%s", p);
free(p);
} else {
VTAILQ_FOREACH(vp, &vclhead, list) {
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/rfc2616.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: rfc2616.c 2515 2008-02-19 11:52:27Z phk $
+ * $Id: rfc2616.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
@@ -39,6 +39,7 @@
#include "shmlog.h"
#include "cache.h"
+#include "heritage.h"
/*--------------------------------------------------------------------
|
[-]
[+]
|
Deleted |
varnish-20080428.tar.bz2/bin/varnishd/s.sh
^
|
@@ -1,82 +0,0 @@
-#!/bin/sh
-
-# A server side test-script for pushing the ESI XML parser over a
-# storage boundary.
-# The crucial trick here is that we send these objects HTTP/0.9 style
-# so that cache_fetch puts the first 128k in one storage object and
-# the rest in another, thus by putting around 128K space in our test
-# data we can put it right before, over and after the storage boundary.
-#
-# Use c.sh as the client side, and run varnish with this vcl:
-#
-# backend b1 {
-# set backend.host = "Localhost";
-# set backend.port = "8081";
-# }
-#
-# sub vcl_recv {
-# pass;
-# }
-#
-# sub vcl_fetch {
-# esi;
-# }
-
-serve () (
- (
- echo 'HTTP/1.0 200 OK'
- echo ''
- echo "$1"
- dd if=/dev/zero bs=$2 count=1 2>/dev/null | tr '\0' ' '
- cat
- sleep .1
- ) | nc -l 8081
-)
-
-
-
-if false ; then
- echo -n "<esi:remove> foo </esi:remove> bar" | serve Test01 1
- echo -n "<esi:remove> foo </esi:remove> bar" | serve Test02 2
- # Unterminated CDATA
- echo -n "<esi:remove> foo </esi:remove> { <![CDATA[foo]] }" | serve Test03 10
-
- for i in `jot 40 131020`
- do
- echo -n "<esi:remove> foo </esi:remove> bar" | serve Test04::$i $i
- done
-
- for i in `jot 40 131036`
- do
- echo -n "<!--esi foo --> bar" | serve Test05::$i $i
- done
-
- for i in `jot 22 131040`
- do
- echo -n "<![CDATA[foo]]>" | serve Test06::$i $i
- done
-
- echo -n "<esi:remove> " | serve Test07 10
-
- echo -n "<!--esi " | serve Test08 10
-
- for i in `jot 10 131042`
- do
- echo -n " > " | serve "Test09:$i <esi:remove" $i
- done
-
- (
- echo -n "<esi:remove "
- dd if=/dev/zero bs=32768 count=1 2>/dev/null | tr '\0' ' '
- echo -n ">"
- ) | serve "Test10" 131030
-
- echo -n " ]]> " | serve "Test11:131048 <![CDATA[ " 131048
- echo -n " bar" | serve "Test12 foo <esi:comment comment=\"Humbug!\"/> " 1
- echo -n " bar" | serve "Test13 foo <esi:foo> " 1
-fi
-
-while true
-do
- echo -n " <esi:say "Hi Mom">" | serve "Test13 foo <esi:foo> " 1
-done
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/shmlog.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: shmlog.c 2604 2008-03-13 10:34:30Z phk $
+ * $Id: shmlog.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
@@ -43,6 +43,8 @@
#include "shmlog.h"
#include "cache.h"
+#include "heritage.h"
+
#define LOCKSHM(foo) \
do { \
if (pthread_mutex_trylock(foo)) { \
@@ -77,17 +79,16 @@
}
static void
-vsl_hdr(enum shmlogtag tag, unsigned char *p, unsigned len, unsigned id)
+vsl_hdr(enum shmlogtag tag, unsigned char *p, unsigned len, int id)
{
- p[__SHMLOG_LEN_HIGH] = (len >> 8) & 0xff;
- p[__SHMLOG_LEN_LOW] = len & 0xff;
- p[__SHMLOG_ID_HIGH] = (id >> 8) & 0xff;
- p[__SHMLOG_ID_LOW] = id & 0xff;
- p[SHMLOG_DATA + len] = '\0';
- p[SHMLOG_NEXTTAG + len] = SLT_ENDMARKER;
+ p[1] = len & 0xff;
+ p[2] = (id >> 8) & 0xff;
+ p[3] = id & 0xff;
+ p[4 + len] = '\0';
+ p[5 + len] = SLT_ENDMARKER;
/* XXX: Write barrier here */
- p[SHMLOG_TAG] = tag;
+ p[0] = tag;
}
/*--------------------------------------------------------------------
@@ -95,7 +96,7 @@
* taking the detour over sprintf()
*/
-static void
+void
VSLR(enum shmlogtag tag, int id, txt t)
{
unsigned char *p;
@@ -117,14 +118,14 @@
assert(loghead->ptr < loghead->size);
/* Wrap if necessary */
- if (loghead->ptr + SHMLOG_NEXTTAG + l + 1 >= loghead->size)
+ if (loghead->ptr + 5 + l + 1 >= loghead->size)
vsl_wrap();
p = logstart + loghead->ptr;
- loghead->ptr += SHMLOG_NEXTTAG + l;
+ loghead->ptr += 5 + l;
assert(loghead->ptr < loghead->size);
UNLOCKSHM(&vsl_mtx);
- memcpy(p + SHMLOG_DATA, t.b, l);
+ memcpy(p + 4, t.b, l);
vsl_hdr(tag, p, l, id);
}
@@ -142,8 +143,8 @@
va_start(ap, fmt);
if (strchr(fmt, '%') == NULL) {
- t.b = TRUST_ME(fmt);
- t.e = strchr(t.b, '\0');
+ t.b = (void*)(uintptr_t)fmt;
+ t.e = strchr(fmt, '\0');
VSLR(tag, id, t);
} else {
LOCKSHM(&vsl_mtx);
@@ -152,25 +153,26 @@
assert(loghead->ptr < loghead->size);
/* Wrap if we cannot fit a full size record */
- if (loghead->ptr + SHMLOG_NEXTTAG + 255 + 1 >= loghead->size)
+ if (loghead->ptr + 5 + 255 + 1 >= loghead->size)
vsl_wrap();
p = logstart + loghead->ptr;
- n = vsnprintf((char *)(p + SHMLOG_DATA), 256, fmt, ap);
+ n = vsnprintf((char *)(p + 4), 256, fmt, ap);
if (n > 255)
n = 255; /* we truncate long fields */
vsl_hdr(tag, p, n, id);
- loghead->ptr += SHMLOG_NEXTTAG + n;
+ loghead->ptr += 5 + n;
assert(loghead->ptr < loghead->size);
UNLOCKSHM(&vsl_mtx);
}
va_end(ap);
}
+
/*--------------------------------------------------------------------*/
void
-WSL_Flush(struct worker *w, int overflow)
+WSL_Flush(struct worker *w)
{
unsigned char *p;
unsigned l;
@@ -179,19 +181,18 @@
if (l == 0)
return;
LOCKSHM(&vsl_mtx);
- VSL_stats->shm_flushes += overflow;
VSL_stats->shm_writes++;
VSL_stats->shm_records += w->wlr;
if (loghead->ptr + l + 1 >= loghead->size)
vsl_wrap();
p = logstart + loghead->ptr;
+ memcpy(p + 1, w->wlb + 1, l - 1);
p[l] = SLT_ENDMARKER;
loghead->ptr += l;
assert(loghead->ptr < loghead->size);
- UNLOCKSHM(&vsl_mtx);
- memcpy(p + 1, w->wlb + 1, l - 1);
/* XXX: memory barrier here */
p[0] = w->wlb[0];
+ UNLOCKSHM(&vsl_mtx);
w->wlp = w->wlb;
w->wlr = 0;
}
@@ -216,12 +217,12 @@
assert(w->wlp < w->wle);
/* Wrap if necessary */
- if (w->wlp + SHMLOG_NEXTTAG + l + 1 >= w->wle)
- WSL_Flush(w, 1);
+ if (w->wlp + 5 + l + 1 >= w->wle)
+ WSL_Flush(w);
p = w->wlp;
- w->wlp += SHMLOG_NEXTTAG + l;
+ w->wlp += 5 + l;
assert(w->wlp < w->wle);
- memcpy(p + SHMLOG_DATA, t.b, l);
+ memcpy(p + 4, t.b, l);
vsl_hdr(tag, p, l, id);
w->wlr++;
}
@@ -240,22 +241,22 @@
va_start(ap, fmt);
if (strchr(fmt, '%') == NULL) {
- t.b = TRUST_ME(fmt);
- t.e = strchr(t.b, '\0');
+ t.b = (void*)(uintptr_t)fmt;
+ t.e = strchr(fmt, '\0');
WSLR(w, tag, id, t);
} else {
assert(w->wlp < w->wle);
/* Wrap if we cannot fit a full size record */
- if (w->wlp + SHMLOG_NEXTTAG + 255 + 1 >= w->wle)
- WSL_Flush(w, 1);
+ if (w->wlp + 5 + 255 + 1 >= w->wle)
+ WSL_Flush(w);
p = w->wlp;
- n = vsnprintf((char *)(p + SHMLOG_DATA), 256, fmt, ap);
+ n = vsnprintf((char *)(p + 4), 256, fmt, ap);
if (n > 255)
n = 255; /* we truncate long fields */
vsl_hdr(tag, p, n, id);
- w->wlp += SHMLOG_NEXTTAG + n;
+ w->wlp += 5 + n;
assert(w->wlp < w->wle);
w->wlr++;
}
@@ -347,10 +348,6 @@
MAP_HASSEMAPHORE | MAP_NOSYNC | MAP_SHARED,
heritage.vsl_fd, 0);
xxxassert(loghead != MAP_FAILED);
- i = mlock(loghead, heritage.vsl_size);
- if (i != 0)
- fprintf(stderr, "Notice: locking SHMFILE in core failed: %s\n",
- strerror(errno));
VSL_stats = &loghead->stats;
pp = (void *)(loghead + 1);
*pp = *params;
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/steps.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: steps.h 2415 2008-01-31 11:57:51Z des $
+ * $Id: steps.h 2496 2008-02-17 09:26:32Z des $
*/
STEP(again, AGAIN)
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/stevedore.c
^
|
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: stevedore.c 2515 2008-02-19 11:52:27Z phk $
+ * $Id: stevedore.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
@@ -35,6 +35,7 @@
#include <string.h>
#include "cache.h"
+#include "heritage.h"
#include "stevedore.h"
/*
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/stevedore.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: stevedore.h 2415 2008-01-31 11:57:51Z des $
+ * $Id: stevedore.h 2496 2008-02-17 09:26:32Z des $
*/
#include "vqueue.h"
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/storage_file.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: storage_file.c 2628 2008-04-08 15:33:30Z phk $
+ * $Id: storage_file.c 2564 2008-03-08 13:38:23Z des $
*
* Storage method based on mmap'ed file
*/
@@ -120,37 +120,19 @@
/*--------------------------------------------------------------------*/
-static uintmax_t
-smf_fsspace(int fd, unsigned *bs)
+static void
+smf_calcsize(struct smf_sc *sc, const char *size, int newfile)
{
#if defined(HAVE_SYS_STATVFS_H)
struct statvfs fsst;
-
- AZ(fstatvfs(fd, &fsst));
#elif defined(HAVE_SYS_MOUNT_H) || defined(HAVE_SYS_VFS_H)
struct statfs fsst;
-
- AZ(fstatfs(sc->fd, &fsst));
#else
#error no struct statfs / struct statvfs
#endif
-
- /* We use units of the larger of filesystem blocksize and pagesize */
- if (*bs < fsst.f_bsize)
- *bs = fsst.f_bsize;
- xxxassert(*bs % fsst.f_bsize == 0);
- return (fsst.f_bsize * fsst.f_bavail);
-}
-
-
-/*--------------------------------------------------------------------*/
-
-static void
-smf_calcsize(struct smf_sc *sc, const char *size, int newfile)
-{
uintmax_t l, fssize;
unsigned bs;
- const char *q;
+ char suff[2];
int i;
off_t o;
struct stat st;
@@ -159,48 +141,86 @@
AZ(fstat(sc->fd, &st));
xxxassert(S_ISREG(st.st_mode));
+#if defined(HAVE_SYS_STATVFS_H)
+ AZ(fstatvfs(sc->fd, &fsst));
+#elif defined(HAVE_SYS_MOUNT_H) || defined(HAVE_SYS_VFS_H)
+ AZ(fstatfs(sc->fd, &fsst));
+#else
+#error no struct statfs / struct statvfs
+#endif
+
+ /* We use units of the larger of filesystem blocksize and pagesize */
bs = sc->pagesize;
- fssize = smf_fsspace(sc->fd, &bs);
+ if (bs < fsst.f_bsize)
+ bs = fsst.f_bsize;
xxxassert(bs % sc->pagesize == 0);
+ xxxassert(bs % fsst.f_bsize == 0);
+ fssize = fsst.f_bsize * fsst.f_bavail;
- if ((size == NULL || *size == '\0') && !newfile) {
- /*
- * We have no size specification, but an existing file,
- * use it's existing size.
- */
+ i = sscanf(size, "%ju%1s", &l, suff); /* can return -1, 0, 1 or 2 */
+
+ if (i == 0) {
+ fprintf(stderr,
+ "Error: (-sfile) size \"%s\" not understood\n", size);
+ exit (2);
+ }
+
+ if (i >= 1 && l == 0) {
+ fprintf(stderr,
+ "Error: (-sfile) zero size not permitted\n");
+ exit (2);
+ }
+
+ if (i == -1 && !newfile) /* Use the existing size of the file */
l = st.st_size;
- } else {
- q = str2bytes(size, &l, fssize);
- if (q != NULL) {
+ /* We must have at least one block */
+ if (l < bs) {
+ if (i == -1) {
fprintf(stderr,
- "Error: (-sfile) size \"%s\": %s\n", size, q);
- exit (2);
+ "Info: (-sfile) default to 80%% size\n");
+ l = 80;
+ suff[0] = '%';
+ i = 2;
+ }
+
+ if (i == 2) {
+ if (suff[0] == 'k' || suff[0] == 'K')
+ l *= 1024UL;
+ else if (suff[0] == 'm' || suff[0] == 'M')
+ l *= 1024UL * 1024UL;
+ else if (suff[0] == 'g' || suff[0] == 'G')
+ l *= 1024UL * 1024UL * 1024UL;
+ else if (suff[0] == 't' || suff[0] == 'T')
+ l *= (uintmax_t)(1024UL * 1024UL) *
+ (uintmax_t)(1024UL * 1024UL);
+ else if (suff[0] == '%') {
+ l *= fssize;
+ l /= 100;
+ }
}
- }
- /*
- * This trickery wouldn't be necessary if X/Open would
- * just add OFF_MAX to <limits.h>...
- */
- i = 0;
- while(1) {
+ /*
+ * This trickery wouldn't be necessary if X/Open would
+ * just add OFF_MAX to <limits.h>...
+ */
o = l;
- if (o == l && o > 0)
- break;
- l >>= 1;
- i++;
- }
- if (i)
- fprintf(stderr, "WARNING: storage file size reduced"
- " to %ju due to system limitations\n", l);
-
- if (l < st.st_size) {
- AZ(ftruncate(sc->fd, l));
- } else if (l - st.st_size > fssize) {
- l = fssize * 80 / 100;
- fprintf(stderr, "WARNING: storage file size reduced"
- " to %ju (80%% of available disk space)\n", l);
+ if (o != l || o < 0) {
+ do {
+ l >>= 1;
+ o = l;
+ } while (o != l || o < 0);
+ fprintf(stderr, "WARNING: storage file size reduced"
+ " to %ju due to system limitations\n", l);
+ }
+
+ if (l < st.st_size) {
+ AZ(ftruncate(sc->fd, l));
+ } else if (l - st.st_size > fssize) {
+ l = fssize * 80 / 100;
+ fprintf(stderr, "WARNING: storage file size reduced"
+ " to %ju (80%% of available disk space)\n", l);
+ }
}
/* round down to multiple of filesystem blocksize or pagesize */
@@ -222,7 +242,7 @@
l -= (l % bs);
}
- printf("storage_file: filename: %s size %ju MB.\n",
+ printf("storage_file: filename: %s size %ju MegaBytes.\n",
sc->filename, l / (1024 * 1024));
sc->filesize = l;
@@ -609,7 +629,7 @@
(uintmax_t)sum, sc->filesize);
/* XXX */
- if (sum < MINPAGES * (off_t)getpagesize())
+ if (sum < MINPAGES * (uintmax_t)getpagesize())
exit (2);
MTX_INIT(&sc->mtx);
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/storage_malloc.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: storage_malloc.c 2630 2008-04-16 07:58:43Z phk $
+ * $Id: storage_malloc.c 2564 2008-03-08 13:38:23Z des $
*
* Storage method based on malloc(3)
*/
@@ -35,20 +35,14 @@
#include <sys/types.h>
-#include <stdio.h>
#include <stdlib.h>
-#include <pthread.h>
#include "shmlog.h"
#include "cache.h"
#include "stevedore.h"
-static size_t sma_max = SIZE_MAX;
-static MTX sma_mtx;
-
struct sma {
struct storage s;
- size_t sz;
};
static struct storage *
@@ -56,24 +50,10 @@
{
struct sma *sma;
- LOCK(&sma_mtx);
- VSL_stats->sma_nreq++;
- if (VSL_stats->sma_nbytes + size > sma_max)
- size = 0;
- else {
- VSL_stats->sma_nobj++;
- VSL_stats->sma_nbytes += size;
- VSL_stats->sma_balloc += size;
- }
- UNLOCK(&sma_mtx);
-
- if (size == 0)
- return (NULL);
-
+ VSL_stats->sm_nreq++;
sma = calloc(sizeof *sma, 1);
if (sma == NULL)
return (NULL);
- sma->sz = size;
sma->s.priv = sma;
sma->s.ptr = malloc(size);
XXXAN(sma->s.ptr);
@@ -82,6 +62,8 @@
sma->s.fd = -1;
sma->s.stevedore = st;
sma->s.magic = STORAGE_MAGIC;
+ VSL_stats->sm_nobj++;
+ VSL_stats->sm_balloc += sma->s.space;
return (&sma->s);
}
@@ -92,12 +74,8 @@
CHECK_OBJ_NOTNULL(s, STORAGE_MAGIC);
sma = s->priv;
- assert(sma->sz == sma->s.space);
- LOCK(&sma_mtx);
- VSL_stats->sma_nobj--;
- VSL_stats->sma_nbytes -= sma->sz;
- VSL_stats->sma_bfree += sma->sz;
- UNLOCK(&sma_mtx);
+ VSL_stats->sm_nobj--;
+ VSL_stats->sm_balloc -= sma->s.space;
free(sma->s.ptr);
free(sma);
}
@@ -110,52 +88,16 @@
CHECK_OBJ_NOTNULL(s, STORAGE_MAGIC);
sma = s->priv;
- assert(sma->sz == sma->s.space);
if ((p = realloc(sma->s.ptr, size)) != NULL) {
- LOCK(&sma_mtx);
- VSL_stats->sma_nbytes -= (sma->sz - size);
- VSL_stats->sma_bfree += sma->sz - size;
- sma->sz = size;
- UNLOCK(&sma_mtx);
+ VSL_stats->sm_balloc -= sma->s.space;
sma->s.ptr = p;
sma->s.space = size;
+ VSL_stats->sm_balloc += sma->s.space;
}
}
-static void
-sma_init(struct stevedore *parent, const char *spec)
-{
- const char *e;
- uintmax_t u;
-
- (void)parent;
- if (spec != NULL && *spec != '\0') {
- e = str2bytes(spec, &u, 0);
- if (e != NULL) {
- fprintf(stderr,
- "Error: (-smalloc) size \"%s\": %s\n", spec, e);
- exit(2);
- }
- if ((u != (uintmax_t)(size_t)u)) {
- fprintf(stderr,
- "Error: (-smalloc) size \"%s\": too big\n", spec);
- exit(2);
- }
- sma_max = u;
- }
-}
-
-static void
-sma_open(const struct stevedore *st)
-{
- (void)st;
- AZ(pthread_mutex_init(&sma_mtx, NULL));
-}
-
struct stevedore sma_stevedore = {
.name = "malloc",
- .init = sma_init,
- .open = sma_open,
.alloc = sma_alloc,
.free = sma_free,
.trim = sma_trim,
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/tcp.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: tcp.c 2515 2008-02-19 11:52:27Z phk $
+ * $Id: tcp.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
@@ -47,6 +47,7 @@
#include "compat/strlcpy.h"
#endif
+#include "heritage.h"
#include "mgt.h"
/*--------------------------------------------------------------------*/
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/varnishd.1
^
|
@@ -26,7 +26,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: varnishd.1 2565 2008-03-08 13:47:56Z des $
+.\" $Id: varnishd.1 2567 2008-03-08 14:01:28Z des $
.\"
.Dd March 8, 2008
.Dt VARNISHD 1
@@ -43,7 +43,6 @@
.Op Fl f Ar config
.Op Fl g Ar group
.Op Fl h Ar type Ns Op , Ns Ar options
-.Op Fl l Ar shmlogsize
.Op Fl n Ar name
.Op Fl P Ar file
.Op Fl p Ar param Ns = Ns Ar value
@@ -84,11 +83,7 @@
.Ar port
is not specified, the default HTTP port as listed in
.Pa /etc/services
-is used. To listen on multiple hosts or ports, the argument to
-.Fl a
-can be a (quoted) whitespace separated list of
-.Ar address Ns Op : Ns Ar port
-tokens.
+is used.
.It Fl b Ar host Ns Op : Ns Ar port
Use the specified
.Ar host
@@ -136,11 +131,6 @@
See
.Sx Hash Algorithms
for a list of supported algorithms.
-.It Fl l Ar shmlogsize
-Specify size of shmlog file.
-Scaling suffixes like 'k', 'm' can be used up to (e)tabytes.
-Default is 80 Megabytes.
-Specifying less than 8 Megabytes is unwise.
.It Fl n
Specify a name for this instance.
Amonst other things, this name is used to construct the name of the
@@ -288,7 +278,7 @@
.El
.Ss Management Interface
If the
-.Fl T
+.Fl -T
option was specified,
.Nm
will offer a command-line management interface on the specified
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishd/varnishd.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: varnishd.c 2595 2008-03-12 10:25:51Z phk $
+ * $Id: varnishd.c 2564 2008-03-08 13:38:23Z des $
*
* The management process and CLI handling
*/
@@ -126,42 +126,57 @@
static void
usage(void)
{
-#define FMT " %-28s # %s\n"
-
fprintf(stderr, "usage: varnishd [options]\n");
- fprintf(stderr, FMT, "-a address:port", "HTTP listen address and port");
- fprintf(stderr, FMT, "-b address:port", "backend address and port");
- fprintf(stderr, FMT, "", " -b <hostname_or_IP>");
- fprintf(stderr, FMT, "", " -b '<hostname_or_IP>:<port_or_service>'");
- fprintf(stderr, FMT, "-d", "debug");
- fprintf(stderr, FMT, "-f file", "VCL script");
- fprintf(stderr, FMT, "-F", "Run in foreground");
- fprintf(stderr, FMT, "-h kind[,hashoptions]", "Hash specification");
- fprintf(stderr, FMT, "", " -h simple_list");
- fprintf(stderr, FMT, "", " -h classic [default]");
- fprintf(stderr, FMT, "", " -h classic,<buckets>");
- fprintf(stderr, FMT, "-l bytesize", "Size of shared memory log");
- fprintf(stderr, FMT, "-n dir", "varnishd working directory");
- fprintf(stderr, FMT, "-P file", "PID file");
- fprintf(stderr, FMT, "-p param=value", "set parameter");
- fprintf(stderr, FMT,
+ fprintf(stderr, " %-28s # %s\n", "-a address:port",
+ "HTTP listen address and port");
+ fprintf(stderr, " %-28s # %s\n", "-b address:port",
+ "backend address and port");
+ fprintf(stderr, " %-28s # %s\n", "",
+ " -b <hostname_or_IP>");
+ fprintf(stderr, " %-28s # %s\n", "",
+ " -b '<hostname_or_IP>:<port_or_service>'");
+ fprintf(stderr, " %-28s # %s\n", "-d", "debug");
+ fprintf(stderr, " %-28s # %s\n", "-f file", "VCL script");
+ fprintf(stderr, " %-28s # %s\n", "-F", "Run in foreground");
+ fprintf(stderr, " %-28s # %s\n",
+ "-h kind[,hashoptions]", "Hash specification");
+ fprintf(stderr, " %-28s # %s\n", "",
+ " -h simple_list");
+ fprintf(stderr, " %-28s # %s\n", "",
+ " -h classic [default]");
+ fprintf(stderr, " %-28s # %s\n", "",
+ " -h classic,<buckets>");
+ fprintf(stderr, " %-28s # %s\n", "-n dir",
+ "varnishd working directory");
+ fprintf(stderr, " %-28s # %s\n", "-P file", "PID file");
+ fprintf(stderr, " %-28s # %s\n", "-p param=value",
+ "set parameter");
+ fprintf(stderr, " %-28s # %s\n",
"-s kind[,storageoptions]", "Backend storage specification");
- fprintf(stderr, FMT, "", " -s malloc");
- fprintf(stderr, FMT, "", " -s file [default: use /tmp]");
- fprintf(stderr, FMT, "", " -s file,<dir_or_file>");
- fprintf(stderr, FMT, "", " -s file,<dir_or_file>,<size>");
- fprintf(stderr, FMT, "-t", "Default TTL");
- fprintf(stderr, FMT, "-T address:port",
+ fprintf(stderr, " %-28s # %s\n", "",
+ " -s malloc");
+ fprintf(stderr, " %-28s # %s\n", "",
+ " -s file [default: use /tmp]");
+ fprintf(stderr, " %-28s # %s\n", "",
+ " -s file,<dir_or_file>");
+ fprintf(stderr, " %-28s # %s\n", "",
+ " -s file,<dir_or_file>,<size>");
+ fprintf(stderr, " %-28s # %s\n", "-t", "Default TTL");
+ fprintf(stderr, " %-28s # %s\n", "-T address:port",
"Telnet listen address and port");
- fprintf(stderr, FMT, "-V", "version");
- fprintf(stderr, FMT, "-w int[,int[,int]]", "Number of worker threads");
- fprintf(stderr, FMT, "", " -w <fixed_count>");
- fprintf(stderr, FMT, "", " -w min,max");
- fprintf(stderr, FMT, "", " -w min,max,timeout [default: -w1,1000,120]");
-#undef FMT
+ fprintf(stderr, " %-28s # %s\n", "-V", "version");
+ fprintf(stderr, " %-28s # %s\n", "-w int[,int[,int]]",
+ "Number of worker threads");
+ fprintf(stderr, " %-28s # %s\n", "",
+ " -w <fixed_count>");
+ fprintf(stderr, " %-28s # %s\n", "",
+ " -w min,max");
+ fprintf(stderr, " %-28s # %s\n", "",
+ " -w min,max,timeout [default: -w1,1000,120]");
#if 0
-c clusterid@cluster_controller
-m memory_limit
+ -l logfile,logsize
-u uid
-a CLI_port
#endif
@@ -233,7 +248,7 @@
DebugSigPass(int sig)
{
- (void)kill(d_child, sig);
+ kill(d_child, sig);
}
static void
@@ -282,8 +297,8 @@
pfd[1].fd = pipes[1][0];
pfd[1].events = POLLIN;
- (void)signal(SIGPIPE, SIG_IGN);
- (void)signal(SIGINT, DebugSigPass);
+ signal(SIGPIPE, SIG_IGN);
+ signal(SIGINT, DebugSigPass);
i = read(pipes[1][0], buf, sizeof buf - 1);
xxxassert(i >= 0);
buf[i] = '\0';
@@ -344,7 +359,6 @@
return;
}
vsb_finish(cli->sb);
- AZ(vsb_overflowed(cli->sb));
fprintf(stderr, "Error:\n%s\n", vsb_data(cli->sb));
exit (2);
}
@@ -360,9 +374,6 @@
unsigned F_flag = 0;
const char *b_arg = NULL;
const char *f_arg = NULL;
- const char *l_arg = "80m";
- uintmax_t l_size;
- const char *q;
int f_fd = -1;
const char *h_arg = "classic";
const char *n_arg = NULL;
@@ -378,7 +389,7 @@
setbuf(stdout, NULL);
setbuf(stderr, NULL);
- AZ(setenv("TZ", "GMT", 1));
+ setenv("TZ", "GMT", 1);
tzset();
memset(cli, 0, sizeof cli);
@@ -393,7 +404,7 @@
MCF_ParamInit(cli);
cli_check(cli);
- while ((o = getopt(argc, argv, "a:b:Cdf:Fg:h:l:n:P:p:s:T:t:u:Vw:")) != -1)
+ while ((o = getopt(argc, argv, "a:b:Cdf:Fg:h:n:P:p:s:T:t:u:Vw:")) != -1)
switch (o) {
case 'a':
MCF_ParamSet(cli, "listen_address", optarg);
@@ -420,9 +431,6 @@
case 'h':
h_arg = optarg;
break;
- case 'l':
- l_arg = optarg;
- break;
case 'n':
n_arg = optarg;
break;
@@ -469,18 +477,10 @@
usage();
}
- q = str2bytes(l_arg, &l_size, 0);
- if (q != NULL) {
- fprintf(stderr, "Parameter error:\n");
- fprintf(stderr, "\t-l ...: %s\n", q);
- exit (1);
- }
-
/* XXX: we can have multiple CLI actions above, is this enough ? */
if (cli[0].result != CLIS_OK) {
fprintf(stderr, "Parameter errors:\n");
vsb_finish(cli[0].sb);
- AZ(vsb_overflowed(cli[0].sb));
fprintf(stderr, "%s\n", vsb_data(cli[0].sb));
exit(1);
}
@@ -544,21 +544,23 @@
setup_hash(h_arg);
- VSL_MgtInit(SHMLOG_FILENAME, l_size);
+ VSL_MgtInit(SHMLOG_FILENAME, 8*1024*1024);
if (d_flag == 1)
DebugStunt();
if (d_flag < 2 && !F_flag)
- AZ(daemon(1, d_flag));
+ daemon(1, d_flag);
if (d_flag == 1)
printf("%d\n", getpid());
- if (pfh != NULL && vpf_write(pfh))
- fprintf(stderr, "NOTE: Could not write PID file\n");
+ if (pfh != NULL)
+ vpf_write(pfh);
+
+ mgt_cli_init();
mgt_run(d_flag, T_arg);
if (pfh != NULL)
- (void)vpf_remove(pfh);
+ vpf_remove(pfh);
exit(0);
}
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishhist/Makefile.am
^
|
@@ -1,4 +1,4 @@
-# $Id: Makefile.am 2455 2008-02-13 13:55:39Z des $
+# $Id: Makefile.am 2564 2008-03-08 13:38:23Z des $
INCLUDES = -I$(top_srcdir)/include
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishhist/varnishhist.1
^
|
@@ -26,7 +26,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: varnishhist.1 2415 2008-01-31 11:57:51Z des $
+.\" $Id: varnishhist.1 2496 2008-02-17 09:26:32Z des $
.\"
.Dd June 28, 2007
.Dt VARNISHHIST 1
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishhist/varnishhist.c
^
|
@@ -27,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: varnishhist.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: varnishhist.c 2564 2008-03-08 13:38:23Z des $
*
* Log tailer for Varnish
*/
@@ -261,11 +261,9 @@
switch ((ch = getch())) {
case ERR:
break;
-#ifdef KEY_RESIZE
case KEY_RESIZE:
erase();
break;
-#endif
case '\014': /* Ctrl-L */
case '\024': /* Ctrl-T */
redrawwin(stdscr);
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishlog/Makefile.am
^
|
@@ -1,4 +1,4 @@
-# $Id: Makefile.am 2455 2008-02-13 13:55:39Z des $
+# $Id: Makefile.am 2564 2008-03-08 13:38:23Z des $
INCLUDES = -I$(top_srcdir)/include
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishlog/varnishlog.1
^
|
@@ -26,7 +26,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: varnishlog.1 2575 2008-03-09 15:14:04Z des $
+.\" $Id: varnishlog.1 2578 2008-03-09 15:26:31Z des $
.\"
.Dd March 9, 2008
.Dt VARNISHLOG 1
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishlog/varnishlog.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: varnishlog.c 2569 2008-03-08 15:42:23Z des $
+ * $Id: varnishlog.c 2570 2008-03-08 15:43:00Z des $
*
* Log tailer for Varnish
*/
@@ -273,7 +273,7 @@
static void
do_write(struct VSL_data *vd, const char *w_arg, int a_flag)
{
- int fd, i, l;
+ int fd, i;
unsigned char *p;
fd = open_log(w_arg, a_flag);
@@ -283,8 +283,7 @@
if (i < 0)
break;
if (i > 0) {
- l = SHMLOG_LEN(p);
- i = write(fd, p, SHMLOG_NEXTTAG + l);
+ i = write(fd, p, 5 + p[1]);
if (i < 0) {
perror(w_arg);
exit(1);
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishncsa/Makefile.am
^
|
@@ -1,4 +1,4 @@
-# $Id: Makefile.am 2455 2008-02-13 13:55:39Z des $
+# $Id: Makefile.am 2564 2008-03-08 13:38:23Z des $
INCLUDES = -I$(top_srcdir)/include
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishncsa/varnishncsa.1
^
|
@@ -26,7 +26,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: varnishncsa.1 2415 2008-01-31 11:57:51Z des $
+.\" $Id: varnishncsa.1 2496 2008-02-17 09:26:32Z des $
.\"
.Dd November 8, 2007
.Dt VARNISHNCSA 1
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishncsa/varnishncsa.c
^
|
@@ -27,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: varnishncsa.c 2457 2008-02-13 17:10:04Z des $
+ * $Id: varnishncsa.c 2564 2008-03-08 13:38:23Z des $
*
* Obtain log data from the shared memory log, order it by session ID, and
* display it in Apache / NCSA combined log format:
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishreplay/Makefile.am
^
|
@@ -1,4 +1,4 @@
-# $Id: Makefile.am 2455 2008-02-13 13:55:39Z des $
+# $Id: Makefile.am 2564 2008-03-08 13:38:23Z des $
INCLUDES = -I$(top_srcdir)/include
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishreplay/varnishreplay.1
^
|
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: varnishreplay.1 2415 2008-01-31 11:57:51Z des $
+.\" $Id: varnishreplay.1 2496 2008-02-17 09:26:32Z des $
.\"
.Dd September 12, 2007
.Dt VARNISHREPLAY 1
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishreplay/varnishreplay.c
^
|
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: varnishreplay.c 2577 2008-03-09 15:24:37Z des $
+ * $Id: varnishreplay.c 2578 2008-03-09 15:26:31Z des $
*/
#include "config.h"
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishstat/Makefile.am
^
|
@@ -1,4 +1,4 @@
-# $Id: Makefile.am 2455 2008-02-13 13:55:39Z des $
+# $Id: Makefile.am 2564 2008-03-08 13:38:23Z des $
INCLUDES = -I$(top_srcdir)/include
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishstat/varnishstat.1
^
|
@@ -26,7 +26,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: varnishstat.1 2415 2008-01-31 11:57:51Z des $
+.\" $Id: varnishstat.1 2496 2008-02-17 09:26:32Z des $
.\"
.Dd June 28, 2007
.Dt VARNISHSTAT 1
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishstat/varnishstat.c
^
|
@@ -27,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: varnishstat.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: varnishstat.c 2564 2008-03-08 13:38:23Z des $
*
* Log tailer for Varnish
*/
@@ -131,11 +131,9 @@
switch ((ch = getch())) {
case ERR:
break;
-#ifdef KEY_RESIZE
case KEY_RESIZE:
erase();
break;
-#endif
case '\014': /* Ctrl-L */
case '\024': /* Ctrl-T */
redrawwin(stdscr);
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishtop/Makefile.am
^
|
@@ -1,4 +1,4 @@
-# $Id: Makefile.am 2455 2008-02-13 13:55:39Z des $
+# $Id: Makefile.am 2564 2008-03-08 13:38:23Z des $
INCLUDES = -I$(top_srcdir)/include
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishtop/varnishtop.1
^
|
@@ -26,7 +26,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: varnishtop.1 2415 2008-01-31 11:57:51Z des $
+.\" $Id: varnishtop.1 2496 2008-02-17 09:26:32Z des $
.\"
.Dd June 28, 2007
.Dt VARNISHTOP 1
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/bin/varnishtop/varnishtop.c
^
|
@@ -27,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: varnishtop.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: varnishtop.c 2564 2008-03-08 13:38:23Z des $
*
* Log tailer for Varnish
*/
@@ -76,15 +76,14 @@
{
struct top *tp, *tp2;
const unsigned char *q;
- unsigned int u, l;
+ unsigned int u;
int i;
// fprintf(stderr, "%*.*s\n", p[1], p[1], p + 4);
u = 0;
- q = p + SHMLOG_DATA;
- l = SHMLOG_LEN(p);
- for (i = 0; i < l; i++, q++) {
+ q = p + 4;
+ for (i = 0; i < p[1]; i++, q++) {
if (f_flag && (*q == ':' || isspace(*q)))
break;
u += *q;
@@ -93,12 +92,11 @@
VTAILQ_FOREACH(tp, &top_head, list) {
if (tp->hash != u)
continue;
- if (tp->rec[SHMLOG_TAG] != p[SHMLOG_TAG])
+ if (tp->rec[0] != p[0])
continue;
if (tp->clen != q - p)
continue;
- if (memcmp(p + SHMLOG_DATA, tp->rec + SHMLOG_DATA,
- q - (p + SHMLOG_DATA)))
+ if (memcmp(p + 4, tp->rec + 4, q - (p + 4)))
continue;
tp->count += 1.0;
break;
@@ -112,7 +110,7 @@
tp->clen = q - p;
VTAILQ_INSERT_TAIL(&top_head, tp, list);
}
- memcpy(tp->rec, p, SHMLOG_DATA + l);
+ memcpy(tp->rec, p, 4 + p[1]);
while (1) {
tp2 = VTAILQ_PREV(tp, tophead, list);
if (tp2 == NULL || tp2->count >= tp->count)
@@ -133,7 +131,7 @@
update(void)
{
struct top *tp, *tp2;
- int l, len;
+ int l;
double t = 0;
static time_t last;
time_t now;
@@ -149,12 +147,12 @@
mvprintw(0, 0, "list length %u", ntop);
VTAILQ_FOREACH_SAFE(tp, &top_head, list, tp2) {
if (++l < LINES) {
- len = SHMLOG_LEN(tp->rec);
+ int len = tp->rec[1];
if (len > COLS - 20)
len = COLS - 20;
mvprintw(l, 0, "%9.2f %-9.9s %*.*s\n",
- tp->count, VSL_tags[tp->rec[SHMLOG_TAG]],
- len, len, tp->rec + SHMLOG_DATA);
+ tp->count, VSL_tags[tp->rec[0]],
+ len, len, tp->rec + 4);
t = tp->count;
}
tp->count *= .999;
@@ -218,11 +216,9 @@
switch ((ch = getch())) {
case ERR:
break;
-#ifdef KEY_RESIZE
case KEY_RESIZE:
erase();
break;
-#endif
case '\014': /* Ctrl-L */
case '\024': /* Ctrl-T */
redrawwin(stdscr);
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/configure.ac
^
|
@@ -1,9 +1,9 @@
-# $Id: configure.ac 2478 2008-02-15 12:30:47Z phk $
+# $Id: configure.ac 2566 2008-03-08 13:51:54Z des $
AC_PREREQ(2.59)
AC_COPYRIGHT([Copyright (c) 2006-2008 Linpro AS / Verdens Gang AS])
-AC_REVISION([$Id: configure.ac 2478 2008-02-15 12:30:47Z phk $])
-AC_INIT([Varnish], [trunk], [varnish-dev@projects.linpro.no])
+AC_REVISION([$Id: configure.ac 2566 2008-03-08 13:51:54Z des $])
+AC_INIT([Varnish], [1.2], [varnish-dev@projects.linpro.no])
AC_CONFIG_SRCDIR(include/varnishapi.h)
AM_CONFIG_HEADER(config.h)
@@ -75,7 +75,6 @@
AC_CHECK_HEADERS([sys/statvfs.h])
AC_CHECK_HEADERS([sys/vfs.h])
AC_CHECK_HEADERS([netinet/in.h])
-AC_CHECK_HEADERS([pthread_np.h])
AC_CHECK_HEADERS([stddef.h])
AC_CHECK_HEADERS([stdlib.h])
AC_CHECK_HEADERS([unistd.h])
@@ -99,39 +98,19 @@
AC_CHECK_FUNCS([socket])
AC_CHECK_FUNCS([strptime])
AC_CHECK_FUNCS([fmtcheck])
-AC_CHECK_FUNCS([getdtablesize])
-AC_CHECK_FUNCS([abort2])
-
-save_LIBS="${LIBS}"
-LIBS="${PTHREAD_LIBS}"
-AC_CHECK_FUNCS([pthread_set_name_np])
-AC_CHECK_FUNCS([pthread_mutex_isowned_np])
-LIBS="${save_LIBS}"
+# Don't look for sendfile at all, none of them work
+# anyway. (don't tell when done with passed mem-range)
+#
## This one is tricky, there are multiple versions
-case $host in
-*-*-freebsd*)
- AC_CACHE_CHECK([whether sendfile works],
- [ac_cv_so_sendfile_works],
- [AC_RUN_IFELSE(
- [AC_LANG_PROGRAM([[
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <sys/uio.h>
- ]],[[
- return (SF_SYNC == 0);
- ]])],
- [ac_cv_so_sendfile_works=yes],
- [ac_cv_so_sendfile_works=no])
- ])
- if test "$ac_cv_so_sendfile_works" = yes; then
- AC_DEFINE([SENDFILE_WORKS], [1], [Define if SENDFILE works])
- fi
- ;;
-*)
- AC_MSG_WARN([won't look for sendfile() on $host])
- ;;
-esac
+#case $host in
+#*-*-freebsd*|*-*-linux*)
+# AC_CHECK_FUNCS([sendfile])
+# ;;
+#*)
+# AC_MSG_WARN([won't look for sendfile() on $host])
+# ;;
+#esac
# These functions are provided by libcompat on platforms where they
# are not available
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/debian/Makefile.am
^
|
@@ -1,4 +1,4 @@
-# $Id: Makefile.am 2173 2007-10-28 18:43:24Z des $
+# $Id: Makefile.am 2205 2007-10-30 12:11:49Z des $
EXTRA_DIST = \
README.Debian \
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/debian/control
^
|
@@ -6,7 +6,6 @@
Build-Depends: debhelper (>= 5), autotools-dev, automake1.9, libtool, autoconf, libncurses-dev, xsltproc
XS-Vcs-Browser: http://varnish.projects.linpro.no/browser/trunk/varnish-cache
XS-Vcs-Svn: http://varnish.projects.linpro.no/svn/trunk/varnish-cache
-XBS-Homepage: http://varnish.projects.linpro.no/
Standards-Version: 3.7.3
Package: varnish
@@ -37,5 +36,5 @@
Replaces: libvarnish-dev
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, libvarnish0
-Description: Development files for Varnish.
- Development files for the Varnish HTTP accelerator.
+Description: Shared library for Varnish
+ Development files for the Varnish library.
|
|
Changed |
varnish-20080428.tar.bz2/debian/dirs
^
|
[-]
[+]
|
Deleted |
varnish-20080428.tar.bz2/debian/source.lintian-overrides
^
|
@@ -1,2 +0,0 @@
-# This is a false positive, upstream Makefile removes config.* with "distclean"
-varnish source: configure-generated-file-in-source config.log
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/debian/varnish.default
^
|
@@ -7,11 +7,6 @@
# Maximum number of open files (for ulimit -n)
NFILES=131072
-# Maximum locked memory size (for ulimit -l)
-# Used for locking the shared memory log in memory. If you increase log size,
-# you need to increase this number as well
-MEMLOCK=82000
-
# Default varnish instance name is the local nodename. Can be overridden with
# the -n switch, to have more instances on a single server.
INSTANCE=$(uname -n)
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/debian/varnish.init
^
|
@@ -4,8 +4,8 @@
### BEGIN INIT INFO
# Provides: varnish
-# Required-Start: $local_fs $remote_fs $network
-# Required-Stop: $local_fs $remote_fs $network
+# Required-Start: $local_fs $network
+# Required-Stop: $local_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start HTTP accelerator
@@ -34,9 +34,6 @@
# Open files (usually 1024, which is way too small for varnish)
ulimit -n ${NFILES:-131072}
-# Maxiumum locked memory size for shared memory log
-ulimit -l ${MEMLOCK:-82000}
-
# If $DAEMON_OPTS is not set at all in /etc/default/varnish, use minimal useful
# defaults (Backend at localhost:8080, a common place to put a locally
# installed application server.)
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/debian/varnish.logrotate
^
|
@@ -3,7 +3,6 @@
rotate 7
compress
delaycompress
- missingok
postrotate
if /usr/bin/pgrep -P 1 varnishlog >/dev/null; then
/usr/sbin/invoke-rc.d varnishlog reload > /dev/null
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/debian/varnish.postrm
^
|
@@ -10,13 +10,13 @@
if test -e /var/log/varnish ; then
- rm -r /var/log/varnish > /dev/null 2>&1 || exit 78
+ rm -rf /var/log/varnish 2>&1 > /dev/null || exit 78
fi
if test -e /var/lib/varnish; then
- rm -r /var/lib/varnish > /dev/null 2>&1 || exit 78
+ rm -rf /var/lib/varnish 2>&1 > /dev/null || exit 78
fi
;;
@@ -25,13 +25,13 @@
if test -e /var/log/varnish; then
- rm -r /var/log/varnish > /dev/null 2>&1 || exit 78
+ rm -rf /var/log/varnish 2>&1 > /dev/null || exit 78
fi
if test -e /var/lib/varnish; then
- rm -r /var/lib/varnish > /dev/null 2>&1 || exit 78
+ rm -rf /var/lib/varnish 2>&1 > /dev/null || exit 78
fi
;;
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/debian/varnish.varnishlog.init
^
|
@@ -4,8 +4,8 @@
### BEGIN INIT INFO
# Provides: varnishlog
-# Required-Start: $local_fs $remote_fs $network
-# Required-Stop: $local_fs $remote_fs $network
+# Required-Start: $local_fs $network
+# Required-Stop: $local_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start HTTP accelerator log daemon
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/doc/Makefile.am
^
|
@@ -1,16 +1,14 @@
-# $Id: Makefile.am 2301 2007-12-18 17:00:29Z des $
+# $Id: Makefile.am 1909 2007-08-20 19:49:38Z des $
CHANGELOGS = \
- changes-1.1.2.html \
- changes-1.1.1.html \
+ changes-1.0.4.html \
changes-1.1.html \
- changes-1.0.4.html
+ changes-1.1.1.html
XML = \
- changes-1.1.1-1.1.2.xml \
- changes-1.1-1.1.1.xml \
- changes-1.0.4-1.1.xml \
changes-1.0.3-1.0.4.xml \
+ changes-1.0.4-1.1.xml \
+ changes-1.1-1.1.1.xml \
${CHANGELOGS:.html=.xml}
all: ${CHANGELOGS}
|
[-]
[+]
|
Deleted |
varnish-20080428.tar.bz2/doc/changes-1.1.1-1.1.2.xml
^
|
@@ -1,157 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE group [
-<!ENTITY mdash "—">
-]>
-<!-- $Id: changes-1.1.1-1.1.2.xml 2306 2007-12-18 17:19:46Z des $ -->
-<group from="1.1.1" to="1.1.2">
- <subsystem>
- <name>varnishd</name>
-
- <change type="bug" ref="1809,1913">
- <para>When switching to a new VCL configuration, a race
- condition exists which may cause Varnish to reference a backend
- which no longer exists (see <ticket ref="144"/>). This race
- condition has not been entirely eliminated, but it should occur
- less frequently.</para>
- </change>
-
- <change type="bug" ref="1942">
- <para>When dropping a TCP session before any requests were
- processed, an assertion would be triggered due to an
- uninitialized timestamp (see <ticket ref="132"/>). The
- timestamp is now correctly initialized.</para>
- </change>
-
- <change type="bug" ref="1955,1976,1977">
- <para>Varnish will now correctly generate a <code>Date:</code>
- header for every response instead of copying the one it got from
- the backend (see <ticket ref="157"/>).</para>
- </change>
-
- <change type="bug" ref="1971">
- <para>Comparisons in VCL which involve a non-existent string
- (usually a header which is not present in the request or object
- being processed) would cause a NULL pointer dereference; now the
- comparison will simply fail.</para>
- </change>
-
- <change type="bug" ref="1972">
- <para>A bug in the VCL compiler which would cause a double-free
- when processing <code>include</code> directives has been
- fixed.</para>
- </change>
-
- <change type="bug" ref="1991">
- <para>A resource leak in the worker thread management code has
- been fixed.</para>
- </change>
-
- <change type="bug" ref="1809">
- <para>When connecting to a backend, Varnish will usually get the
- address from a cache. When the cache is refreshed, existing
- connections may end up with a reference to an address structure
- which no longer exists, resulting in a crash. This race
- condition has been somewhat mitigated, but not entirely
- eliminated (see <ticket ref="144"/>.)</para>
- </change>
-
- <change type="bug" ref="1888">
- <para>Varnish will now pass the correct protocol version in pipe
- mode: the backend will get what the client sent, and vice
- versa.</para>
- </change>
-
- <change type="bug" ref="2057,2077,2080,2086">
- <para>The core of the pipe mode code has been rewritten to
- increase robustness and eliminate spurious error messages when
- either end closes the connection in a manner Varnish did not
- anticipate.</para>
- </change>
-
- <change type="bug" ref="2181">
- <para>A memory leak in the backend code has been plugged.</para>
- </change>
-
- <change type="bug" ref="2232">
- <para>When using the <code>kqueue</code> acceptor, if a client
- shuts down the request side of the connection (as many clients
- do after sending their final request), it was possible for the
- acceptor code to receive the <code>EOF</code> event and recycle
- the session while the last request was still being serviced,
- resulting in a assertion failure and a crash when the worker
- thread later tried to delete the session. This should no longer
- happen (see <ticket ref="162"/>.)</para>
- </change>
-
- <change type="bug" ref="2275">
- <para>A mismatch between the recorded length of a cached object
- and the amount of data actually present in cache for that object
- can occasionally occur (see <ticket ref="167"/>.) This has been
- partially fixed, but may still occur for error pages generated
- by Varnish when a problem arises while retrieving an object from
- the backend.</para>
- </change>
-
- <change type="bug" ref="2285,2286">
- <para>Some socket-related system calls may return unexpected
- error codes when operating on a TCP connection that has been
- shut down at the other end. These error codes would previously
- cause assertion failures, but are now recognized as harmless
- conditions.</para>
- </change>
- </subsystem>
-
- <subsystem>
- <name>varnishhist</name>
-
- <change type="enh">
- <para>Pressing <code>0</code> though <code>9</code> while
- <code>varnishhist</code> is running will change the refresh
- interval to the corresponding power of two, in seconds.</para>
- </change>
- </subsystem>
-
- <subsystem>
- <name>varnishncsa</name>
-
- <change type="enh">
- <para>The <code>varnishncsa</code> tool can now daemonize and
- write a PID file like <code>varnishlog</code>, using the same
- command-line options. It will also reopen its output upon receipt
- of a <code>SIGHUP</code> if invoked with <code>-w</code>.</para>
- </change>
- </subsystem>
-
- <subsystem>
- <name>varnishstat</name>
-
- <change type="enh">
- <para>Pressing <code>0</code> though <code>9</code> while
- <code>varnishstat</code> is running will change the refresh
- interval to the corresponding power of two, in seconds.</para>
- </change>
- </subsystem>
-
- <subsystem>
- <name>Build system</name>
-
- <change type="enh" ref="2033">
- <para>Varnish's <code><queue.h></code> has been modified
- to avoid conflicts with <code><sys/queue.h></code> on
- platforms where the latter is included indirectly through system
- headers.</para>
- </change>
-
- <change type="enh" ref="2032,2133,2097,2106,2222-2228">
- <para>Several steps have been taken towards Solaris
- support, but this is not yet complete.</para>
- </change>
-
- <change type="bug" ref="2116,2154">
- <para>When <code>configure</code> was run without an explicit
- prefix, Varnish's idea of the default state directory would be
- garbage and a state directory would have to be specified
- manually with <code>-n</code>. This has been corrected.</para>
- </change>
- </subsystem>
-</group>
|
[-]
[+]
|
Deleted |
varnish-20080428.tar.bz2/doc/changes-1.1.2.xml
^
|
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<?xml-stylesheet type="text/xml" href="changes-html.xsl"?>
-<!DOCTYPE changelog [
- <!ENTITY mdash "—">
-]>
-<!-- $Id: changes-1.1.2.xml 2207 2007-10-30 12:36:09Z des $ -->
-<changelog xmlns:xi="http://www.w3.org/2001/XInclude">
- <package>Varnish</package>
- <version>1.1.2</version>
-
- <xi:include href="changes-1.1.1-1.1.2.xml"/>
-</changelog>
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/etc/default.vcl
^
|
@@ -2,15 +2,15 @@
# This is a basic VCL configuration file for varnish. See the vcl(7)
# man page for details on VCL syntax and semantics.
#
-# $Id: default.vcl 2446 2008-02-11 10:46:09Z des $
+# $Id: default.vcl 1916 2007-08-21 15:37:17Z des $
#
# Default backend definition. Set this to point to your content
# server.
backend default {
- .host = "127.0.0.1";
- .port = "8080";
+ set backend.host = "127.0.0.1";
+ set backend.port = "8080";
}
# Below is a commented-out copy of the default VCL logic. If you
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/etc/zope-plone.vcl
^
|
@@ -6,7 +6,7 @@
#
# See the vcl(7) man page for details on VCL syntax and semantics.
#
-# $Id: zope-plone.vcl 2634 2008-04-24 06:37:01Z ssm $
+# $Id: zope-plone.vcl 2635 2008-04-24 06:46:39Z ssm $
#
# Default backend definition. Set this to point to your content
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/Makefile.am
^
|
@@ -1,4 +1,4 @@
-# $Id: Makefile.am 2106 2007-10-16 14:12:23Z des $
+# $Id: Makefile.am 2112 2007-10-18 11:51:32Z des $
pkginclude_HEADERS = \
shmlog.h \
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/binary_heap.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: binary_heap.h 2415 2008-01-31 11:57:51Z des $
+ * $Id: binary_heap.h 2564 2008-03-08 13:38:23Z des $
*
* Binary Heap API (see: http://en.wikipedia.org/wiki/Binary_heap)
*
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/cli.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cli.h 2415 2008-01-31 11:57:51Z des $
+ * $Id: cli.h 2496 2008-02-17 09:26:32Z des $
*
* Public definition of the CLI protocol, part of the published Varnish-API.
*
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/cli_common.h
^
|
@@ -26,16 +26,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cli_common.h 2595 2008-03-12 10:25:51Z phk $
+ * $Id: cli_common.h 2496 2008-02-17 09:26:32Z des $
*/
struct cli {
- /* XXX: should be MINI_OBJ */
struct vsb *sb;
enum cli_status_e result;
};
-int cli_writeres(int fd, const struct cli *cli);
+int cli_writeres(int fd, struct cli *cli);
int cli_readres(int fd, unsigned *status, char **ptr, double tmo);
+extern struct cli_proto CLI_cmds[];
cli_func_t cli_func_ping;
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/cli_priv.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cli_priv.h 2597 2008-03-12 13:46:34Z phk $
+ * $Id: cli_priv.h 2496 2008-02-17 09:26:32Z des $
*
* Varnish process internal CLI stuff.
*
@@ -53,11 +53,10 @@
};
/* The implementation must provide these functions */
-void cli_out(const struct cli *cli, const char *fmt, ...);
+void cli_out(struct cli *cli, const char *fmt, ...);
void cli_param(struct cli *cli);
void cli_result(struct cli *cli, unsigned r);
/* From libvarnish/cli.c */
void cli_dispatch(struct cli *cli, struct cli_proto *clp, const char *line);
cli_func_t cli_func_help;
-struct cli_proto *cli_concat(struct cli_proto *, struct cli_proto *);
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/compat/asprintf.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: asprintf.h 2415 2008-01-31 11:57:51Z des $
+ * $Id: asprintf.h 2496 2008-02-17 09:26:32Z des $
*/
#ifndef COMPAT_ASPRINTF_H_INCLUDED
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/compat/daemon.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: daemon.h 2415 2008-01-31 11:57:51Z des $
+ * $Id: daemon.h 2496 2008-02-17 09:26:32Z des $
*/
#ifndef COMPAT_DAEMON_H_INCLUDED
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/compat/setproctitle.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: setproctitle.h 2415 2008-01-31 11:57:51Z des $
+ * $Id: setproctitle.h 2496 2008-02-17 09:26:32Z des $
*/
#ifndef COMPAT_SETPROCTITLE_H_INCLUDED
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/compat/srandomdev.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: srandomdev.h 2415 2008-01-31 11:57:51Z des $
+ * $Id: srandomdev.h 2496 2008-02-17 09:26:32Z des $
*/
#ifndef COMPAT_SRANDOMDEV_H_INCLUDED
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/compat/strlcat.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: strlcat.h 2415 2008-01-31 11:57:51Z des $
+ * $Id: strlcat.h 2496 2008-02-17 09:26:32Z des $
*/
#ifndef COMPAT_STRLCAT_H_INCLUDED
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/compat/strlcpy.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: strlcpy.h 2415 2008-01-31 11:57:51Z des $
+ * $Id: strlcpy.h 2496 2008-02-17 09:26:32Z des $
*/
#ifndef COMPAT_STRLCPY_H_INCLUDED
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/compat/strndup.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: strndup.h 2415 2008-01-31 11:57:51Z des $
+ * $Id: strndup.h 2496 2008-02-17 09:26:32Z des $
*/
#ifndef COMPAT_STRNDUP_H_INCLUDED
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/compat/vasprintf.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: vasprintf.h 2415 2008-01-31 11:57:51Z des $
+ * $Id: vasprintf.h 2496 2008-02-17 09:26:32Z des $
*/
#ifndef COMPAT_VASPRINTF_H_INCLUDED
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/libvarnish.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: libvarnish.h 2415 2008-01-31 11:57:51Z des $
+ * $Id: libvarnish.h 2496 2008-02-17 09:26:32Z des $
*/
#include <errno.h>
@@ -45,9 +45,6 @@
uint32_t crc32(uint32_t crc, const void *p1, unsigned l);
uint32_t crc32_l(const void *p1, unsigned l);
-/* from libvarnish/num.c */
-const char *str2bytes(const char *p, uintmax_t *r, uintmax_t rel);
-
/* from libvarnish/time.c */
void TIM_format(double t, char *p);
time_t TIM_parse(const char *p);
@@ -66,7 +63,7 @@
*/
#ifdef WITHOUT_ASSERTS
-#define assert(e) ((void)(e))
+#define assert(e) ((void)0)
#else /* WITH_ASSERTS */
#define assert(e) \
do { \
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/libvcl.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: libvcl.h 2415 2008-01-31 11:57:51Z des $
+ * $Id: libvcl.h 2496 2008-02-17 09:26:32Z des $
*/
char *VCC_Compile(struct vsb *sb, const char *b, const char *e);
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/miniobj.h
^
|
@@ -3,16 +3,9 @@
*
* This file is in the public domain.
*
- * $Id: miniobj.h 2470 2008-02-15 10:28:00Z phk $
+ * $Id: miniobj.h 2260 2007-11-15 16:06:08Z des $
*/
-#define ALLOC_OBJ(to, type_magic) \
- do { \
- (to) = calloc(sizeof *(to), 1); \
- if ((to) != NULL) \
- (to)->magic = (type_magic); \
- } while (0)
-
#define FREE_OBJ(to) \
do { \
(to)->magic = (0); \
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/shmlog.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: shmlog.h 2415 2008-01-31 11:57:51Z des $
+ * $Id: shmlog.h 2496 2008-02-17 09:26:32Z des $
*
* Define the layout of the shared memory log segment.
*
@@ -69,22 +69,11 @@
* Record format is as follows:
*
* 1 byte field type (enum shmlogtag)
- * 2 bytes length of contents
- * 2 bytes record identifier
+ * 1 byte length of contents
+ * 2 byte record identifier
* n bytes field contents (isgraph(c) || isspace(c)) allowed.
*/
-#define SHMLOG_TAG 0
-#define __SHMLOG_LEN_HIGH 1
-#define __SHMLOG_LEN_LOW 2
-#define __SHMLOG_ID_HIGH 3
-#define __SHMLOG_ID_LOW 4
-#define SHMLOG_DATA 5
-#define SHMLOG_NEXTTAG 6 /* ... + len */
-
-#define SHMLOG_LEN(p) (((p)[__SHMLOG_LEN_HIGH] << 8) | (p)[__SHMLOG_LEN_LOW])
-#define SHMLOG_ID(p) (((p)[__SHMLOG_ID_HIGH] << 8) | (p)[__SHMLOG_ID_LOW])
-
/*
* The identifiers in shmlogtag are "SLT_" + XML tag. A script may be run
* on this file to extract the table rather than handcode it
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/shmlog_tags.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: shmlog_tags.h 2415 2008-01-31 11:57:51Z des $
+ * $Id: shmlog_tags.h 2563 2008-03-08 13:12:02Z des $
*
* Define the tags in the shared memory in a reusable format.
* Whoever includes this get to define what the SLTM macro does.
@@ -84,8 +84,6 @@
SLTM(VCL_call)
SLTM(VCL_trace)
SLTM(VCL_return)
-SLTM(VCL_error)
-SLTM(VCL_info)
SLTM(ReqStart)
SLTM(Hit)
SLTM(HitPass)
@@ -95,5 +93,4 @@
SLTM(WorkThread)
SLTM(Terminate)
-SLTM(ESItrace)
-SLTM(ESI_xmlerror)
+SLTM(VCL_error)
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/stat_field.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: stat_field.h 2629 2008-04-08 15:34:57Z phk $
+ * $Id: stat_field.h 2496 2008-02-17 09:26:32Z des $
*/
MAC_STAT(client_conn, uint64_t, 'a', "Client connections accepted")
@@ -52,7 +52,6 @@
MAC_STAT(n_smf_frag, uint64_t, 'i', "N small free smf")
MAC_STAT(n_smf_large, uint64_t, 'i', "N large free smf")
MAC_STAT(n_vbe_conn, uint64_t, 'i', "N struct vbe_conn")
-MAC_STAT(n_bereq, uint64_t, 'i', "N struct bereq")
MAC_STAT(n_wrk, uint64_t, 'i', "N worker threads")
MAC_STAT(n_wrk_create, uint64_t, 'a', "N worker threads created")
MAC_STAT(n_wrk_failed, uint64_t, 'a', "N worker threads not created")
@@ -60,19 +59,16 @@
MAC_STAT(n_wrk_queue, uint64_t, 'a', "N queued work requests")
MAC_STAT(n_wrk_overflow, uint64_t, 'a', "N overflowed work requests")
MAC_STAT(n_wrk_drop, uint64_t, 'a', "N dropped work requests")
-MAC_STAT(n_backend, uint64_t, 'i', "N backends")
MAC_STAT(n_expired, uint64_t, 'i', "N expired objects")
MAC_STAT(n_lru_nuked, uint64_t, 'i', "N LRU nuked objects")
MAC_STAT(n_lru_saved, uint64_t, 'i', "N LRU saved objects")
-MAC_STAT(n_lru_moved, uint64_t, 'i', "N LRU moved objects")
MAC_STAT(n_deathrow, uint64_t, 'i', "N objects on deathrow")
MAC_STAT(losthdr, uint64_t, 'a', "HTTP header overflows")
MAC_STAT(n_objsendfile, uint64_t, 'a', "Objects sent with sendfile")
MAC_STAT(n_objwrite, uint64_t, 'a', "Objects sent with write")
-MAC_STAT(n_objoverflow, uint64_t, 'a', "Objects overflowing workspace")
MAC_STAT(s_sess, uint64_t, 'a', "Total Sessions")
MAC_STAT(s_req, uint64_t, 'a', "Total Requests")
@@ -89,7 +85,6 @@
MAC_STAT(shm_records, uint64_t, 'a', "SHM records")
MAC_STAT(shm_writes, uint64_t, 'a', "SHM writes")
-MAC_STAT(shm_flushes, uint64_t, 'a', "SHM flushes due to overflow")
MAC_STAT(shm_cont, uint64_t, 'a', "SHM MTX contention")
MAC_STAT(sm_nreq, uint64_t, 'a', "allocator requests")
@@ -97,10 +92,4 @@
MAC_STAT(sm_balloc, uint64_t, 'i', "bytes allocated")
MAC_STAT(sm_bfree, uint64_t, 'i', "bytes free")
-MAC_STAT(sma_nreq, uint64_t, 'a', "SMA allocator requests")
-MAC_STAT(sma_nobj, uint64_t, 'i', "SMA outstanding allocations")
-MAC_STAT(sma_nbytes, uint64_t, 'i', "SMA outstanding bytes")
-MAC_STAT(sma_balloc, uint64_t, 'i', "SMA bytes allocated")
-MAC_STAT(sma_bfree, uint64_t, 'i', "SMA bytes free")
-
MAC_STAT(backend_req, uint64_t, 'a', "Backend requests made")
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/stats.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: stats.h 2415 2008-01-31 11:57:51Z des $
+ * $Id: stats.h 2496 2008-02-17 09:26:32Z des $
*/
#include <stdint.h>
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/varnishapi.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: varnishapi.h 2575 2008-03-09 15:14:04Z des $
+ * $Id: varnishapi.h 2578 2008-03-09 15:26:31Z des $
*/
#ifndef VARNISHAPI_H_INCLUDED
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/vcl.h
^
|
@@ -1,5 +1,5 @@
/*
- * $Id: vcl.h 2437 2008-02-06 15:19:49Z phk $
+ * $Id: vcl.h 1940 2007-09-07 09:22:30Z cecilihf $
*
* NB: This file is machine generated, DO NOT EDIT!
*
@@ -7,22 +7,20 @@
*/
struct sess;
-struct cli;
-typedef void vcl_init_f(struct cli *);
-typedef void vcl_fini_f(struct cli *);
+typedef void vcl_init_f(void);
+typedef void vcl_fini_f(void);
typedef int vcl_func_f(struct sess *sp);
struct VCL_conf {
unsigned magic;
#define VCL_CONF_MAGIC 0x7406c509 /* from /dev/random */
- struct director **director;
- unsigned ndirector;
+ struct backend **backend;
+ unsigned nbackend;
struct vrt_ref *ref;
unsigned nref;
unsigned busy;
- unsigned discard;
unsigned nsrc;
const char **srcname;
@@ -43,7 +41,6 @@
vcl_func_f *hit_func;
vcl_func_f *fetch_func;
vcl_func_f *deliver_func;
- vcl_func_f *prefetch_func;
vcl_func_f *timeout_func;
vcl_func_f *discard_func;
};
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/vcl_returns.h
^
|
@@ -1,5 +1,5 @@
/*
- * $Id: vcl_returns.h 2341 2008-01-14 09:14:56Z phk $
+ * $Id: vcl_returns.h 2065 2007-09-30 20:36:16Z phk $
*
* NB: This file is machine generated, DO NOT EDIT!
*
@@ -44,7 +44,6 @@
VCL_MET_MAC(hit,HIT,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_DELIVER))
VCL_MET_MAC(fetch,FETCH,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_INSERT))
VCL_MET_MAC(deliver,DELIVER,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_DELIVER))
-VCL_MET_MAC(prefetch,PREFETCH,(VCL_RET_FETCH|VCL_RET_PASS))
VCL_MET_MAC(timeout,TIMEOUT,(VCL_RET_FETCH|VCL_RET_DISCARD))
VCL_MET_MAC(discard,DISCARD,(VCL_RET_DISCARD|VCL_RET_KEEP))
#else
@@ -56,8 +55,7 @@
#define VCL_MET_HIT (1 << 5)
#define VCL_MET_FETCH (1 << 6)
#define VCL_MET_DELIVER (1 << 7)
-#define VCL_MET_PREFETCH (1 << 8)
-#define VCL_MET_TIMEOUT (1 << 9)
-#define VCL_MET_DISCARD (1 << 10)
+#define VCL_MET_TIMEOUT (1 << 8)
+#define VCL_MET_DISCARD (1 << 9)
#endif
-#define N_METHODS 11
+#define N_METHODS 10
|
[-]
[+]
|
Deleted |
varnish-20080428.tar.bz2/include/vlu.h
^
|
@@ -1,41 +0,0 @@
-/*-
- * Copyright (c) 2005-2008 Poul-Henning Kamp <phk@freebsd.org>
- * All rights reserved.
- *
- * 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 AUTHORS 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 THE AUTHORS 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.
- *
- * $Id: vpf.h 1410 2007-05-11 11:17:09Z des $
- *
- * Functions for assembling a bytestream into text-lines and calling
- * a function on each.
- */
-
-#ifndef VLU_H_INCLUDED
-#define VLU_H_INCLUDED
-
-typedef int (vlu_f)(void *, const char *);
-struct vlu *VLU_New(void *priv, vlu_f *func, unsigned bufsize);
-int VLU_Fd(int fd, struct vlu *l);
-int VLU_File(FILE *f, struct vlu *l);
-void VLU_Destroy(struct vlu *l);
-
-#endif
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/vrt.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: vrt.h 2546 2008-03-03 17:03:05Z des $
+ * $Id: vrt.h 2496 2008-02-17 09:26:32Z des $
*
* Runtime support for compiled VCL programs.
*
@@ -36,49 +36,37 @@
struct sess;
struct vsb;
-struct cli;
-struct director;
+struct backend;
struct VCL_conf;
struct sockaddr;
-/*
- * A backend is a host+port somewhere on the network
- */
-struct vrt_backend {
- const char *portname;
- const char *hostname;
- const char *vcl_name;
+struct vrt_simple_backend {
const char *ident;
+ const char *name;
+ const char *port;
+ const char *host;
};
-/*
- * A director with a predictable reply
- */
-
-struct vrt_dir_simple {
- const char *name;
- const struct vrt_backend *host;
+struct vrt_backend_entry {
+ const char *port;
+ const char *host;
+ double weight;
+ struct vrt_backend_entry *next;
};
-/*
- * A director with an unpredictable reply
- */
-
-struct vrt_dir_random_entry {
- const struct vrt_backend *host;
- double weight;
+struct vrt_round_robin_backend {
+ const char *name;
+ unsigned count;
+ struct vrt_backend_entry *bentry;
};
-struct vrt_dir_random {
- const char *name;
- unsigned nmember;
- const struct vrt_dir_random_entry *members;
+struct vrt_random_backend {
+ const char *name;
+ unsigned weighted;
+ unsigned count;
+ struct vrt_backend_entry *bentry;
};
-/*
- * other stuff.
- * XXX: document when bored
- */
struct vrt_ref {
unsigned source;
@@ -129,13 +117,13 @@
void VRT_Rollback(struct sess *sp);
/* Backend related */
-void VRT_init_dir_simple(struct cli *, struct director **, const struct vrt_dir_simple *);
-void VRT_init_dir_random(struct cli *, struct director **, const struct vrt_dir_random *);
-void VRT_fini_dir(struct cli *, struct director *);
+void VRT_init_simple_backend(struct backend **, const struct vrt_simple_backend *);
+void VRT_init_round_robin_backend(struct backend **, const struct vrt_round_robin_backend *);
+void VRT_init_random_backend(struct backend **, const struct vrt_random_backend *);
+void VRT_fini_backend(struct backend *);
char *VRT_IP_string(const struct sess *sp, const struct sockaddr *sa);
char *VRT_int_string(const struct sess *sp, int);
-char *VRT_double_string(const struct sess *sp, double);
#define VRT_done(sp, hand) \
do { \
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/vrt_obj.h
^
|
@@ -1,11 +1,15 @@
/*
- * $Id: vrt_obj.h 2554 2008-03-04 11:42:00Z des $
+ * $Id: vrt_obj.h 2066 2007-09-30 20:38:15Z phk $
*
* NB: This file is machine generated, DO NOT EDIT!
*
* Edit vcc_gen_obj.tcl instead
*/
+void VRT_l_backend_host(struct backend *, const char *);
+void VRT_l_backend_port(struct backend *, const char *);
+void VRT_l_backend_dnsttl(struct backend *, double);
+void VRT_l_backend_set(struct backend *, struct vrt_backend_entry *);
struct sockaddr * VRT_r_client_ip(const struct sess *);
struct sockaddr * VRT_r_server_ip(struct sess *);
const char * VRT_r_req_request(const struct sess *);
@@ -15,11 +19,9 @@
const char * VRT_r_req_proto(const struct sess *);
void VRT_l_req_proto(const struct sess *, const char *, ...);
void VRT_l_req_hash(struct sess *, const char *);
-struct director * VRT_r_req_backend(struct sess *);
-void VRT_l_req_backend(struct sess *, struct director *);
+struct backend * VRT_r_req_backend(struct sess *);
+void VRT_l_req_backend(struct sess *, struct backend *);
int VRT_r_req_restarts(const struct sess *);
-double VRT_r_req_grace(struct sess *);
-void VRT_l_req_grace(struct sess *, double);
const char * VRT_r_bereq_request(const struct sess *);
void VRT_l_bereq_request(const struct sess *, const char *, ...);
const char * VRT_r_bereq_url(const struct sess *);
@@ -38,12 +40,7 @@
void VRT_l_obj_cacheable(const struct sess *, unsigned);
double VRT_r_obj_ttl(const struct sess *);
void VRT_l_obj_ttl(const struct sess *, double);
-double VRT_r_obj_grace(const struct sess *);
-void VRT_l_obj_grace(const struct sess *, double);
-double VRT_r_obj_prefetch(const struct sess *);
-void VRT_l_obj_prefetch(const struct sess *, double);
double VRT_r_obj_lastuse(const struct sess *);
-const char * VRT_r_obj_hash(const struct sess *);
const char * VRT_r_resp_proto(const struct sess *);
void VRT_l_resp_proto(const struct sess *, const char *, ...);
int VRT_r_resp_status(const struct sess *);
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/vsb.h
^
|
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: vsb.h 2410 2008-01-30 10:24:54Z phk $
+ * $Id: vsb.h 1783 2007-07-30 08:03:42Z des $
* $FreeBSD: src/sys/sys/vsb.h,v 1.14 2004/07/09 11:35:30 des Exp $
*/
@@ -69,11 +69,11 @@
#endif
int vsb_putc(struct vsb *, int);
int vsb_trim(struct vsb *);
-int vsb_overflowed(const struct vsb *);
+int vsb_overflowed(struct vsb *);
void vsb_finish(struct vsb *);
char *vsb_data(struct vsb *);
int vsb_len(struct vsb *);
-int vsb_done(const struct vsb *);
+int vsb_done(struct vsb *);
void vsb_delete(struct vsb *);
#ifdef __cplusplus
};
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/include/vss.h
^
|
@@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: vss.h 2415 2008-01-31 11:57:51Z des $
+ * $Id: vss.h 2496 2008-02-17 09:26:32Z des $
*/
/* vss.c */
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnish/Makefile.am
^
|
@@ -1,4 +1,4 @@
-# $Id: Makefile.am 2471 2008-02-15 10:34:42Z phk $
+# $Id: Makefile.am 2564 2008-03-08 13:38:23Z des $
INCLUDES = -I$(top_srcdir)/include
@@ -12,10 +12,8 @@
cli_common.c \
crc32.c \
flopen.c \
- num.c \
time.c \
version.c \
- vlu.c \
vpf.c \
vsb.c \
vss.c \
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnish/argv.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: argv.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: argv.c 2564 2008-03-08 13:38:23Z des $
*
* const char **ParseArgv(const char *s, int comment)
* Parse a command like line into an argv[]
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnish/assert.c
^
|
@@ -26,13 +26,14 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: assert.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: assert.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
+#include <errno.h>
#include <string.h>
#include "libvarnish.h"
@@ -43,11 +44,8 @@
fprintf(stderr,
"Missing errorhandling code in %s(), %s line %d:\n"
- " Condition(%s) not true.\n",
- func, file, line, cond);
- if (err)
- fprintf(stderr,
- " errno = %d (%s)\n", err, strerror(err));
+ " Condition(%s) not true.\n"
+ " errno = %d (%s)\n", func, file, line, cond, err, strerror(err));
abort();
}
@@ -57,10 +55,7 @@
fprintf(stderr,
"Assert error in %s(), %s line %d:\n"
- " Condition(%s) not true.\n",
- func, file, line, cond);
- if (err)
- fprintf(stderr,
- " errno = %d (%s)\n", err, strerror(err));
+ " Condition(%s) not true.\n"
+ " errno = %d (%s)\n", func, file, line, cond, err, strerror(err));
abort();
}
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnish/binary_heap.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: binary_heap.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: binary_heap.c 2564 2008-03-08 13:38:23Z des $
*
* Implementation of a binary heap API
*
@@ -68,7 +68,7 @@
/* Implementation ----------------------------------------------------*/
static void
-binheap_update(const struct binheap *bh, unsigned u)
+binheap_update(struct binheap *bh, unsigned u)
{
assert(bh->magic == BINHEAP_MAGIC);
assert(u < bh->next);
@@ -99,7 +99,7 @@
}
static void
-binhead_swap(const struct binheap *bh, unsigned u, unsigned v)
+binhead_swap(struct binheap *bh, unsigned u, unsigned v)
{
void *p;
@@ -114,7 +114,7 @@
}
static unsigned
-binheap_trickleup(const struct binheap *bh, unsigned u)
+binheap_trickleup(struct binheap *bh, unsigned u)
{
unsigned v;
@@ -131,7 +131,7 @@
}
static void
-binheap_trickledown(const struct binheap *bh, unsigned u)
+binheap_trickledown(struct binheap *bh, unsigned u)
{
unsigned v1, v2;
@@ -184,7 +184,7 @@
u = bh->next++;
bh->array[u] = p;
binheap_update(bh, u);
- (void)binheap_trickleup(bh, u);
+ binheap_trickleup(bh, u);
}
void *
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnish/cli.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cli.c 2597 2008-03-12 13:46:34Z phk $
+ * $Id: cli.c 2564 2008-03-08 13:38:23Z des $
*
* Stuff for handling the CLI protocol
*/
@@ -35,7 +35,6 @@
#include <ctype.h>
#include <string.h>
-#include <stdlib.h>
#include <stdio.h>
#include <cli.h>
@@ -53,7 +52,8 @@
{
struct cli_proto *cp;
- if (av[2] == NULL || *av[2] == '-') {
+ if (av[2] == NULL) {
+ cli_out(cli, "Available commands:\n");
for (cp = priv; cp->request != NULL; cp++)
cli_out(cli, "%s\n", cp->syntax);
return;
@@ -64,8 +64,7 @@
return;
}
}
- cli_out(cli, "Unknown request.\nType 'help' for more info.\n");
- cli_result(cli, CLIS_UNKNOWN);
+ cli_param(cli);
}
void
@@ -78,7 +77,6 @@
cli_result(cli, CLIS_OK);
/* XXX: syslog commands */
av = ParseArgv(line, 0);
- AN(av);
do {
if (av[0] != NULL) {
cli_out(cli, "Syntax Error: %s\n", av[0]);
@@ -98,7 +96,7 @@
break;
if (cp->request == NULL) {
cli_out(cli,
- "Unknown request.\nType 'help' for more info.\n");
+ "Unknown request, type 'help' for more info.\n");
cli_result(cli, CLIS_UNKNOWN);
break;
}
@@ -132,28 +130,3 @@
} while (0);
FreeArgv(av);
}
-
-struct cli_proto *
-cli_concat(struct cli_proto *c1, struct cli_proto *c2)
-{
- struct cli_proto *c;
- int i1, i2;
-
- i1 = 0;
- for(c = c1; c != NULL && c->request != NULL; c++)
- i1++;
- i2 = 0;
- for(c = c2; c != NULL && c->request != NULL; c++)
- i2++;
-
- c = malloc(sizeof(*c) * (i1 + i2 + 1));
- if (c == NULL)
- return (c);
- if (c1 != NULL)
- memcpy(c, c1, sizeof(*c1) * i1);
- if (c2 != NULL)
- memcpy(c + i1, c2, sizeof(*c2) * i2);
- memset(c + i1 + i2, 0, sizeof(*c));
- return (c);
-}
-
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnish/cli_common.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cli_common.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: cli_common.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
@@ -34,6 +34,7 @@
#include <sys/types.h>
#include <sys/uio.h>
+#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <poll.h>
@@ -48,22 +49,20 @@
#include "vsb.h"
-#include "libvarnish.h"
-
#include "cli.h"
#include "cli_priv.h"
#include "cli_common.h"
void
-cli_out(const struct cli *cli, const char *fmt, ...)
+cli_out(struct cli *cli, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
if (cli != NULL)
- (void)vsb_vprintf(cli->sb, fmt, ap);
+ vsb_vprintf(cli->sb, fmt, ap);
else
- (void)vfprintf(stdout, fmt, ap);
+ vfprintf(stdout, fmt, ap);
va_end(ap);
}
@@ -87,7 +86,7 @@
}
int
-cli_writeres(int fd, const struct cli *cli)
+cli_writeres(int fd, struct cli *cli)
{
int i, l;
struct iovec iov[3];
@@ -146,8 +145,6 @@
unsigned u, v;
char *p;
- if (ptr != NULL)
- *ptr = NULL;
i = read_tmo(fd, res, CLI_LINE0_LEN, tmo);
if (i != CLI_LINE0_LEN) {
if (status != NULL)
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnish/crc32.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: crc32.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: crc32.c 2564 2008-03-08 13:38:23Z des $
*
* This CRC32 implementation is in the public domain.
*/
|
[-]
[+]
|
Deleted |
varnish-20080428.tar.bz2/lib/libvarnish/flint.lnt
^
|
@@ -1,90 +0,0 @@
--passes=8
-
-+libh mgt_event.h
-+libh ../../config.h
-
--emacro((???),va_arg) // the va_arg() macro can yield 415, 416, 661, 662
- // 796 and 797 (out-of-bounds errors).
--elib(123) // size is both a variable and a macro with args
--emacro(736, isnan) // isnanf
-
-
--header(../../config.h)
-
-// Fix strchr() semtics, it can only return NULL if arg2 != 0
--sem(strchr, 1p, type(1), 2n == 0 ? (@p < 1p) : (@p < 1p || @p == 0 ))
-
--sem(lbv_assert, r_no)
--sem(lbv_xxxassert, r_no)
--sem(WS_Init, custodial(2))
--sem(http_Setup, custodial(2))
-
--ffc // No automatic custody
-
--e763 // Redundant declaration for symbol '...' previously declared
--e726 // Extraneous comma ignored
--e728 // Symbol ... not explicitly initialized
--e716 // while(1) ...
--e785 // Too few initializers for aggregate
--e786 // String concatenation within initializer
-
--emacro(740, VTAILQ_PREV) // Unusual pointer cast (incompatible indirect types)
--emacro(740, VTAILQ_LAST) // Unusual pointer cast (incompatible indirect types)
--emacro((826), VTAILQ_PREV) // Suspicious pointer-to-pointer conversion (area too small)
--emacro((826), VTAILQ_LAST) // Suspicious pointer-to-pointer conversion (area too small)
--emacro(506, VTAILQ_FOREACH_SAFE) // constant value boolean
-
--esym(534, sprintf) // Ignoring return value of function
--esym(534, asprintf) // Ignoring return value of function
--esym(534, printf) // Ignoring return value of function
--esym(534, fprintf) // Ignoring return value of function
--esym(534, memset) // Ignoring return value of function
--esym(534, memcpy) // Ignoring return value of function
--esym(534, memmove) // Ignoring return value of function
--esym(534, strcpy) // Ignoring return value of function
--esym(534, vsb_printf) // Ignoring return value of function
--esym(534, vsb_cat) // Ignoring return value of function
--esym(534, vsb_bcat) // Ignoring return value of function
--esym(534, vsb_putc) // Ignoring return value of function
--esym(534, strcat) // Ignoring return value of function
--esym(534, strcpy) // Ignoring return value of function
--esym(534, strlcpy) // Ignoring return value of function
-
--emacro(506, isnan) // constant value boolean
--emacro(747, isnan) // significant coersion
--emacro(506, assert) // constant value boolean
--emacro(774, HTTPH) // always false
-
-// cache.h
--emacro(506, INCOMPL) // Constant value Boolean
-
-// cache_center.c
--efunc(525, CNT_Session) // Negative indentation from line
--efunc(525, http_FilterFields) // Negative indentation from line
--efunc(539, http_FilterFields) // Positive indentation from line
-
-// cache_vcl.c
--efunc(525, vcl_handlingname) // Negative indentation from line
--esym(528, vcl_handlingname) // Not referenced
--e641 // Converting enum 'cli_status_e' to int
-
-// Review all below this line ///////////////////////////////////////////////
-
--e732 // Loss of sign (arg. no. 2) (int to unsigned
--e737 // [45] Loss of sign in promotion from int to unsigned
--e713 // Loss of precision (assignment) (unsigned long long to long long)
--e574 // Signed-unsigned mix with relational
--e712 // Loss of precision (assignment) (long long to
--e747 // Significant prototype coercion (arg. no. 2) long
-
-/*
-
--e767 // Macro redef (system queue.h vs ours )
-
--e506 // Constant value boolean
--e818 // Pointer parameter '...' could be declared as pointing to const
--e774 // Boolean within 'if' always evaluates to False
--e534 // Ignoring return value of function
--e557 // unrecog format
-
-*/
|
[-]
[+]
|
Deleted |
varnish-20080428.tar.bz2/lib/libvarnish/flint.sh
^
|
@@ -1,29 +0,0 @@
-#!/bin/sh
-
-T=/tmp/_$$
-flexelint \
- -I/usr/include \
- -I. \
- -I../../include \
- flint.lnt \
- *.c > $T 2>&1
-
-for t in Error Warning Info
-do
- sed -n "/$t [0-9][0-9][0-9]:/s/.*\($t [0-9][0-9][0-9]\).*/\1/p" $T
-done | awk '
-$2 == 830 { next }
-$2 == 831 { next }
- {
- i=$2"_"$1
- h[i]++
- n++
- }
-END {
- printf "%5d %s\n", n, "Total"
- for (i in h)
- printf "%5d %s\n", h[i], i
- }
-' | sort -rn
-
-cat $T
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnish/flopen.c
^
|
@@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: flopen.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: flopen.c 2564 2008-03-08 13:38:23Z des $
* Derived from:
* $FreeBSD: src/lib/libutil/flopen.c,v 1.7 2007/05/23 12:09:33 des Exp $
*/
@@ -58,7 +58,7 @@
va_list ap;
va_start(ap, flags);
- mode = (mode_t)va_arg(ap, int); /* mode_t promoted to int */
+ mode = va_arg(ap, int); /* mode_t promoted to int */
va_end(ap);
}
@@ -78,32 +78,32 @@
if (fcntl(fd, operation, &lock) == -1) {
/* unsupported or interrupted */
serrno = errno;
- (void)close(fd);
+ close(fd);
errno = serrno;
return (-1);
}
if (stat(path, &sb) == -1) {
/* disappeared from under our feet */
- (void)close(fd);
+ close(fd);
continue;
}
if (fstat(fd, &fsb) == -1) {
/* can't happen [tm] */
serrno = errno;
- (void)close(fd);
+ close(fd);
errno = serrno;
return (-1);
}
if (sb.st_dev != fsb.st_dev ||
sb.st_ino != fsb.st_ino) {
/* changed under our feet */
- (void)close(fd);
+ close(fd);
continue;
}
if (trunc && ftruncate(fd, 0) != 0) {
/* can't happen [tm] */
serrno = errno;
- (void)close(fd);
+ close(fd);
errno = serrno;
return (-1);
}
|
[-]
[+]
|
Deleted |
varnish-20080428.tar.bz2/lib/libvarnish/num.c
^
|
@@ -1,175 +0,0 @@
-/*-
- * Copyright (c) 2008 Linpro 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.
- *
- * $Id$
- *
- * Deal with numbers with data storage suffix scaling
- */
-
-#include "config.h"
-
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-
-#include <libvarnish.h>
-
-const char *
-str2bytes(const char *p, uintmax_t *r, uintmax_t rel)
-{
- double fval;
- char *end;
-
- fval = strtod(p, &end);
- if (end == p || !isfinite(fval))
- return ("Invalid number");
-
- if (*end == '\0') {
- *r = (uintmax_t)fval;
- return (NULL);
- }
-
- if (end[0] == '%' && end[1] == '\0') {
- if (rel == 0)
- return ("Absolute number required");
- fval *= rel / 100.0;
- } else {
- /* accept a space before the multiplier */
- if (end[0] == ' ' && end[1] != '\0')
- ++end;
-
- switch (end[0]) {
- case 'k': case 'K':
- fval *= (uintmax_t)1 << 10;
- ++end;
- break;
- case 'm': case 'M':
- fval *= (uintmax_t)1 << 20;
- ++end;
- break;
- case 'g': case 'G':
- fval *= (uintmax_t)1 << 30;
- ++end;
- break;
- case 't': case 'T':
- fval *= (uintmax_t)1 << 40;
- ++end;
- break;
- case 'p': case 'P':
- fval *= (uintmax_t)1 << 50;
- ++end;
- break;
- case 'e': case 'E':
- fval *= (uintmax_t)1 << 60;
- ++end;
- break;
- }
-
- /* accept 'b' for 'bytes' */
- if (end[0] == 'b' || end[0] == 'B')
- ++end;
-
- if (end[0] != '\0')
- return ("Invalid suffix");
- }
-
- *r = (uintmax_t)round(fval);
- return (NULL);
-}
-
-#ifdef NUM_C_TEST
-#include <assert.h>
-#include <err.h>
-#include <stdio.h>
-#include <string.h>
-
-struct test_case {
- const char *str;
- uintmax_t rel;
- uintmax_t val;
-} test_cases[] = {
- { "1", (uintmax_t)0, (uintmax_t)1 },
- { "1B", (uintmax_t)0, (uintmax_t)1<<0 },
- { "1 B", (uintmax_t)0, (uintmax_t)1<<0 },
- { "1.3B", (uintmax_t)0, (uintmax_t)1 },
- { "1.7B", (uintmax_t)0, (uintmax_t)2 },
-
- { "1024", (uintmax_t)0, (uintmax_t)1024 },
- { "1k", (uintmax_t)0, (uintmax_t)1<<10 },
- { "1kB", (uintmax_t)0, (uintmax_t)1<<10 },
- { "1.3kB", (uintmax_t)0, (uintmax_t)1331 },
- { "1.7kB", (uintmax_t)0, (uintmax_t)1741 },
-
- { "1048576", (uintmax_t)0, (uintmax_t)1048576 },
- { "1M", (uintmax_t)0, (uintmax_t)1<<20 },
- { "1MB", (uintmax_t)0, (uintmax_t)1<<20 },
- { "1.3MB", (uintmax_t)0, (uintmax_t)1363149 },
- { "1.7MB", (uintmax_t)0, (uintmax_t)1782579 },
-
- { "1073741824", (uintmax_t)0, (uintmax_t)1073741824 },
- { "1G", (uintmax_t)0, (uintmax_t)1<<30 },
- { "1GB", (uintmax_t)0, (uintmax_t)1<<30 },
- { "1.3GB", (uintmax_t)0, (uintmax_t)1395864371 },
- { "1.7GB", (uintmax_t)0, (uintmax_t)1825361101 },
-
- { "1099511627776", (uintmax_t)0, (uintmax_t)1099511627776ULL },
- { "1T", (uintmax_t)0, (uintmax_t)1<<40 },
- { "1TB", (uintmax_t)0, (uintmax_t)1<<40 },
- { "1.3TB", (uintmax_t)0, (uintmax_t)1429365116109ULL },
- { "1.7TB", (uintmax_t)0, (uintmax_t)1869169767219ULL },
-
- { "1%", (uintmax_t)1024, (uintmax_t)10 },
- { "2%", (uintmax_t)1024, (uintmax_t)20 },
- { "3%", (uintmax_t)1024, (uintmax_t)31 },
- /* TODO: add more */
-
- { 0, 0, 0 },
-};
-
-int
-main(int argc, char *argv[])
-{
- struct test_case *tc;
- uintmax_t val;
- int ec;
-
- (void)argc;
- for (ec = 0, tc = test_cases; tc->str; ++tc) {
- str2bytes(tc->str, &val, tc->rel);
- if (val != tc->val) {
- printf("%s: str2bytes(\"%s\", %ju) %ju != %ju\n",
- *argv, tc->str, tc->rel, val, tc->val);
- ++ec;
- }
- }
- /* TODO: test invalid strings */
- if (!ec)
- printf("OK\n");
- return (ec > 0);
-}
-#endif
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnish/time.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: time.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: time.c 2564 2008-03-08 13:38:23Z des $
*
* Semi-trivial functions to handle HTTP header timestamps according to
* RFC 2616 section 3.3.
@@ -95,8 +95,8 @@
time_t tt;
tt = (time_t) t;
- (void)gmtime_r(&tt, &tm);
- AN(strftime(p, 30, "%a, %d %b %Y %T GMT", &tm));
+ gmtime_r(&tt, &tm);
+ strftime(p, 30, "%a, %d %b %Y %T GMT", &tm);
}
/* XXX: add statistics ? */
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnish/version.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: version.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: version.c 2564 2008-03-08 13:38:23Z des $
*
* Display a standardized version message.
*/
|
[-]
[+]
|
Deleted |
varnish-20080428.tar.bz2/lib/libvarnish/vlu.c
^
|
@@ -1,131 +0,0 @@
-/*-
- * Copyright (c) 2005-2008 Poul-Henning Kamp <phk@freebsd.org>
- * All rights reserved.
- *
- * 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 AUTHORS 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 THE AUTHORS 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.
- *
- * $Id: vpf.h 1410 2007-05-11 11:17:09Z des $
- *
- * Functions for assembling a bytestream into text-lines and calling
- * a function on each.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <unistd.h>
-#include "vlu.h"
-#include "miniobj.h"
-
-struct vlu {
- unsigned magic;
-#define LINEUP_MAGIC 0x8286661
- char *buf;
- unsigned bufl;
- unsigned bufp;
- void *priv;
- vlu_f *func;
-};
-
-struct vlu *
-VLU_New(void *priv, vlu_f *func, unsigned bufsize)
-{
- struct vlu *l;
-
- if (bufsize == 0)
- bufsize = BUFSIZ;
- ALLOC_OBJ(l, LINEUP_MAGIC);
- if (l != NULL) {
- l->func = func;
- l->priv = priv;
- l->bufl = bufsize - 1;
- l->buf = malloc(l->bufl + 1);
- if (l->buf == NULL) {
- FREE_OBJ(l);
- l = NULL;
- }
- }
- return (l);
-}
-
-void
-VLU_Destroy(struct vlu *l)
-{
-
- CHECK_OBJ_NOTNULL(l, LINEUP_MAGIC);
- free(l->buf);
- FREE_OBJ(l);
-}
-
-static int
-LineUpProcess(struct vlu *l)
-{
- char *p, *q;
- int i;
-
- l->buf[l->bufp] = '\0';
- for (p = l->buf; *p != '\0'; p = q) {
- q = strchr(p, '\n');
- if (q == NULL)
- break;
- *q++ = '\0';
- i = l->func(l->priv, p);
- if (i != 0)
- return (i);
- }
- if (*p != '\0') {
- q = strchr(p, '\0');
- assert(q != NULL);
- l->bufp = (unsigned)(q - p);
- memmove(l->buf, p, l->bufp);
- l->buf[l->bufp] = '\0';
- } else
- l->bufp = 0;
- return (0);
-}
-
-int
-VLU_Fd(int fd, struct vlu *l)
-{
- int i;
-
- CHECK_OBJ_NOTNULL(l, LINEUP_MAGIC);
- i = read(fd, l->buf + l->bufp, l->bufl - l->bufp);
- if (i <= 0)
- return (-1);
- l->bufp += i;
- return (LineUpProcess(l));
-}
-
-int
-VLU_File(FILE *f, struct vlu *l)
-{
- char *p;
-
- CHECK_OBJ_NOTNULL(l, LINEUP_MAGIC);
- p = fgets(l->buf + l->bufp, l->bufl - l->bufp, f);
- if (p == NULL)
- return (-1);
- l->bufp = strlen(l->buf);
- return (LineUpProcess(l));
-}
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnish/vpf.c
^
|
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: vpf.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: vpf.c 2564 2008-03-08 13:38:23Z des $
* Derived from:
* $FreeBSD: src/lib/libutil/pidfile.c,v 1.5 2007/05/11 11:10:05 des Exp $
*/
@@ -45,7 +45,6 @@
#include "compat/strlcpy.h"
#endif
-#include "libvarnish.h" /* XXX: for assert() */
#include "flopen.h"
#include "vpf.h"
@@ -59,7 +58,7 @@
static int _vpf_remove(struct pidfh *pfh, int freeit);
static int
-vpf_verify(const struct pidfh *pfh)
+vpf_verify(struct pidfh *pfh)
{
struct stat sb;
@@ -87,7 +86,7 @@
i = read(fd, buf, sizeof(buf) - 1);
error = errno; /* Remember errno in case close() wants to change it. */
- (void)close(fd);
+ close(fd);
if (i == -1)
return (error);
buf[i] = '\0';
@@ -116,11 +115,8 @@
"/var/run/%s.pid", getprogname());
else
#endif
- {
- assert(path != NULL);
len = snprintf(pfh->pf_path, sizeof(pfh->pf_path),
"%s", path);
- }
if (len >= (int)sizeof(pfh->pf_path)) {
free(pfh);
errno = ENAMETOOLONG;
@@ -150,8 +146,8 @@
*/
if (fstat(fd, &sb) == -1) {
error = errno;
- (void)unlink(pfh->pf_path);
- (void)close(fd);
+ unlink(pfh->pf_path);
+ close(fd);
free(pfh);
errno = error;
return (NULL);
@@ -188,16 +184,15 @@
*/
if (ftruncate(fd, 0) == -1) {
error = errno;
- (void)_vpf_remove(pfh, 0);
+ _vpf_remove(pfh, 0);
errno = error;
return (-1);
}
- error = snprintf(pidstr, sizeof(pidstr), "%u", getpid());
- assert(error < sizeof pidstr);
+ snprintf(pidstr, sizeof(pidstr), "%u", getpid());
if (pwrite(fd, pidstr, strlen(pidstr), 0) != (ssize_t)strlen(pidstr)) {
error = errno;
- (void)_vpf_remove(pfh, 0);
+ _vpf_remove(pfh, 0);
errno = error;
return (-1);
}
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnish/vsb.c
^
|
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: vsb.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: vsb.c 2564 2008-03-08 13:38:23Z des $
* $FreeBSD: src/sys/kern/subr_sbuf.c,v 1.30 2005/12/23 11:49:53 phk Exp $
*/
@@ -53,7 +53,7 @@
#define VSB_ISFINISHED(s) ((s)->s_flags & VSB_FINISHED)
#define VSB_HASOVERFLOWED(s) ((s)->s_flags & VSB_OVERFLOWED)
#define VSB_HASROOM(s) ((s)->s_len < (s)->s_size - 1)
-#define VSB_FREESPACE(s) ((s)->s_size - ((s)->s_len + 1))
+#define VSB_FREESPACE(s) ((s)->s_size - (s)->s_len - 1)
#define VSB_CANEXTEND(s) ((s)->s_flags & VSB_AUTOEXTEND)
/*
@@ -375,7 +375,7 @@
return (-1);
}
if (c != '\0')
- s->s_buf[s->s_len++] = (char)c;
+ s->s_buf[s->s_len++] = c;
return (0);
}
@@ -401,7 +401,7 @@
* Check if an vsb overflowed
*/
int
-vsb_overflowed(const struct vsb *s)
+vsb_overflowed(struct vsb *s)
{
return VSB_HASOVERFLOWED(s);
}
@@ -469,7 +469,7 @@
* Check if an vsb has been finished.
*/
int
-vsb_done(const struct vsb *s)
+vsb_done(struct vsb *s)
{
return(VSB_ISFINISHED(s));
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnish/vss.c
^
|
@@ -27,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: vss.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: vss.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
@@ -60,10 +60,7 @@
int va_socktype;
int va_protocol;
socklen_t va_addrlen;
- union {
- struct sockaddr_storage _storage;
- struct sockaddr sa;
- } va_addr;
+ struct sockaddr_storage va_addr;
};
/*
@@ -184,7 +181,7 @@
val = 1;
if (setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof val) != 0) {
perror("setsockopt(SO_REUSEADDR, 1)");
- (void)close(sd);
+ close(sd);
return (-1);
}
#ifdef IPV6_V6ONLY
@@ -193,18 +190,18 @@
if (va->va_family == AF_INET6 &&
setsockopt(sd, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof val) != 0) {
perror("setsockopt(IPV6_V6ONLY, 1)");
- (void)close(sd);
+ close(sd);
return (-1);
}
#endif
- if (bind(sd, &va->va_addr.sa, va->va_addrlen) != 0) {
+ if (bind(sd, (const struct sockaddr *)&va->va_addr, va->va_addrlen) != 0) {
perror("bind()");
- (void)close(sd);
+ close(sd);
return (-1);
}
if (listen(sd, depth) != 0) {
perror("listen()");
- (void)close(sd);
+ close(sd);
return (-1);
}
return (sd);
@@ -224,9 +221,9 @@
perror("socket()");
return (-1);
}
- if (connect(sd, &va->va_addr.sa, va->va_addrlen) != 0) {
+ if (connect(sd, (const struct sockaddr *)&va->va_addr, va->va_addrlen) != 0) {
perror("connect()");
- (void)close(sd);
+ close(sd);
return (-1);
}
return (sd);
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnish/vtmpfile.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: vtmpfile.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: vtmpfile.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
@@ -42,8 +42,7 @@
vtmpfile(char *template)
{
char *b, *e, *p;
- int fd;
- char ran;
+ int fd, ran;
for (b = template; *b != '#'; ++b)
/* nothing */ ;
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnishapi/Makefile.am
^
|
@@ -1,4 +1,4 @@
-# $Id: Makefile.am 2455 2008-02-13 13:55:39Z des $
+# $Id: Makefile.am 2564 2008-03-08 13:38:23Z des $
INCLUDES = -I$(top_srcdir)/include
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnishapi/base64.c
^
|
@@ -3,7 +3,7 @@
*
* This file is in the public domain.
*
- * $Id: base64.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: base64.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnishapi/instance.c
^
|
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: instance.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: instance.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnishapi/shmlog.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: shmlog.c 2591 2008-03-11 09:48:27Z des $
+ * $Id: shmlog.c 2578 2008-03-09 15:26:31Z des $
*/
#include "config.h"
@@ -66,7 +66,7 @@
/* for -r option */
FILE *fi;
- unsigned char rbuf[SHMLOG_NEXTTAG + 255 + 1];
+ unsigned char rbuf[5 + 255 + 1];
int b_opt;
int c_opt;
@@ -205,7 +205,7 @@
if (!vd->d_opt && vd->fi == NULL) {
for (p = vd->ptr; *p != SLT_ENDMARKER; )
- p += SHMLOG_LEN(p) + SHMLOG_NEXTTAG;
+ p += p[1] + 5;
vd->ptr = p;
}
return (0);
@@ -228,16 +228,15 @@
vsl_nextlog(struct VSL_data *vd, unsigned char **pp)
{
unsigned char *p;
- unsigned w, l;
+ unsigned w;
int i;
CHECK_OBJ_NOTNULL(vd, VSL_MAGIC);
if (vd->fi != NULL) {
- i = fread(vd->rbuf, SHMLOG_DATA, 1, vd->fi);
+ i = fread(vd->rbuf, 4, 1, vd->fi);
if (i != 1)
return (-1);
- i = fread(vd->rbuf + SHMLOG_DATA,
- SHMLOG_LEN(vd->rbuf) + 1, 1, vd->fi);
+ i = fread(vd->rbuf + 4, vd->rbuf[1] + 1, 1, vd->fi);
if (i != 1)
return (-1);
*pp = vd->rbuf;
@@ -257,8 +256,7 @@
usleep(SLEEP_USEC);
continue;
}
- l = SHMLOG_LEN(p);
- vd->ptr = p + l + SHMLOG_NEXTTAG;
+ vd->ptr = p + p[1] + 5;
*pp = p;
return (1);
}
@@ -271,7 +269,7 @@
{
unsigned char *p;
regmatch_t rm;
- unsigned u, l;
+ unsigned u;
int i;
CHECK_OBJ_NOTNULL(vd, VSL_MAGIC);
@@ -279,9 +277,8 @@
i = vsl_nextlog(vd, &p);
if (i != 1)
return (i);
- u = SHMLOG_ID(p);
- l = SHMLOG_LEN(p);
- switch(p[SHMLOG_TAG]) {
+ u = (p[2] << 8) | p[3];
+ switch(p[0]) {
case SLT_SessionOpen:
case SLT_ReqStart:
vd->map[u] |= M_CLIENT;
@@ -302,11 +299,11 @@
if (--vd->keep == 0)
return (0);
}
- if (vd->map[p[SHMLOG_TAG]] & M_SELECT) {
+ if (vd->map[p[0]] & M_SELECT) {
*pp = p;
return (1);
}
- if (vd->map[p[SHMLOG_TAG]] & M_SUPPRESS)
+ if (vd->map[p[0]] & M_SUPPRESS)
continue;
if (vd->b_opt && !(vd->map[u] & M_BACKEND))
continue;
@@ -314,17 +311,15 @@
continue;
if (vd->regincl != NULL) {
rm.rm_so = 0;
- rm.rm_eo = l;
- i = regexec(vd->regincl,
- (char *)p + SHMLOG_DATA, 1, &rm, 0);
+ rm.rm_eo = p[1];
+ i = regexec(vd->regincl, (char *)p + 4, 1, &rm, 0);
if (i == REG_NOMATCH)
continue;
}
if (vd->regexcl != NULL) {
rm.rm_so = 0;
- rm.rm_eo = l;
- i = regexec(vd->regexcl,
- (char *)p + SHMLOG_DATA, 1, &rm, 0);
+ rm.rm_eo = p[1];
+ i = regexec(vd->regexcl, (char *)p + 4, 1, &rm, 0);
if (i != REG_NOMATCH)
continue;
}
@@ -339,7 +334,7 @@
VSL_Dispatch(struct VSL_data *vd, vsl_handler *func, void *priv)
{
int i;
- unsigned u, l;
+ unsigned u;
unsigned char *p;
CHECK_OBJ_NOTNULL(vd, VSL_MAGIC);
@@ -347,12 +342,11 @@
i = VSL_NextLog(vd, &p);
if (i <= 0)
return (i);
- u = SHMLOG_ID(p);
- l = SHMLOG_LEN(p);
+ u = (p[2] << 8) | p[3];
if (func(priv,
- p[SHMLOG_TAG], u, l,
+ p[0], u, p[1],
vd->map[u] & (VSL_S_CLIENT|VSL_S_BACKEND),
- (char *)p + SHMLOG_DATA))
+ (char *)p + 4))
return (1);
}
}
@@ -363,15 +357,11 @@
VSL_H_Print(void *priv, enum shmlogtag tag, unsigned fd, unsigned len, unsigned spec, const char *ptr)
{
FILE *fo = priv;
- int type;
assert(fo != NULL);
-
- type = (spec & VSL_S_CLIENT) ? 'c' :
- (spec & VSL_S_BACKEND) ? 'b' : '-';
-
if (tag == SLT_Debug) {
- fprintf(fo, "%5d %-12s %c \"", fd, VSL_tags[tag], type);
+ fprintf(fo, "%5d %-12s %c \"", fd, VSL_tags[tag],
+ ((spec & VSL_S_CLIENT) ? 'c' : (spec & VSL_S_BACKEND) ? 'b' : ' '));
while (len-- > 0) {
if (*ptr >= ' ' && *ptr <= '~')
fprintf(fo, "%c", *ptr);
@@ -382,7 +372,10 @@
fprintf(fo, "\"\n");
return (0);
}
- fprintf(fo, "%5d %-12s %c %.*s\n", fd, VSL_tags[tag], type, len, ptr);
+ fprintf(fo, "%5d %-12s %c %.*s\n",
+ fd, VSL_tags[tag],
+ ((spec & VSL_S_CLIENT) ? 'c' : (spec & VSL_S_BACKEND) ? 'b' : ' '),
+ len, ptr);
return (0);
}
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnishcompat/Makefile.am
^
|
@@ -1,4 +1,4 @@
-# $Id: Makefile.am 2455 2008-02-13 13:55:39Z des $
+# $Id: Makefile.am 2564 2008-03-08 13:38:23Z des $
INCLUDES = -I$(top_srcdir)/include
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnishcompat/asprintf.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: asprintf.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: asprintf.c 2564 2008-03-08 13:38:23Z des $
*
*/
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnishcompat/daemon.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: daemon.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: daemon.c 2564 2008-03-08 13:38:23Z des $
* Derived from:
* $FreeBSD: src/lib/libc/gen/daemon.c,v 1.8 2007/01/09 00:27:53 imp Exp $
*/
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnishcompat/setproctitle.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: setproctitle.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: setproctitle.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnishcompat/srandomdev.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: srandomdev.c 2528 2008-02-21 21:14:57Z des $
+ * $Id: srandomdev.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
@@ -49,13 +49,13 @@
unsigned int seed;
int fd;
- if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 ||
- (fd = open("/dev/random", O_RDONLY)) >= 0) {
+ if ((fd = open("/dev/random", O_RDONLY)) >= 0) {
read(fd, &seed, sizeof seed);
close(fd);
} else {
gettimeofday(&tv, NULL);
- seed = (getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec;
+ /* NOTE: intentional use of uninitialized variable */
+ seed ^= (getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec;
}
srandom(seed);
}
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnishcompat/strlcat.c
^
|
@@ -1,4 +1,4 @@
-/* $Id: strlcat.c 2455 2008-02-13 13:55:39Z des $ */
+/* $Id: strlcat.c 2564 2008-03-08 13:38:23Z des $ */
/* $OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $ */
/*
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnishcompat/strlcpy.c
^
|
@@ -1,4 +1,4 @@
-/* $Id: strlcpy.c 2455 2008-02-13 13:55:39Z des $ */
+/* $Id: strlcpy.c 2564 2008-03-08 13:38:23Z des $ */
/* $OpenBSD: strlcpy.c,v 1.10 2005/08/08 08:05:37 espie Exp $ */
/*
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnishcompat/strndup.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: strndup.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: strndup.c 2564 2008-03-08 13:38:23Z des $
*
*/
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnishcompat/vasprintf.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: vasprintf.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: vasprintf.c 2564 2008-03-08 13:38:23Z des $
*
*/
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvarnishcompat/vis.c
^
|
@@ -28,7 +28,7 @@
*
* @(#)vis.c 8.1 (Berkeley) 7/19/93
* $FreeBSD: src/lib/libc/gen/vis.c,v 1.13 2003/10/30 12:41:50 phk Exp $
- * $Id: vis.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: vis.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvcl/Makefile.am
^
|
@@ -1,4 +1,4 @@
-# $Id: Makefile.am 2455 2008-02-13 13:55:39Z des $
+# $Id: Makefile.am 2564 2008-03-08 13:38:23Z des $
INCLUDES = -I$(top_srcdir)/include
|
[-]
[+]
|
Added |
varnish-20080428.tar.bz2/lib/libvcl/sample.vcl
^
|
@@ -0,0 +1,109 @@
+
+acl rfc1918 {
+ 10.0.0.0/8;
+ 172.16.0.0/12;
+ 192.168.0.0/16;
+}
+
+sub request_policy {
+
+ if (client.ip == 10.1.2.3) {
+ no_cache;
+ finish;
+ }
+
+ if (client.ip ~ rfc1918) {
+ no_cache;
+ finish;
+ }
+
+ if (req.url.host ~ "cnn.no$") {
+ rewrite "cnn.no$" "vg.no";
+ }
+
+ if (req.url.path ~ "cgi-bin") {
+ no_cache;
+ }
+
+ if (req.useragent ~ "spider") {
+ no_new_cache;
+ }
+
+# comment
+
+ if (backend.response_time <= 0.8s) {
+ set req.ttlfactor = 1.5;
+ } elseif (backend.response_time > 1.5s) {
+ set req.ttlfactor = 2.0;
+ } elseif (backend.response_time > 2.5m) {
+ set req.ttlfactor = 5.0;
+ }
+
+ /*
+ * the program contains no references to
+ * maxage, s-maxage and expires, so the
+ * default handling (RFC2616) applies
+ */
+}
+
+backend vg {
+ set backend.ip = 10.0.0.100;
+ set backend.timeout = 4s;
+ set backend.bandwidth = 2000Mb/s;
+}
+
+backend chat {
+ set backend.ip = 10.0.0.4;
+ set backend.timeout = 4s;
+ set backend.bandwidth = 2000Mb/s;
+}
+
+sub bail {
+ error 404 "Bailing out";
+ finish;
+}
+
+sub fetch_policy {
+
+ if (!req.url.host ~ "/vg.no$/") {
+ set req.backend = vg;
+ } else {
+ /* XXX: specify 404 page url ? */
+ error 404;
+ }
+
+ if (backend.response_time > 2.0s) {
+ if (req.url.path ~ "/landbrugspriser/") {
+ call bail;
+ }
+ }
+ fetch;
+ if (backend.down) {
+ if (obj.exist) {
+ set obj.ttl += 10m;
+ finish;
+ }
+ switch_config ohhshit;
+ }
+ if (obj.result == 404) {
+ error 300 "http://www.vg.no";
+ }
+ if (obj.result != 200) {
+ finish;
+ }
+ if (obj.size > 256kb) {
+ no_cache;
+ } else if (obj.size > 32kb && obj.ttl < 2m) {
+ set obj.ttl = 5m;
+ }
+ if (backend.response_time > 2.0s) {
+ set obj.ttl *= 2.0;
+ }
+}
+
+sub prefetch_policy {
+
+ if (obj.usage < 10 && obj.ttl < 5m) {
+ fetch;
+ }
+}
|
[-]
[+]
|
Added |
varnish-20080428.tar.bz2/lib/libvcl/syntax.txt
^
|
@@ -0,0 +1,201 @@
+# Manually maintained syntax description of VCL
+#
+# $Id: syntax.txt 1657 2007-07-05 21:08:15Z phk $
+#
+
+vcl_program:
+ prog_element
+ vcl_program prog_element
+
+prog_element:
+ acl
+ function
+ backend
+
+function:
+ 'sub' ident compound
+
+compound:
+ '{' statements '}'
+
+statements:
+ statement
+ statements statement
+
+statement:
+ compound
+ if_stmt
+ action
+ 'C{' inline_c_src '}C'
+
+if_stmt:
+ 'if' conditional compound elseifparts elsepart
+
+elseifparts:
+ <none>
+ elseifpart
+ elseifparts elseifpart
+
+elseifpart:
+ 'elseif' conditional compound
+
+elsepart:
+ <none>
+ 'else' compound
+
+conditional:
+ '(' cond_0 ')'
+
+cond_0:
+ cond_1
+ cond_0 '||' cond_1
+
+cond_1:
+ cond_2
+ cond_1 '&&' cond_2
+
+cond_2:
+ cond_3
+ '!' cond_3
+
+cond_3:
+ '(' cond_0 ')'
+ var_int cond_int
+ var_size cond_size
+ var_bool
+ var_ip cond_ip
+ var_string cond_string
+ var_time cond_time
+ var_backend
+
+cond_int:
+ '==' cnum
+ '!=' cnum
+ '<=' cnum
+ '>=' cnum
+ '<' cnum
+ '>' cnum
+
+cond_size:
+ cond_int size_unit
+
+conf_time:
+ cond_int time_unit
+
+time_unit:
+ 's'
+ 'm'
+ 'h'
+ 'd'
+
+size_unit:
+ 'kb'
+ 'mb'
+ 'Mb'
+ 'gb'
+ 'Gb'
+
+cond_string:
+ '~' regexp
+ '==' cstr
+ '!=' cstr
+
+cond_ip:
+
+regexp:
+ cstr
+
+backend:
+ 'backend' ident '{' be_decls '}'
+
+be_decls:
+ be_decl
+ be_decls be_decl
+
+be_decl:
+ 'set' be_string '=' cstr ';'
+ 'set' be_time '=' cnum time_unit ';'
+
+action:
+ 'no_new_cache' ';'
+ 'no_cache' ';'
+ return_action ';'
+ 'error' cnum cstr ';'
+ 'error' cstr ';'
+ 'error' cnum ';'
+ 'error' ';'
+ 'switch_config' ident ';'
+ 'call' ident ';'
+ 'rewrite' cstr cstr ';'
+ 'set' assignment ';'
+ 'remove' variable ';'
+
+# see variable 'returns' in vcc_gen_fixed_token.tcl
+return_action:
+ 'lookup'
+ 'hash'
+ 'pipe'
+ 'pass'
+ 'fetch'
+ 'insert'
+ 'deliver'
+ 'discard'
+
+assignment:
+ var_int ratio
+ var_int assign_int
+ var_size ratio
+ var_size assign_int size_unit
+ var_rate ratio
+ var_rate assign_int size_unit '/' time_unit
+ var_time ratio
+ var_time assign_int time_unit
+ var_float ratio
+ var_float '+=' double
+ var_float '-=' double
+ var_float '=' double
+ var_backend '=' ident
+ var_string '=' stringval
+ var_string '+=' stringval
+
+assign_int:
+ '+=' cnum
+ '-=' cnum
+ '=' cnum
+
+
+ratio:
+ '*=' double
+ '/=' double
+
+acl:
+ 'acl' ident '{' rules '}'
+
+rules:
+ rule
+ rules rule
+
+rule:
+ '(' not rule0 ')' ';'
+ not rule0 ';'
+
+not:
+ <nothing>
+ '!'
+
+rule0:
+ cstr
+ cstr '/' cnum
+ '!' cstr
+
+stringval:
+ cstr
+ var_string
+
+cstr: (string constant)
+
+cnum: (numeric constant)
+
+double: (floating point constant)
+
+ident: (identifier)
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvcl/vcc_acl.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: vcc_acl.c 2479 2008-02-15 12:42:48Z phk $
+ * $Id: vcc_acl.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
@@ -75,7 +75,6 @@
vcc_NextToken(tl);
ExpectErr(tl, CNUM);
mask = vcc_UintVal(tl);
- vcc_NextToken(tl);
}
Fh(tl, 1, "{ %u, %u, %u, ", not, mask, para);
EncToken(tl->fh, t);
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvcl/vcc_action.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: vcc_action.c 2607 2008-03-19 12:27:43Z des $
+ * $Id: vcc_action.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
@@ -97,10 +97,9 @@
unsigned a;
vcc_NextToken(tl);
- if (tl->t->tok == CNUM) {
+ if (tl->t->tok == CNUM)
a = vcc_UintVal(tl);
- vcc_NextToken(tl);
- } else
+ else
a = 0;
Fb(tl, 1, "VRT_error(sp, %u", a);
if (tl->t->tok == CSTR) {
@@ -159,7 +158,6 @@
case SIZE:
case RATE:
case TIME:
- case RTIME:
case FLOAT:
if (tl->t->tok != '=')
Fb(tl, 0, "%s %c ", vp->rname, *tl->t->b);
@@ -175,18 +173,15 @@
case '=':
if (vp->fmt == TIME)
vcc_TimeVal(tl);
- else if (vp->fmt == RTIME)
- vcc_RTimeVal(tl);
else if (vp->fmt == SIZE)
vcc_SizeVal(tl);
else if (vp->fmt == RATE)
vcc_RateVal(tl);
else if (vp->fmt == FLOAT)
Fb(tl, 0, "%g", vcc_DoubleVal(tl));
- else if (vp->fmt == INT) {
+ else if (vp->fmt == INT)
Fb(tl, 0, "%u", vcc_UintVal(tl));
- vcc_NextToken(tl);
- } else {
+ else {
vsb_printf(tl->sb, "Cannot assign this variable type.\n");
vcc_ErrWhere(tl, vt);
return;
@@ -276,7 +271,7 @@
/*--------------------------------------------------------------------*/
static void
-parse_unset(struct tokenlist *tl)
+parse_remove(struct tokenlist *tl)
{
struct var *vp;
@@ -286,7 +281,7 @@
ERRCHK(tl);
assert(vp != NULL);
if (vp->fmt != STRING || vp->hdr == NULL) {
- vsb_printf(tl->sb, "Only http header lines can be unset.\n");
+ vsb_printf(tl->sb, "Only http header lines can be removed.\n");
vcc_ErrWhere(tl, tl->t);
return;
}
@@ -349,6 +344,8 @@
vcc_NextToken(tl);
Fb(tl, 1, "VRT_ESI(sp);\n");
+ Expect(tl, ';');
+ vcc_NextToken(tl);
}
/*--------------------------------------------------------------------*/
@@ -367,8 +364,7 @@
#undef VCL_RET_MAC_E
{ "call", parse_call },
{ "set", parse_set },
- { "unset", parse_unset },
- { "remove", parse_unset }, /* backward compatibility */
+ { "remove", parse_remove },
{ "purge_url", parse_purge_url },
{ "purge_hash", parse_purge_hash },
{ "esi", parse_esi },
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvcl/vcc_backend.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: vcc_backend.c 2519 2008-02-20 10:59:25Z phk $
+ * $Id: vcc_backend.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
@@ -36,7 +36,6 @@
#include <netdb.h>
#include <stdio.h>
-#include <stdarg.h>
#include <string.h>
#include "vsb.h"
@@ -72,423 +71,290 @@
*/
static void
-vcc_EmitBeIdent(struct vsb *v, const struct token *qual, int serial, const struct token *first, const struct token *last)
+vcc_EmitBeIdent(struct tokenlist *tl, struct token *first, struct token *last)
{
- vsb_printf(v, "\t.ident =");
- if (serial != 0 && qual != NULL) {
- vsb_printf(v, "\n\t \"%.*s \"", PF(qual));
- qual = VTAILQ_NEXT(qual, list);
- vsb_printf(v, "\n\t \"%.*s \"", PF(qual));
- vsb_printf(v, "\n\t \":: %d :: \"", serial);
- }
+ Fc(tl, 0, "\t.ident =");
while (first != last) {
if (first->dec != NULL)
- vsb_printf(v, "\n\t \"\\\"\" %.*s \"\\\" \"",
+ Fc(tl, 0, "\n\t \"\\\"\" %.*s \"\\\" \"",
PF(first));
else
- vsb_printf(v, "\n\t \"%.*s \"", PF(first));
+ Fc(tl, 0, "\n\t \"%.*s \"", PF(first));
first = VTAILQ_NEXT(first, list);
}
- vsb_printf(v, ",\n");
-}
-
-/*--------------------------------------------------------------------
- * Helper functions to complain about duplicate and missing fields
- */
-
-struct fld_spec {
- const char *name;
- struct token *found;
-};
-
-static void
-vcc_ResetFldSpec(struct fld_spec *f)
-{
-
- for (; f->name != NULL; f++)
- f->found = NULL;
-}
-
-static struct fld_spec *
-vcc_FldSpec(struct tokenlist *tl, const char *first, ...)
-{
- struct fld_spec f[100], *r;
- int n = 0;
- va_list ap;
- const char *p;
-
- f[n++].name = first;
- va_start(ap, first);
- while (1) {
- p = va_arg(ap, const char *);
- if (p == NULL)
- break;
- f[n++].name = p;
- assert(n < 100);
- }
- va_end(ap);
- f[n++].name = NULL;
-
- vcc_ResetFldSpec(f);
-
- r = TlAlloc(tl, sizeof *r * n);
- memcpy(r, f, n * sizeof *r);
- return (r);
+ Fc(tl, 0, ",\n");
}
-
-static void
-vcc_IsField(struct tokenlist *tl, struct token **t, struct fld_spec *fs)
-{
- struct token *t_field;
-
- ExpectErr(tl, '.');
- vcc_NextToken(tl);
- ExpectErr(tl, ID);
- t_field = tl->t;
- *t = t_field;
- vcc_NextToken(tl);
- ExpectErr(tl, '=');
- vcc_NextToken(tl);
-
- for (; fs->name != NULL; fs++) {
- if (!vcc_IdIs(t_field, fs->name + 1))
- continue;
- if (fs->found == NULL) {
- fs->found = t_field;
- return;
- }
- vsb_printf(tl->sb, "Field ");
- vcc_ErrToken(tl, t_field);
- vsb_printf(tl->sb, " redefined at:\n");
- vcc_ErrWhere(tl, t_field);
- vsb_printf(tl->sb, "\nFirst defined at:\n");
- vcc_ErrWhere(tl, fs->found);
- return;
- }
- vsb_printf(tl->sb, "Unknown field: ");
- vcc_ErrToken(tl, t_field);
- vsb_printf(tl->sb, " at\n");
- vcc_ErrWhere(tl, t_field);
- return;
-}
-
-static void
-vcc_FieldsOk(struct tokenlist *tl, const struct fld_spec *fs)
-{
- int ok = 1;
-
- for (; fs->name != NULL; fs++) {
- if (*fs->name == '!' && fs->found == NULL) {
- vsb_printf(tl->sb,
- "Mandatory field .'%s' missing.\n", fs->name + 1);
- ok = 0;
- }
- }
- if (!ok) {
- vcc_ErrWhere(tl, tl->t);
- }
- return;
-}
-
-
-/*--------------------------------------------------------------------
- * Parse and emit a backend host specification.
- *
- * The syntax is the following:
- *
- * backend_spec:
- * name_of_backend # by reference
- * '{' be_elements '}' # by specification
- *
- * be_elements:
- * be_element
- * be_element be_elements
- *
- * be_element:
- * '.' name '=' value ';'
- *
- * The struct vrt_backend is emitted to Fh().
- */
-
-static void
-vcc_ParseBackendHost(struct tokenlist *tl, int *nbh, const struct token *qual, int serial)
+void
+vcc_ParseSimpleBackend(struct tokenlist *tl)
{
- struct token *t_field;
- struct token *t_first;
+ struct var *vp;
+ struct token *t_be = NULL;
struct token *t_host = NULL;
struct token *t_port = NULL;
+ struct token *t_first;
const char *ep;
- struct host *h;
- struct fld_spec *fs;
- fs = vcc_FldSpec(tl, "!host", "?port", NULL);
t_first = tl->t;
+ vcc_NextToken(tl);
+ ExpectErr(tl, ID);
+ t_be = tl->t;
+ vcc_AddDef(tl, tl->t, R_BACKEND);
- if (tl->t->tok == ID) {
- VTAILQ_FOREACH(h, &tl->hosts, list) {
- if (vcc_Teq(h->name, tl->t))
- break;
- }
- if (h == NULL) {
- vsb_printf(tl->sb, "Reference to unknown backend ");
+ /* In the compiled vcl we use these macros to refer to backends */
+ Fh(tl, 1, "#define VGC_backend_%.*s (VCL_conf.backend[%d])\n",
+ PF(tl->t), tl->nbackend);
+
+ vcc_NextToken(tl);
+ ExpectErr(tl, '{');
+ vcc_NextToken(tl);
+
+ while (1) {
+ if (tl->t->tok == '}')
+ break;
+ ExpectErr(tl, ID);
+ if (!vcc_IdIs(tl->t, "set")) {
+ vsb_printf(tl->sb,
+ "Expected 'set', found ");
vcc_ErrToken(tl, tl->t);
vsb_printf(tl->sb, " at\n");
vcc_ErrWhere(tl, tl->t);
return;
}
vcc_NextToken(tl);
- ExpectErr(tl, ';');
+ ExpectErr(tl, VAR);
+ vp = vcc_FindVar(tl, tl->t, vcc_be_vars);
+ ERRCHK(tl);
+ assert(vp != NULL);
vcc_NextToken(tl);
- *nbh = h->hnum;
- return;
- }
- ExpectErr(tl, '{');
- vcc_NextToken(tl);
-
- *nbh = tl->nbackend_host++;
- Fh(tl, 0, "\nstatic const struct vrt_backend bh_%d = {\n", *nbh);
-
- /* Check for old syntax */
- if (tl->t->tok == ID && vcc_IdIs(tl->t, "set")) {
- vsb_printf(tl->sb,
- "NB: Backend Syntax has changed:\n"
- "Remove \"set\" and \"backend\" in front"
- " of backend fields.\n" );
- vcc_ErrToken(tl, tl->t);
- vsb_printf(tl->sb, " at\n");
- vcc_ErrWhere(tl, tl->t);
- return;
- }
-
- while (tl->t->tok != '}') {
-
- vcc_IsField(tl, &t_field, fs);
- if (tl->err)
- break;
- if (vcc_IdIs(t_field, "host")) {
+ ExpectErr(tl, '=');
+ vcc_NextToken(tl);
+ switch (vp->fmt) {
+ case HOSTNAME:
ExpectErr(tl, CSTR);
- assert(tl->t->dec != NULL);
t_host = tl->t;
vcc_NextToken(tl);
- } else if (vcc_IdIs(t_field, "port")) {
+ break;
+ case PORTNAME:
ExpectErr(tl, CSTR);
- assert(tl->t->dec != NULL);
t_port = tl->t;
vcc_NextToken(tl);
- } else {
- ErrInternal(tl);
+ break;
+ default:
+ vsb_printf(tl->sb,
+ "Assignments not possible for '%s'\n", vp->name);
+ vcc_ErrWhere(tl, tl->t);
return;
}
-
ExpectErr(tl, ';');
vcc_NextToken(tl);
}
- if (!tl->err)
- vcc_FieldsOk(tl, fs);
- if (tl->err) {
- vsb_printf(tl->sb,
- "\nIn backend host specfication starting at:\n");
- vcc_ErrWhere(tl, t_first);
+ ExpectErr(tl, '}');
+ if (t_host == NULL) {
+ vsb_printf(tl->sb, "Backend '%.*s' has no hostname\n",
+ PF(t_be));
+ vcc_ErrWhere(tl, tl->t);
return;
}
-
- /* Check that the hostname makes sense */
- assert(t_host != NULL);
ep = CheckHostPort(t_host->dec, "80");
if (ep != NULL) {
- vsb_printf(tl->sb, "Backend host '%.*s': %s\n", PF(t_host), ep);
+ vsb_printf(tl->sb, "Backend '%.*s': %s\n", PF(t_be), ep);
vcc_ErrWhere(tl, t_host);
return;
}
- Fh(tl, 0, "\t.hostname = ");
- EncToken(tl->fh, t_host);
- Fh(tl, 0, ",\n");
-
- /* Check that the portname makes sense */
if (t_port != NULL) {
ep = CheckHostPort(t_host->dec, t_port->dec);
if (ep != NULL) {
vsb_printf(tl->sb,
- "Backend port '%.*s': %s\n", PF(t_port), ep);
+ "Backend '%.*s': %s\n", PF(t_be), ep);
vcc_ErrWhere(tl, t_port);
return;
}
- Fh(tl, 0, "\t.portname = ");
- EncToken(tl->fh, t_port);
- Fh(tl, 0, ",\n");
- } else {
- Fh(tl, 0, "\t.portname = \"80\",\n");
}
- ExpectErr(tl, '}');
- vcc_EmitBeIdent(tl->fh, qual, serial, t_first, tl->t);
- Fh(tl, 0, "\t.vcl_name = \"%.*s", PF(qual));
- if (serial)
- Fh(tl, 0, "[%d]", serial);
- Fh(tl, 0, "\"\n};\n");
vcc_NextToken(tl);
+ Fc(tl, 0, "\nstatic const struct vrt_simple_backend sbe_%.*s = {\n",
+ PF(t_be));
+ Fc(tl, 0, "\t.name = \"%.*s\",\n", PF(t_be));
+ if (t_port != NULL)
+ Fc(tl, 0, "\t.port = %.*s,\n", PF(t_port));
+ else
+ Fc(tl, 0, "\t.port = \"http\",\n");
+ Fc(tl, 0, "\t.host = %.*s,\n", PF(t_host));
+ vcc_EmitBeIdent(tl, t_first, tl->t);
+ Fc(tl, 0, "};\n");
+ Fi(tl, 0, "\tVRT_init_simple_backend(&VGC_backend_%.*s , &sbe_%.*s);\n",
+ PF(t_be), PF(t_be));
+ Ff(tl, 0, "\tVRT_fini_backend(VGC_backend_%.*s);\n", PF(t_be));
+ tl->nbackend++;
}
-/*--------------------------------------------------------------------
- * Parse a plain backend
- */
-
void
-vcc_ParseBackend(struct tokenlist *tl)
+vcc_ParseBalancedBackend(struct tokenlist *tl)
{
- struct host *h;
- int nbh;
-
- h = TlAlloc(tl, sizeof *h);
-
- vcc_NextToken(tl);
+ struct var *vp;
+ struct token *t_be = NULL;
+ struct token *t_host = NULL;
+ struct token *t_port = NULL;
+ double t_weight = 0;
+ const char *ep;
+ int cnt = 0;
+ int weighted = 0;
+ double weight = 0;
+ unsigned backend_type = tl->t->tok;
- ExpectErr(tl, ID); /* name */
- h->name = tl->t;
vcc_NextToken(tl);
-
- vcc_ParseBackendHost(tl, &nbh, h->name, 0);
- ERRCHK(tl);
-
- h->hnum = nbh;
- VTAILQ_INSERT_TAIL(&tl->hosts, h, list);
+ ExpectErr(tl, ID);
+ t_be = tl->t;
+ vcc_AddDef(tl, tl->t, R_BACKEND);
/* In the compiled vcl we use these macros to refer to backends */
- Fh(tl, 1, "\n#define VGC_backend_%.*s (VCL_conf.director[%d])\n",
- PF(h->name), tl->nbackend);
-
- vcc_AddDef(tl, h->name, R_BACKEND);
-
- Fi(tl, 0,
- "\tVRT_init_dir_simple(cli, &VGC_backend_%.*s , &sbe_%.*s);\n",
- PF(h->name), PF(h->name));
- Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend_%.*s);\n", PF(h->name));
-
- Fc(tl, 0, "\nstatic const struct vrt_dir_simple sbe_%.*s = {\n",
- PF(h->name));
- Fc(tl, 0, "\t.name = \"%.*s\",\n", PF(h->name));
- Fc(tl, 0, "\t.host = &bh_%d,\n", nbh);
- Fc(tl, 0, "};\n");
-
- tl->nbackend++;
-}
-
-/*--------------------------------------------------------------------
- * Parse directors
- */
-
-static void
-vcc_ParseRandomDirector(struct tokenlist *tl, struct token *t_dir)
-{
- struct token *t_field;
- int nbh, nelem;
- struct fld_spec *fs;
- unsigned u;
-
- Fh(tl, 1, "\n#define VGC_backend_%.*s (VCL_conf.director[%d])\n",
- PF(t_dir), tl->nbackend);
- vcc_AddDef(tl, t_dir, R_BACKEND);
-
- fs = vcc_FldSpec(tl, "!backend", "!weight", NULL);
-
- vcc_NextToken(tl); /* ID: policy (= random) */
+ Fh(tl, 1, "#define VGC_backend_%.*s (VCL_conf.backend[%d])\n",
+ PF(tl->t), tl->nbackend);
+ vcc_NextToken(tl);
ExpectErr(tl, '{');
vcc_NextToken(tl);
-
- Fc(tl, 0,
- "\nstatic const struct vrt_dir_random_entry vdre_%.*s[] = {\n",
- PF(t_dir));
-
- for (nelem = 0; tl->t->tok != '}'; nelem++) { /* List of members */
- vcc_ResetFldSpec(fs);
- nbh = -1;
-
+
+ while (1) {
+ if (tl->t->tok == '}')
+ break;
+ ExpectErr(tl, ID);
+ if (!vcc_IdIs(tl->t, "set")) {
+ vsb_printf(tl->sb,
+ "Expected 'set', found ");
+ vcc_ErrToken(tl, tl->t);
+ vsb_printf(tl->sb, " at\n");
+ vcc_ErrWhere(tl, tl->t);
+ return;
+ }
+ vcc_NextToken(tl);
+ ExpectErr(tl, VAR);
+ vp = vcc_FindVar(tl, tl->t, vcc_be_vars);
+ ERRCHK(tl);
+ assert(vp != NULL);
+ vcc_NextToken(tl);
+ ExpectErr(tl, '=');
+ vcc_NextToken(tl);
+ if (vp->fmt != SET) {
+ vsb_printf(tl->sb,
+ "Assignments not possible for '%s'\n", vp->name);
+ vcc_ErrWhere(tl, tl->t);
+ return;
+ }
+
ExpectErr(tl, '{');
vcc_NextToken(tl);
- Fc(tl, 0, "\t{");
-
- while (tl->t->tok != '}') { /* Member fields */
- vcc_IsField(tl, &t_field, fs);
- ERRCHK(tl);
- if (vcc_IdIs(t_field, "backend")) {
- vcc_ParseBackendHost(tl, &nbh, t_dir, nelem);
- Fc(tl, 0, " .host = &bh_%d,", nbh);
- ERRCHK(tl);
- } else if (vcc_IdIs(t_field, "weight")) {
- ExpectErr(tl, CNUM);
- u = vcc_UintVal(tl);
- if (u == 0) {
+
+ while (1) {
+ if (tl->t->tok == '}')
+ break;
+
+ ExpectErr(tl, '{');
+ vcc_NextToken(tl);
+
+ // Host
+ ExpectErr(tl, CSTR);
+ t_host = tl->t;
+ vcc_NextToken(tl);
+
+ ep = CheckHostPort(t_host->dec, "80");
+ if (ep != NULL) {
+ vsb_printf(tl->sb, "Backend '%.*s': %s\n", PF(t_be), ep);
+ vcc_ErrWhere(tl, t_host);
+ return;
+ }
+
+ if (tl->t->tok == ',') {
+ vcc_NextToken(tl);
+
+ // Port
+
+ ExpectErr(tl, CSTR);
+ t_port = tl->t;
+ vcc_NextToken(tl);
+
+ ep = CheckHostPort(t_host->dec, t_port->dec);
+ if (ep != NULL) {
vsb_printf(tl->sb,
- "The .weight must be higher than zero.");
- vcc_ErrToken(tl, tl->t);
- vsb_printf(tl->sb, " at\n");
- vcc_ErrWhere(tl, tl->t);
+ "Backend '%.*s': %s\n", PF(t_be), ep);
+ vcc_ErrWhere(tl, t_port);
return;
}
- Fc(tl, 0, " .weight = %u", u);
- vcc_NextToken(tl);
- ExpectErr(tl, ';');
- vcc_NextToken(tl);
- } else {
- ErrInternal(tl);
+
+ if (tl->t->tok == ',') {
+
+ vcc_NextToken(tl);
+
+ // Weight
+ t_weight = vcc_DoubleVal(tl);
+ weighted = 1;
+ weight += t_weight;
+ }
}
+
+ ExpectErr(tl, '}');
+ vcc_NextToken(tl);
+
+ Fc(tl, 0, "\nstatic struct vrt_backend_entry bentry_%.*s_%d = {\n",
+ PF(t_be), cnt);
+ Fc(tl, 0, "\t.port = %.*s,\n", PF(t_port));
+ Fc(tl, 0, "\t.host = %.*s,\n", PF(t_host));
+ Fc(tl, 0, "\t.weight = %f,\n", t_weight);
+ if (cnt > 0) {
+ Fc(tl, 0, "\t.next = &bentry_%.*s_%d\n", PF(t_be), cnt-1);
+ } /*else {
+ Fc(tl, 0, "\t.next = NULL\n");
+ }*/
+ Fc(tl, 0, "};\n");
+ t_weight = 0;
+ cnt++;
}
- vcc_FieldsOk(tl, fs);
- ERRCHK(tl);
- Fc(tl, 0, " },\n");
+ ExpectErr(tl, '}');
vcc_NextToken(tl);
- }
- Fc(tl, 0, "\t{ .host = 0 }\n");
- Fc(tl, 0, "};\n");
- Fc(tl, 0,
- "\nstatic const struct vrt_dir_random vdr_%.*s = {\n",
- PF(t_dir));
- Fc(tl, 0, "\t.name = \"%.*s\",\n", PF(t_dir));
- Fc(tl, 0, "\t.nmember = %d,\n", nelem);
- Fc(tl, 0, "\t.members = vdre_%.*s,\n", PF(t_dir));
- Fc(tl, 0, "};\n");
- vcc_NextToken(tl);
- Fi(tl, 0,
- "\tVRT_init_dir_random(cli, &VGC_backend_%.*s , &vdr_%.*s);\n",
- PF(t_dir), PF(t_dir));
- Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend_%.*s);\n", PF(t_dir));
-}
-
-/*--------------------------------------------------------------------
- * Parse directors
- */
-
-void
-vcc_ParseDirector(struct tokenlist *tl)
-{
- struct token *t_dir, *t_first;
+ ExpectErr(tl, ';');
+ vcc_NextToken(tl);
+
+ if (t_host == NULL) {
+ vsb_printf(tl->sb, "Backend '%.*s' has no hostname\n",
+ PF(t_be));
+ vcc_ErrWhere(tl, tl->t);
+ return;
+ }
+
+ if (weighted && (int)weight != 1) {
+ vsb_printf(tl->sb, "Total weight must be 1\n");
+ vcc_ErrWhere(tl, tl->t);
+ return;
+ }
+
+ if (backend_type == T_BACKEND_ROUND_ROBIN) {
+ Fc(tl, 0, "\nstatic struct vrt_round_robin_backend sbe_%.*s = {\n",
+ PF(t_be));
+ Fc(tl, 0, "\t.name = \"%.*s\",\n", PF(t_be));
+ Fc(tl, 0, "\t.count = %d,\n", cnt);
+ Fc(tl, 0, "\t.bentry = &bentry_%.*s_%d\n", PF(t_be), cnt-1);
+ Fc(tl, 0, "};\n");
+ Fi(tl, 0, "\tVRT_init_round_robin_backend(&VGC_backend_%.*s , &sbe_%.*s);\n",
+ PF(t_be), PF(t_be));
+ } else if (backend_type == T_BACKEND_RANDOM) {
+ Fc(tl, 0, "\nstatic struct vrt_random_backend sbe_%.*s = {\n",
+ PF(t_be));
+ Fc(tl, 0, "\t.name = \"%.*s\",\n", PF(t_be));
+ Fc(tl, 0, "\t.weighted = %d,\n", weighted);
+ Fc(tl, 0, "\t.count = %d,\n", cnt);
+ Fc(tl, 0, "\t.bentry = &bentry_%.*s_%d\n", PF(t_be), cnt-1);
+ Fc(tl, 0, "};\n");
+ Fi(tl, 0, "\tVRT_init_random_backend(&VGC_backend_%.*s , &sbe_%.*s);\n",
+ PF(t_be), PF(t_be));
+ }
+ Ff(tl, 0, "\tVRT_fini_backend(VGC_backend_%.*s);\n", PF(t_be));
- t_first = tl->t;
- vcc_NextToken(tl); /* ID: director */
+ }
+ ExpectErr(tl, '}');
- ExpectErr(tl, ID); /* ID: name */
- t_dir = tl->t;
vcc_NextToken(tl);
-
- ExpectErr(tl, ID); /* ID: policy */
- if (vcc_IdIs(tl->t, "random"))
- vcc_ParseRandomDirector(tl, t_dir);
- else {
- vsb_printf(tl->sb, "Unknown director policy: ");
- vcc_ErrToken(tl, tl->t);
- vsb_printf(tl->sb, " at\n");
- vcc_ErrWhere(tl, tl->t);
- return;
- }
- if (tl->err) {
- vsb_printf(tl->sb,
- "\nIn director specfication starting at:\n",
- PF(t_first));
- vcc_ErrWhere(tl, t_first);
- return;
- }
tl->nbackend++;
}
+
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvcl/vcc_compile.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: vcc_compile.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: vcc_compile.c 2564 2008-03-08 13:38:23Z des $
*/
/*
@@ -297,7 +297,7 @@
EmitInitFunc(const struct tokenlist *tl)
{
- Fc(tl, 0, "\nstatic void\nVGC_Init(struct cli *cli)\n{\n\n");
+ Fc(tl, 0, "\nstatic void\nVGC_Init(void)\n{\n\n");
vsb_finish(tl->fi);
/* XXX: check vsb_overflowed ? */
vsb_cat(tl->fc, vsb_data(tl->fi));
@@ -308,7 +308,7 @@
EmitFiniFunc(const struct tokenlist *tl)
{
- Fc(tl, 0, "\nstatic void\nVGC_Fini(struct cli *cli)\n{\n\n");
+ Fc(tl, 0, "\nstatic void\nVGC_Fini(void)\n{\n\n");
vsb_finish(tl->ff);
/* XXX: check vsb_overflowed ? */
vsb_cat(tl->fc, vsb_data(tl->ff));
@@ -341,14 +341,14 @@
}
Fc(tl, 0, "};\n");
- Fc(tl, 0, "\nstatic struct director\t*directors[%d];\n", tl->nbackend);
+ Fc(tl, 0, "\nstatic struct backend\t*backends[%d];\n", tl->nbackend);
Fc(tl, 0, "\nconst struct VCL_conf VCL_conf = {\n");
Fc(tl, 0, "\t.magic = VCL_CONF_MAGIC,\n");
Fc(tl, 0, "\t.init_func = VGC_Init,\n");
Fc(tl, 0, "\t.fini_func = VGC_Fini,\n");
- Fc(tl, 0, "\t.ndirector = %d,\n", tl->nbackend);
- Fc(tl, 0, "\t.director = directors,\n");
+ Fc(tl, 0, "\t.nbackend = %d,\n", tl->nbackend);
+ Fc(tl, 0, "\t.backend = backends,\n");
Fc(tl, 0, "\t.ref = VGC_ref,\n");
Fc(tl, 0, "\t.nref = VGC_NREFS,\n");
Fc(tl, 0, "\t.nsrc = %u,\n", tl->nsources);
@@ -480,7 +480,6 @@
tl = calloc(sizeof *tl, 1);
assert(tl != NULL);
- VTAILQ_INIT(&tl->hosts);
VTAILQ_INIT(&tl->membits);
VTAILQ_INIT(&tl->tokens);
VTAILQ_INIT(&tl->refs);
@@ -694,10 +693,15 @@
void
VCC_InitCompile(const char *default_vcl)
{
+ struct var *v;
vcc_default_vcl_b = default_vcl;
vcc_default_vcl_e = strchr(default_vcl, '\0');
assert(vcc_default_vcl_e != NULL);
vcl_init_tnames();
+ for (v = vcc_vars; v->name != NULL; v++)
+ v->len = strlen(v->name);
+ for (v = vcc_be_vars; v->name != NULL; v++)
+ v->len = strlen(v->name);
}
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvcl/vcc_compile.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: vcc_compile.h 2420 2008-02-04 09:26:36Z phk $
+ * $Id: vcc_compile.h 2496 2008-02-17 09:26:32Z des $
*/
#include "vqueue.h"
@@ -59,19 +59,12 @@
char *dec;
};
-struct host {
- VTAILQ_ENTRY(host) list;
- unsigned hnum;
- struct token *name;
-};
-
VTAILQ_HEAD(tokenhead, token);
struct tokenlist {
struct tokenhead tokens;
VTAILQ_HEAD(, source) sources;
VTAILQ_HEAD(, membit) membits;
- VTAILQ_HEAD(, host) hosts;
unsigned nsources;
struct source *src;
struct token *t;
@@ -85,7 +78,6 @@
VTAILQ_HEAD(, ref) refs;
struct vsb *sb;
int err;
- int nbackend_host;
int nbackend;
VTAILQ_HEAD(, proc) procs;
struct proc *curproc;
@@ -103,11 +95,13 @@
SIZE,
RATE,
TIME,
- RTIME,
STRING,
IP,
+ HOSTNAME,
+ PORTNAME,
HASH,
- HEADER
+ HEADER,
+ SET
};
enum var_access {
@@ -158,8 +152,8 @@
void vcc_ParseAction(struct tokenlist *tl);
/* vcc_backend.c */
-void vcc_ParseBackend(struct tokenlist *tl);
-void vcc_ParseDirector(struct tokenlist *tl);
+void vcc_ParseSimpleBackend(struct tokenlist *tl);
+void vcc_ParseBalancedBackend(struct tokenlist *tl);
/* vcc_compile.c */
extern struct method method_tab[];
@@ -174,12 +168,12 @@
void *TlAlloc(struct tokenlist *tl, unsigned len);
/* vcc_obj.c */
+extern struct var vcc_be_vars[];
extern struct var vcc_vars[];
/* vcc_parse.c */
void vcc_Parse(struct tokenlist *tl);
void vcc_RateVal(struct tokenlist *tl);
-void vcc_RTimeVal(struct tokenlist *tl);
void vcc_TimeVal(struct tokenlist *tl);
void vcc_SizeVal(struct tokenlist *tl);
unsigned vcc_UintVal(struct tokenlist *tl);
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvcl/vcc_fixed_token.c
^
|
@@ -1,5 +1,5 @@
/*
- * $Id: vcc_fixed_token.c 2552 2008-03-04 11:02:25Z des $
+ * $Id: vcc_fixed_token.c 2564 2008-03-08 13:38:23Z des $
*
* NB: This file is machine generated, DO NOT EDIT!
*
@@ -166,6 +166,32 @@
return (T_ACL);
}
return (0);
+ case 'b':
+ if (p[0] == 'b' && p[1] == 'a' && p[2] == 'c' &&
+ p[3] == 'k' && p[4] == 'e' && p[5] == 'n' &&
+ p[6] == 'd' && p[7] == '_' && p[8] == 'r' &&
+ p[9] == 'o' && p[10] == 'u' && p[11] == 'n' &&
+ p[12] == 'd' && p[13] == '_' && p[14] == 'r' &&
+ p[15] == 'o' && p[16] == 'b' && p[17] == 'i' &&
+ p[18] == 'n' && !isvar(p[19])) {
+ *q = p + 19;
+ return (T_BACKEND_ROUND_ROBIN);
+ }
+ if (p[0] == 'b' && p[1] == 'a' && p[2] == 'c' &&
+ p[3] == 'k' && p[4] == 'e' && p[5] == 'n' &&
+ p[6] == 'd' && p[7] == '_' && p[8] == 'r' &&
+ p[9] == 'a' && p[10] == 'n' && p[11] == 'd' &&
+ p[12] == 'o' && p[13] == 'm' && !isvar(p[14])) {
+ *q = p + 14;
+ return (T_BACKEND_RANDOM);
+ }
+ if (p[0] == 'b' && p[1] == 'a' && p[2] == 'c' &&
+ p[3] == 'k' && p[4] == 'e' && p[5] == 'n' &&
+ p[6] == 'd' && !isvar(p[7])) {
+ *q = p + 7;
+ return (T_BACKEND);
+ }
+ return (0);
case 'e':
if (p[0] == 'e' && p[1] == 'l' && p[2] == 's' &&
p[3] == 'i' && p[4] == 'f' && !isvar(p[5])) {
@@ -266,6 +292,9 @@
vcl_tnames[EOI] = "EOI";
vcl_tnames[ID] = "ID";
vcl_tnames[T_ACL] = "acl";
+ vcl_tnames[T_BACKEND] = "backend";
+ vcl_tnames[T_BACKEND_RANDOM] = "backend_random";
+ vcl_tnames[T_BACKEND_ROUND_ROBIN] = "backend_round_robin";
vcl_tnames[T_CAND] = "&&";
vcl_tnames[T_COR] = "||";
vcl_tnames[T_DEC] = "--";
@@ -304,7 +333,7 @@
vsb_cat(sb, "#define VCL_RET_KEEP (1 << 9)\n");
vsb_cat(sb, "#define VCL_RET_RESTART (1 << 10)\n");
vsb_cat(sb, "/*\n");
- vsb_cat(sb, " * $Id: vcc_fixed_token.c 2552 2008-03-04 11:02:25Z des $\n");
+ vsb_cat(sb, " * $Id: vcc_fixed_token.c 2564 2008-03-08 13:38:23Z des $\n");
vsb_cat(sb, " *\n");
vsb_cat(sb, " * NB: This file is machine generated, DO NOT EDIT!\n");
vsb_cat(sb, " *\n");
@@ -312,22 +341,20 @@
vsb_cat(sb, " */\n");
vsb_cat(sb, "\n");
vsb_cat(sb, "struct sess;\n");
- vsb_cat(sb, "struct cli;\n");
vsb_cat(sb, "\n");
- vsb_cat(sb, "typedef void vcl_init_f(struct cli *);\n");
- vsb_cat(sb, "typedef void vcl_fini_f(struct cli *);\n");
+ vsb_cat(sb, "typedef void vcl_init_f(void);\n");
+ vsb_cat(sb, "typedef void vcl_fini_f(void);\n");
vsb_cat(sb, "typedef int vcl_func_f(struct sess *sp);\n");
vsb_cat(sb, "\n");
vsb_cat(sb, "struct VCL_conf {\n");
vsb_cat(sb, " unsigned magic;\n");
vsb_cat(sb, "#define VCL_CONF_MAGIC 0x7406c509 /* from /dev/random */\n");
vsb_cat(sb, "\n");
- vsb_cat(sb, " struct director **director;\n");
- vsb_cat(sb, " unsigned ndirector;\n");
+ vsb_cat(sb, " struct backend **backend;\n");
+ vsb_cat(sb, " unsigned nbackend;\n");
vsb_cat(sb, " struct vrt_ref *ref;\n");
vsb_cat(sb, " unsigned nref;\n");
vsb_cat(sb, " unsigned busy;\n");
- vsb_cat(sb, " unsigned discard;\n");
vsb_cat(sb, " \n");
vsb_cat(sb, " unsigned nsrc;\n");
vsb_cat(sb, " const char **srcname;\n");
@@ -348,7 +375,6 @@
vsb_cat(sb, " vcl_func_f *hit_func;\n");
vsb_cat(sb, " vcl_func_f *fetch_func;\n");
vsb_cat(sb, " vcl_func_f *deliver_func;\n");
- vsb_cat(sb, " vcl_func_f *prefetch_func;\n");
vsb_cat(sb, " vcl_func_f *timeout_func;\n");
vsb_cat(sb, " vcl_func_f *discard_func;\n");
vsb_cat(sb, "};\n");
@@ -380,7 +406,7 @@
vsb_cat(sb, " * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n");
vsb_cat(sb, " * SUCH DAMAGE.\n");
vsb_cat(sb, " *\n");
- vsb_cat(sb, " * $Id: vcc_fixed_token.c 2552 2008-03-04 11:02:25Z des $\n");
+ vsb_cat(sb, " * $Id: vcc_fixed_token.c 2564 2008-03-08 13:38:23Z des $\n");
vsb_cat(sb, " *\n");
vsb_cat(sb, " * Runtime support for compiled VCL programs.\n");
vsb_cat(sb, " *\n");
@@ -390,49 +416,37 @@
vsb_cat(sb, "\n");
vsb_cat(sb, "struct sess;\n");
vsb_cat(sb, "struct vsb;\n");
- vsb_cat(sb, "struct cli;\n");
- vsb_cat(sb, "struct director;\n");
+ vsb_cat(sb, "struct backend;\n");
vsb_cat(sb, "struct VCL_conf;\n");
vsb_cat(sb, "struct sockaddr;\n");
vsb_cat(sb, "\n");
- vsb_cat(sb, "/*\n");
- vsb_cat(sb, " * A backend is a host+port somewhere on the network\n");
- vsb_cat(sb, " */\n");
- vsb_cat(sb, "struct vrt_backend {\n");
- vsb_cat(sb, " const char *portname;\n");
- vsb_cat(sb, " const char *hostname;\n");
- vsb_cat(sb, " const char *vcl_name;\n");
+ vsb_cat(sb, "struct vrt_simple_backend {\n");
vsb_cat(sb, " const char *ident;\n");
+ vsb_cat(sb, " const char *name;\n");
+ vsb_cat(sb, " const char *port;\n");
+ vsb_cat(sb, " const char *host;\n");
vsb_cat(sb, "};\n");
vsb_cat(sb, "\n");
- vsb_cat(sb, "/*\n");
- vsb_cat(sb, " * A director with a predictable reply\n");
- vsb_cat(sb, " */\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "struct vrt_dir_simple {\n");
- vsb_cat(sb, " const char *name;\n");
- vsb_cat(sb, " const struct vrt_backend *host;\n");
+ vsb_cat(sb, "struct vrt_backend_entry {\n");
+ vsb_cat(sb, " const char *port;\n");
+ vsb_cat(sb, " const char *host;\n");
+ vsb_cat(sb, " double weight;\n");
+ vsb_cat(sb, " struct vrt_backend_entry *next;\n");
vsb_cat(sb, "};\n");
vsb_cat(sb, "\n");
- vsb_cat(sb, "/*\n");
- vsb_cat(sb, " * A director with an unpredictable reply\n");
- vsb_cat(sb, " */\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "struct vrt_dir_random_entry {\n");
- vsb_cat(sb, " const struct vrt_backend *host;\n");
- vsb_cat(sb, " double weight;\n");
+ vsb_cat(sb, "struct vrt_round_robin_backend {\n");
+ vsb_cat(sb, " const char *name;\n");
+ vsb_cat(sb, " unsigned count;\n");
+ vsb_cat(sb, " struct vrt_backend_entry *bentry;\n");
vsb_cat(sb, "};\n");
vsb_cat(sb, "\n");
- vsb_cat(sb, "struct vrt_dir_random {\n");
- vsb_cat(sb, " const char *name;\n");
- vsb_cat(sb, " unsigned nmember;\n");
- vsb_cat(sb, " const struct vrt_dir_random_entry *members;\n");
+ vsb_cat(sb, "struct vrt_random_backend {\n");
+ vsb_cat(sb, " const char *name;\n");
+ vsb_cat(sb, " unsigned weighted;\n");
+ vsb_cat(sb, " unsigned count;\n");
+ vsb_cat(sb, " struct vrt_backend_entry *bentry;\n");
vsb_cat(sb, "};\n");
vsb_cat(sb, "\n");
- vsb_cat(sb, "/*\n");
- vsb_cat(sb, " * other stuff.\n");
- vsb_cat(sb, " * XXX: document when bored\n");
- vsb_cat(sb, " */\n");
vsb_cat(sb, "\n");
vsb_cat(sb, "struct vrt_ref {\n");
vsb_cat(sb, " unsigned source;\n");
@@ -483,13 +497,13 @@
vsb_cat(sb, "void VRT_Rollback(struct sess *sp);\n");
vsb_cat(sb, "\n");
vsb_cat(sb, "/* Backend related */\n");
- vsb_cat(sb, "void VRT_init_dir_simple(struct cli *, struct director **, const struct vrt_dir_simple *);\n");
- vsb_cat(sb, "void VRT_init_dir_random(struct cli *, struct director **, const struct vrt_dir_random *);\n");
- vsb_cat(sb, "void VRT_fini_dir(struct cli *, struct director *);\n");
+ vsb_cat(sb, "void VRT_init_simple_backend(struct backend **, const struct vrt_simple_backend *);\n");
+ vsb_cat(sb, "void VRT_init_round_robin_backend(struct backend **, const struct vrt_round_robin_backend *);\n");
+ vsb_cat(sb, "void VRT_init_random_backend(struct backend **, const struct vrt_random_backend *);\n");
+ vsb_cat(sb, "void VRT_fini_backend(struct backend *);\n");
vsb_cat(sb, "\n");
vsb_cat(sb, "char *VRT_IP_string(const struct sess *sp, const struct sockaddr *sa);\n");
vsb_cat(sb, "char *VRT_int_string(const struct sess *sp, int);\n");
- vsb_cat(sb, "char *VRT_double_string(const struct sess *sp, double);\n");
vsb_cat(sb, "\n");
vsb_cat(sb, "#define VRT_done(sp, hand) \\\n");
vsb_cat(sb, " do { \\\n");
@@ -497,13 +511,17 @@
vsb_cat(sb, " return (1); \\\n");
vsb_cat(sb, " } while (0)\n");
vsb_cat(sb, "/*\n");
- vsb_cat(sb, " * $Id: vcc_fixed_token.c 2552 2008-03-04 11:02:25Z des $\n");
+ vsb_cat(sb, " * $Id: vcc_fixed_token.c 2564 2008-03-08 13:38:23Z des $\n");
vsb_cat(sb, " *\n");
vsb_cat(sb, " * NB: This file is machine generated, DO NOT EDIT!\n");
vsb_cat(sb, " *\n");
vsb_cat(sb, " * Edit vcc_gen_obj.tcl instead\n");
vsb_cat(sb, " */\n");
vsb_cat(sb, "\n");
+ vsb_cat(sb, "void VRT_l_backend_host(struct backend *, const char *);\n");
+ vsb_cat(sb, "void VRT_l_backend_port(struct backend *, const char *);\n");
+ vsb_cat(sb, "void VRT_l_backend_dnsttl(struct backend *, double);\n");
+ vsb_cat(sb, "void VRT_l_backend_set(struct backend *, struct vrt_backend_entry *);\n");
vsb_cat(sb, "struct sockaddr * VRT_r_client_ip(const struct sess *);\n");
vsb_cat(sb, "struct sockaddr * VRT_r_server_ip(struct sess *);\n");
vsb_cat(sb, "const char * VRT_r_req_request(const struct sess *);\n");
@@ -513,11 +531,9 @@
vsb_cat(sb, "const char * VRT_r_req_proto(const struct sess *);\n");
vsb_cat(sb, "void VRT_l_req_proto(const struct sess *, const char *, ...);\n");
vsb_cat(sb, "void VRT_l_req_hash(struct sess *, const char *);\n");
- vsb_cat(sb, "struct director * VRT_r_req_backend(struct sess *);\n");
- vsb_cat(sb, "void VRT_l_req_backend(struct sess *, struct director *);\n");
+ vsb_cat(sb, "struct backend * VRT_r_req_backend(struct sess *);\n");
+ vsb_cat(sb, "void VRT_l_req_backend(struct sess *, struct backend *);\n");
vsb_cat(sb, "int VRT_r_req_restarts(const struct sess *);\n");
- vsb_cat(sb, "double VRT_r_req_grace(struct sess *);\n");
- vsb_cat(sb, "void VRT_l_req_grace(struct sess *, double);\n");
vsb_cat(sb, "const char * VRT_r_bereq_request(const struct sess *);\n");
vsb_cat(sb, "void VRT_l_bereq_request(const struct sess *, const char *, ...);\n");
vsb_cat(sb, "const char * VRT_r_bereq_url(const struct sess *);\n");
@@ -536,12 +552,7 @@
vsb_cat(sb, "void VRT_l_obj_cacheable(const struct sess *, unsigned);\n");
vsb_cat(sb, "double VRT_r_obj_ttl(const struct sess *);\n");
vsb_cat(sb, "void VRT_l_obj_ttl(const struct sess *, double);\n");
- vsb_cat(sb, "double VRT_r_obj_grace(const struct sess *);\n");
- vsb_cat(sb, "void VRT_l_obj_grace(const struct sess *, double);\n");
- vsb_cat(sb, "double VRT_r_obj_prefetch(const struct sess *);\n");
- vsb_cat(sb, "void VRT_l_obj_prefetch(const struct sess *, double);\n");
vsb_cat(sb, "double VRT_r_obj_lastuse(const struct sess *);\n");
- vsb_cat(sb, "const char *VRT_r_obj_hash(struct sess *sp);\n");
vsb_cat(sb, "const char * VRT_r_resp_proto(const struct sess *);\n");
vsb_cat(sb, "void VRT_l_resp_proto(const struct sess *, const char *, ...);\n");
vsb_cat(sb, "int VRT_r_resp_status(const struct sess *);\n");
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvcl/vcc_gen_fixed_token.tcl
^
|
@@ -42,7 +42,6 @@
{hit {error restart pass deliver}}
{fetch {error restart pass insert}}
{deliver {error restart deliver}}
- {prefetch {fetch pass}}
{timeout {fetch discard}}
{discard {discard keep}}
}
@@ -73,6 +72,12 @@
sub
acl
+
+ backend
+
+ backend_round_robin
+
+ backend_random
}
# Non-word tokens
@@ -108,7 +113,7 @@
proc warns {fd} {
puts $fd "/*"
- puts $fd { * $Id: vcc_gen_fixed_token.tcl 2460 2008-02-13 17:25:52Z des $}
+ puts $fd { * $Id: vcc_gen_fixed_token.tcl 2564 2008-03-08 13:38:23Z des $}
puts $fd " *"
puts $fd " * NB: This file is machine generated, DO NOT EDIT!"
puts $fd " *"
@@ -123,22 +128,20 @@
set fo [open ../../include/vcl.h w]
warns $fo
puts $fo {struct sess;
-struct cli;
-typedef void vcl_init_f(struct cli *);
-typedef void vcl_fini_f(struct cli *);
+typedef void vcl_init_f(void);
+typedef void vcl_fini_f(void);
typedef int vcl_func_f(struct sess *sp);
}
puts $fo "struct VCL_conf {"
puts $fo { unsigned magic;
#define VCL_CONF_MAGIC 0x7406c509 /* from /dev/random */
- struct director **director;
- unsigned ndirector;
+ struct backend **backend;
+ unsigned nbackend;
struct vrt_ref *ref;
unsigned nref;
unsigned busy;
- unsigned discard;
unsigned nsrc;
const char **srcname;
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvcl/vcc_gen_obj.tcl
^
|
@@ -30,6 +30,13 @@
# Generate various .c and .h files for the VCL compiler and the interfaces
# for it.
+# Objects available in backends
+set beobj {
+ { backend.host WO HOSTNAME {} "struct backend *"}
+ { backend.port WO PORTNAME {} "struct backend *"}
+ { backend.dnsttl WO TIME {} "struct backend *"}
+ { backend.set WO SET {} "struct backend *"}
+}
# Variables available in sessions
# Comments are stripped from #...\n
@@ -90,11 +97,6 @@
{recv pipe pass hash miss hit fetch deliver }
"const struct sess *"
}
- { req.grace
- RW TIME
- {recv pipe pass hash miss hit fetch deliver }
- "struct sess *"
- }
# Request sent to backend
{ bereq.request
@@ -155,26 +157,11 @@
{ hit fetch discard timeout}
"const struct sess *"
}
- { obj.grace
- RW TIME
- { hit fetch discard timeout}
- "const struct sess *"
- }
- { obj.prefetch
- RW RTIME
- { fetch prefetch }
- "const struct sess *"
- }
{ obj.lastuse
RO TIME
{ hit fetch deliver discard timeout}
"const struct sess *"
}
- { obj.hash
- RO STRING
- { miss hit fetch deliver }
- "const struct sess *"
- }
# The response we send back
{ resp.proto
@@ -216,9 +203,8 @@
set tt(IP) "struct sockaddr *"
set tt(STRING) "const char *"
set tt(BOOL) "unsigned"
-set tt(BACKEND) "struct director *"
+set tt(BACKEND) "struct backend *"
set tt(TIME) "double"
-set tt(RTIME) "double"
set tt(INT) "int"
set tt(HDR_RESP) "const char *"
set tt(HDR_OBJ) "const char *"
@@ -235,7 +221,7 @@
proc warns {fd} {
puts $fd "/*"
- puts $fd { * $Id: vcc_gen_obj.tcl 2554 2008-03-04 11:42:00Z des $}
+ puts $fd { * $Id: vcc_gen_obj.tcl 2564 2008-03-08 13:38:23Z des $}
puts $fd " *"
puts $fd " * NB: This file is machine generated, DO NOT EDIT!"
puts $fd " *"
@@ -315,6 +301,12 @@
puts $fo "#include \"vcc_compile.h\""
puts $fo ""
+puts $fo "struct var vcc_be_vars\[\] = {"
+vars $beobj "backend"
+puts $fo "};"
+
+puts $fo ""
+
puts $fo "struct var vcc_vars\[\] = {"
vars $spobj "sp"
puts $fo "};"
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvcl/vcc_obj.c
^
|
@@ -1,5 +1,5 @@
/*
- * $Id: vcc_obj.c 2552 2008-03-04 11:02:25Z des $
+ * $Id: vcc_obj.c 2564 2008-03-08 13:38:23Z des $
*
* NB: This file is machine generated, DO NOT EDIT!
*
@@ -10,6 +10,38 @@
#include <stdio.h>
#include "vcc_compile.h"
+struct var vcc_be_vars[] = {
+ { "backend.host", HOSTNAME, 12,
+ NULL,
+ "VRT_l_backend_host(backend, ",
+ V_WO,
+ 0,
+ 0
+ },
+ { "backend.port", PORTNAME, 12,
+ NULL,
+ "VRT_l_backend_port(backend, ",
+ V_WO,
+ 0,
+ 0
+ },
+ { "backend.dnsttl", TIME, 14,
+ NULL,
+ "VRT_l_backend_dnsttl(backend, ",
+ V_WO,
+ 0,
+ 0
+ },
+ { "backend.set", SET, 11,
+ NULL,
+ "VRT_l_backend_set(backend, ",
+ V_WO,
+ 0,
+ 0
+ },
+ { NULL }
+};
+
struct var vcc_vars[] = {
{ "client.ip", IP, 9,
"VRT_r_client_ip(sp)",
@@ -74,13 +106,6 @@
0,
VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
},
- { "req.grace", TIME, 9,
- "VRT_r_req_grace(sp)",
- "VRT_l_req_grace(sp, ",
- V_RW,
- 0,
- VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
- },
{ "bereq.request", STRING, 13,
"VRT_r_bereq_request(sp)",
"VRT_l_bereq_request(sp, ",
@@ -158,20 +183,6 @@
0,
VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DISCARD | VCL_MET_TIMEOUT
},
- { "obj.grace", TIME, 9,
- "VRT_r_obj_grace(sp)",
- "VRT_l_obj_grace(sp, ",
- V_RW,
- 0,
- VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DISCARD | VCL_MET_TIMEOUT
- },
- { "obj.prefetch", RTIME, 12,
- "VRT_r_obj_prefetch(sp)",
- "VRT_l_obj_prefetch(sp, ",
- V_RW,
- 0,
- VCL_MET_FETCH | VCL_MET_PREFETCH
- },
{ "obj.lastuse", TIME, 11,
"VRT_r_obj_lastuse(sp)",
NULL,
@@ -179,13 +190,6 @@
0,
VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_DISCARD | VCL_MET_TIMEOUT
},
- { "obj.hash", STRING, 8,
- "VRT_r_obj_hash(sp)",
- NULL,
- V_RO,
- 0,
- VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
- },
{ "resp.proto", STRING, 10,
"VRT_r_resp_proto(sp)",
"VRT_l_resp_proto(sp, ",
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvcl/vcc_parse.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: vcc_parse.c 2479 2008-02-15 12:42:48Z phk $
+ * $Id: vcc_parse.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
@@ -150,6 +150,7 @@
d *= 10;
d += *p - '0';
}
+ vcc_NextToken(tl);
return (d);
}
@@ -185,29 +186,11 @@
/*--------------------------------------------------------------------*/
void
-vcc_RTimeVal(struct tokenlist *tl)
-{
- double v, sc;
- int sign = 1;
-
- if (tl->t->tok == '-') {
- sign *= -1;
- vcc_NextToken(tl);
- }
- v = vcc_DoubleVal(tl);
- ERRCHK(tl);
- ExpectErr(tl, ID);
- sc = TimeUnit(tl);
- Fb(tl, 0, "(%d * %g * %g)", sign, v, sc);
-}
-
-void
vcc_TimeVal(struct tokenlist *tl)
{
double v, sc;
v = vcc_DoubleVal(tl);
- ERRCHK(tl);
ExpectErr(tl, ID);
sc = TimeUnit(tl);
Fb(tl, 0, "(%g * %g)", v, sc);
@@ -219,7 +202,6 @@
double v, sc;
v = vcc_DoubleVal(tl);
- ERRCHK(tl);
ExpectErr(tl, ID);
sc = SizeUnit(tl);
Fb(tl, 0, "(%g * %g)", v, sc);
@@ -231,7 +213,6 @@
double v, sc;
v = vcc_DoubleVal(tl);
- ERRCHK(tl);
ExpectErr(tl, ID);
sc = RateUnit(tl);
Fb(tl, 0, "(%g * %g)", v, sc);
@@ -565,23 +546,15 @@
case T_SUB:
Function(tl);
break;
- case CSRC:
- Fc(tl, 0, "%.*s\n",
- tl->t->e - (tl->t->b + 4), tl->t->b + 2);
- vcc_NextToken(tl);
+ case T_BACKEND:
+ vcc_ParseSimpleBackend(tl);
+ break;
+ case T_BACKEND_RANDOM:
+ case T_BACKEND_ROUND_ROBIN:
+ vcc_ParseBalancedBackend(tl);
break;
case EOI:
break;
- case ID:
- if (vcc_IdIs(tl->t, "backend")) {
- vcc_ParseBackend(tl);
- break;
- }
- if (vcc_IdIs(tl->t, "director")) {
- vcc_ParseDirector(tl);
- break;
- }
- /* FALLTHROUGH */
default:
vsb_printf(tl->sb,
"Expected 'acl', 'sub' or 'backend', found ");
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvcl/vcc_priv.h
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: vcc_priv.h 2415 2008-01-31 11:57:51Z des $
+ * $Id: vcc_priv.h 2496 2008-02-17 09:26:32Z des $
*
* Stuff shared between main.c and fixed_token.c
*/
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvcl/vcc_string.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: vcc_string.c 2549 2008-03-04 09:29:54Z des $
+ * $Id: vcc_string.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
@@ -145,9 +145,6 @@
case INT:
Fb(tl, 0, "VRT_int_string(sp, %s)", vp->rname);
break;
- case FLOAT:
- Fb(tl, 0, "VRT_double_string(sp, %s)", vp->rname);
- break;
default:
vsb_printf(tl->sb,
"String representation of '%s' not implemented yet.\n",
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvcl/vcc_token.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: vcc_token.c 2627 2008-04-08 15:33:08Z phk $
+ * $Id: vcc_token.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
@@ -314,8 +314,7 @@
if (q < sp->e)
continue;
vcc_AddToken(tl, EOI, p, p + 2);
- vsb_printf(tl->sb,
- "Unterminated /* ... */ comment, starting at\n");
+ vsb_printf(tl->sb, "Unterminated /* ... */ comment, starting at\n");
vcc_ErrWhere(tl, tl->t);
return;
}
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvcl/vcc_token_defs.h
^
|
@@ -1,5 +1,5 @@
/*
- * $Id: vcc_token_defs.h 2367 2008-01-22 10:48:49Z phk $
+ * $Id: vcc_token_defs.h 1931 2007-08-31 12:14:06Z cecilihf $
*
* NB: This file is machine generated, DO NOT EDIT!
*
@@ -14,23 +14,26 @@
#define T_ELSIF 132
#define T_SUB 133
#define T_ACL 134
-#define T_INC 135
-#define T_DEC 136
-#define T_CAND 137
-#define T_COR 138
-#define T_LEQ 139
-#define T_EQ 140
-#define T_NEQ 141
-#define T_GEQ 142
-#define T_SHR 143
-#define T_SHL 144
-#define T_INCR 145
-#define T_DECR 146
-#define T_MUL 147
-#define T_DIV 148
-#define ID 149
-#define VAR 150
-#define CNUM 151
-#define CSTR 152
-#define EOI 153
-#define CSRC 154
+#define T_BACKEND 135
+#define T_BACKEND_ROUND_ROBIN 136
+#define T_BACKEND_RANDOM 137
+#define T_INC 138
+#define T_DEC 139
+#define T_CAND 140
+#define T_COR 141
+#define T_LEQ 142
+#define T_EQ 143
+#define T_NEQ 144
+#define T_GEQ 145
+#define T_SHR 146
+#define T_SHL 147
+#define T_INCR 148
+#define T_DECR 149
+#define T_MUL 150
+#define T_DIV 151
+#define ID 152
+#define VAR 153
+#define CNUM 154
+#define CSTR 155
+#define EOI 156
+#define CSRC 157
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvcl/vcc_var.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: vcc_var.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: vcc_var.c 2564 2008-03-08 13:38:23Z des $
*/
#include "config.h"
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/lib/libvcl/vcc_xref.c
^
|
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: vcc_xref.c 2455 2008-02-13 13:55:39Z des $
+ * $Id: vcc_xref.c 2564 2008-03-08 13:38:23Z des $
*
* This fine contains code for two cross-reference or consistency checks.
*
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/man/vcl.7
^
|
@@ -26,7 +26,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: vcl.7 2448 2008-02-13 10:55:03Z phk $
+.\" $Id: vcl.7 2496 2008-02-17 09:26:32Z des $
.\"
.Dd August 10, 2007
.Dt VCL 7
@@ -80,8 +80,8 @@
A backend declaration creates and initializes a named backend object:
.Bd -literal -offset 4n
backend www {
- .host = "www.example.com";
- .port = "http";
+ set backend.host = "www.example.com";
+ set backend.port = "http";
}
.Ed
.Pp
@@ -97,9 +97,9 @@
which can later be used to match client addresses:
.Bd -literal -offset 4n
acl local {
- "localhost"; /* myself */
- "192.0.2.0"/24; /* and everyone on the local network */
- ! "192.0.2.23"; /* except for the dialin router */
+ "locahost"; /* myself */
+ "10.0.0.1"/8; /* and everyone on the local network */
+ ! "10.0.0.23"; /* except for the dialin router */
}
.Ed
.Pp
@@ -445,14 +445,6 @@
seconds.
.El
.Pp
-The following variables are available while determining the hash key
-of an object:
-.Bl -tag -width 4n
-.It Va req.hash
-The hash key used to refer to an object in the cache. Used when both
-reading from and writing to the cache.
-.El
-.Pp
The following variables are available while preparing a response to
the client:
.Bl -tag -width 4n
@@ -624,7 +616,7 @@
.Bd -literal -offset 4n
acl purge {
"localhost";
- "192.0.2.1"/24;
+ "10.0.0.1"/8;
}
sub vcl_recv {
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/redhat/README.redhat
^
|
@@ -24,14 +24,12 @@
Builing a RPM package from SVN
-==============================
+===============================
You may build the package from a svn checkout. Follow the instructions
at http://varnish.projects.linpro.no/wiki/Repository to get the
source. Then enter the trunk directory and edit
varnish-cache/redhat/varnish.spec. At least bump the version and/or
-release numbers, and uncomment the autogen call. You need to install
-the autoconf and automake packages. Then use something like this to
-build the rpm package:
+release numbers. Then use something like this to build the rpm package:
#!/bin/bash
VERSION=$( awk ' /^Version:/ { print $2 } ' varnish-cache/redhat/varnish.spec )
@@ -43,10 +41,6 @@
done
) -cvzf varnish-$VERSION.tar.gz varnish-$VERSION/*
rm varnish-$VERSION
-rpmbuild -ts varnish-$VERSION.tar.gz
-# End of script
+rpmbuild -tb varnish-$VERSION.tar.gz
-This builds a source rpm. Then you can, for example on a RHEL4 system,
-do something like this:
-rpmbuild --define "dist el4" --rebuild /path/to/varnish-1.1.2.src.rpm
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/redhat/varnish.initrc
^
|
@@ -26,9 +26,6 @@
# Open files (usually 1024, which is way too small for varnish)
ulimit -n ${NFILES:-131072}
-# Varnish wants to lock shared memory log in memory.
-ulimit -l ${MEMLOCK:-82000}
-
# See how we were called.
case "$1" in
start)
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/redhat/varnish.spec
^
|
@@ -1,16 +1,13 @@
Summary: Varnish is a high-performance HTTP accelerator
Name: varnish
-Version: 2.0
-Release: pre_svn20080307%{?dist}
-License: BSD
+Version: 1.1.svn
+Release: 200708142344%{?dist}
+License: BSD-like
Group: System Environment/Daemons
URL: http://www.varnish-cache.org/
Source0: http://downloads.sourceforge.net/varnish/varnish-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-# The svn sources needs autoconf, automake and libtoolto generate a suitable
-# configure script. Release tarballs would not need this
-#BuildRequires: automake autoconf libtool
-BuildRequires: ncurses-devel libxslt
+BuildRequires: ncurses-devel automake autoconf libtool
Requires: kernel >= 2.6.0 varnish-libs = %{version}-%{release}
Requires: logrotate
Requires(pre): shadow-utils
@@ -53,10 +50,7 @@
# The svn sources needs to generate a suitable configure script
# Release tarballs would not need this
-# ./autogen.sh
-
-mkdir examples
-cp etc/default.vcl etc/zope-plone.vcl examples
+./autogen.sh
%build
@@ -110,8 +104,7 @@
%{_var}/log/varnish
%{_mandir}/man1/*.1*
%{_mandir}/man7/*.7*
-%doc INSTALL LICENSE README redhat/README.redhat ChangeLog
-%doc examples
+%doc INSTALL LICENSE README redhat/README.redhat redhat/default.vcl ChangeLog
%dir %{_sysconfdir}/varnish/
%config(noreplace) %{_sysconfdir}/varnish/default.vcl
%config(noreplace) %{_sysconfdir}/sysconfig/varnish
@@ -128,7 +121,6 @@
%defattr(-,root,root,-)
%{_libdir}/libvarnish.so
%{_libdir}/libvarnishapi.so
-%{_libdir}/libvarnishcompat.so
%{_libdir}/libvcl.so
%{_includedir}/varnish/shmlog.h
%{_includedir}/varnish/shmlog_tags.h
@@ -172,38 +164,11 @@
%postun libs -p /sbin/ldconfig
%changelog
-* Sat Dec 29 2007 Ingvar Hagelund <ingvar@linpro.no> - 1.1.2-5
-- Added missing configuration examples
-- Corrected the license to "BSD"
-
-* Fri Dec 28 2007 Ingvar Hagelund <ingvar@linpro.no> - 1.1.2-4
-- Build for fedora update
-
-* Fri Dec 28 2007 Ingvar Hagelund <ingvar@linpro.no> - 1.1.2-2
-- Added missing changelog items
-
-* Thu Dec 20 2007 Stig Sandbeck Mathisen <ssm@linpro.no> - 1.1.2-1
-- Bumped the version number to 1.1.2.
-- Addeed build dependency on libxslt
-
-* Wed Sep 08 2007 Ingvar Hagelund <ingvar@linpro.no> - 1.1.1-3
-- Added a patch, changeset 1913 from svn trunk. This makes varnish
- more stable under specific loads.
-
-* Tue Sep 06 2007 Ingvar Hagelund <ingvar@linpro.no> - 1.1.1-2
-- Removed autogen call (only diff from relase tarball)
-
-* Mon Aug 20 2007 Ingvar Hagelund <ingvar@linpro.no> - 1.1.1-1
-- Bumped the version number to 1.1.1.
-
* Tue Aug 14 2007 Ingvar Hagelund <ingvar@linpro.no> - 1.1.svn
- Update for 1.1 branch
- Added the devel package for the header files and static library files
- Added a varnish user, and fixed the init script accordingly
-* Thu Jul 05 2007 Dag-Erling Smørgrav <des@linpro.no> - 1.1-1
-- Bump Version and Release for 1.1
-
* Mon May 28 2007 Ingvar Hagelund <ingvar@linpro.no> - 1.0.4-3
- Fixed initrc-script bug only visible on el4 (fixes #107)
|
[-]
[+]
|
Changed |
varnish-20080428.tar.bz2/redhat/varnish.sysconfig
^
|
@@ -7,10 +7,6 @@
# Maximum number of open files (for ulimit -n)
NFILES=131072
-# Locked shared memory (for ulimit -l)
-# Default log size is 82MB + header
-MEMLOCK=82000
-
# This file contains 4 alternatives, please use only one.
## Alternative 1, Minimal configuration, no VCL
|