unsigned char *ptr;
unsigned len;
void *priv;
+ struct stevedore *stevedore;
};
-typedef void storage_init_f(void);
-typedef struct storage *storage_alloc_f(unsigned size);
-typedef void storage_free_f(struct storage *);
-
-struct stevedore {
- const char *name;
- storage_init_f *init;
- storage_alloc_f *alloc;
- storage_free_f *free;
-};
-
-extern struct stevedore sma_stevedore;
+#include "_stevedore.h"
+/*
+ * XXX: in the longer term, we want to support multiple stevedores,
+ * XXX: selected by some kind of heuristics based on size, lifetime
+ * XXX: etc etc. For now we support only one.
+ */
extern struct stevedore *stevedore;
/* Prototypes etc ----------------------------------------------------*/
usage(void)
{
fprintf(stderr, "usage: varnishd [options]\n");
- fprintf(stderr, " %-20s # %s\n", "-b", "backend_IP_number");
- fprintf(stderr, " %-20s # %s\n", "-d", "debug");
- fprintf(stderr, " %-20s # %s\n", "-f", "VCL_file");
- fprintf(stderr, " %-20s # %s\n", "-p number", "TCP listen port");
+ fprintf(stderr, " %-28s # %s\n", "-b", "backend_IP_number");
+ fprintf(stderr, " %-28s # %s\n", "-d", "debug");
+ fprintf(stderr, " %-28s # %s\n", "-f", "VCL_file");
+ fprintf(stderr, " %-28s # %s\n", "-p number", "TCP listen port");
+ fprintf(stderr, " %-28s # %s\n",
+ "-s kind[,storageoptions]", "Backend storage specification");
#if 0
-c clusterid@cluster_controller
-m memory_limit
/*--------------------------------------------------------------------*/
+static int
+cmp_storage(struct stevedore *s, const char *p, const char *q)
+{
+ if (strlen(s->name) != q - p)
+ return (1);
+ if (strncmp(s->name, p, q - p))
+ return (1);
+ return (0);
+}
+
+static void
+setup_storage(const char *sflag)
+{
+ const char *p;
+
+ p = strchr(sflag, ',');
+ if (p == NULL)
+ p = strchr(sflag, '\0');
+ if (!cmp_storage(&sma_stevedore, sflag, p)) {
+ heritage.stevedore = &sma_stevedore;
+ } else {
+ fprintf(stderr, "Unknown storage method \"%*.*s\"\n",
+ p - sflag, p - sflag, sflag);
+ exit (2);
+ }
+ if (heritage.stevedore->init != NULL)
+ heritage.stevedore->init(heritage.stevedore, p);
+}
+
+/*--------------------------------------------------------------------*/
+
#include "shmlog.h"
static void
AZ(ftruncate(heritage.vsl_fd, sizeof slh + size));
heritage.vsl_size = slh.size + slh.start;
}
+
/*--------------------------------------------------------------------*/
/* for development purposes */
unsigned dflag = 1; /* XXX: debug=on for now */
const char *bflag = NULL;
const char *fflag = NULL;
+ const char *sflag = "malloc";
register_printf_render_std((const unsigned char *)"HVQ");
case 'p':
portnumber = optarg;
break;
+ case 's':
+ sflag = optarg;
+ break;
default:
usage();
}
if (heritage.vcl_file == NULL)
exit (1);
+ setup_storage(sflag);
+
/*
* XXX: Lacking the suspend/resume facility (due to the socket API
* missing an unlisten(2) facility) we may want to push this into
testme();
-
exit(0);
}