time_t lastcp, lastar;
};
+int dbpagesize = 0;
+
static struct fileinfo dbserve(struct source *src, char *nm)
{
struct dbsrc *d = src->pdata;
flog(LOG_ERR, "could not create bdb database: %s", db_strerror(ret));
exit(1);
}
+ if(dbpagesize) {
+ if((ret = d->db->set_pagesize(d->db, dbpagesize)) != 0) {
+ flog(LOG_ERR, "could not set bdb page size (to %i): %s", dbpagesize, db_strerror(ret));
+ exit(1);
+ }
+ }
if((ret = d->db->open(d->db, NULL, path, NULL, DB_HASH, DB_AUTO_COMMIT | DB_CREATE, 0666)) != 0) {
flog(LOG_ERR, "could not open bdb database: %s", db_strerror(ret));
exit(1);
static struct charvbuf files;
static int verbose = 0;
-static void opendb(char *path)
+static void opendb(char *path, int pagesize)
{
char *envpath, *p;
int ret;
fprintf(stderr, "statdbput: could not create db handle: %s\n", db_strerror(ret));
exit(1);
}
+ if(pagesize) {
+ if((ret = db->set_pagesize(db, pagesize)) != 0) {
+ fprintf(stderr, "statdbput: could not set db page size (to %i): %s", pagesize, db_strerror(ret));
+ exit(1);
+ }
+ }
if((ret = db->open(db, NULL, path, NULL, DB_HASH, DB_AUTO_COMMIT | DB_CREATE, 0666)) != 0) {
fprintf(stderr, "statdbput: %s: %s\n", path, db_strerror(ret));
exit(1);
static void usage(FILE *out)
{
- fprintf(out, "usage: statdbput [-hvD] [-n NAME] DB CONTENT-TYPE {FILE|-}...\n");
- fprintf(out, " statdbput [-hvD] [-d] DB CONTENT-TYPE DIR...\n");
+ fprintf(out, "usage: statdbput [-hvD] [-P PAGESIZE] [-n NAME] DB CONTENT-TYPE {FILE|-}...\n");
+ fprintf(out, " statdbput [-hvD] [-P PAGESIZE] [-d] DB CONTENT-TYPE DIR...\n");
}
int main(int argc, char **argv)
int c, rv, ret;
int dm, ul, i, a;
char *name, *ctype, *dbpath;
+ int pagesize;
dm = ul = 0;
name = NULL;
- while((c = getopt(argc, argv, "+hvDdn:")) >= 0) {
+ pagesize = 0;
+ while((c = getopt(argc, argv, "+hvDdn:P:")) >= 0) {
switch(c) {
case 'd':
dm = 1;
case 'n':
name = optarg;
break;
+ case 'P':
+ pagesize = atoi(optarg);
+ break;
case 'h':
usage(stdout);
return(0);
}
dbpath = argv[optind++];
ctype = argv[optind++];
- opendb(dbpath);
+ opendb(dbpath, pagesize);
while(1) {
if((ret = env->txn_begin(env, NULL, &txn, 0)) != 0) {
fprintf(stderr, "statdbput: could not begin transaction in %s: %s\n", dbpath, db_strerror(ret));
static void usage(FILE *out)
{
- fprintf(out, "usage: statserve [-h] SOURCE...\n");
+ fprintf(out, "usage: statserve [-h] [-P PAGESIZE] SOURCE...\n");
}
static void listenloop(struct muth *muth, va_list args)
int c;
struct source *last, *src;
- while((c = getopt(argc, argv, "+h")) >= 0) {
+ while((c = getopt(argc, argv, "+hP:")) >= 0) {
switch(c) {
+ case 'P':
+ dbpagesize = atoi(optarg);
+ break;
case 'h':
usage(stdout);
return(0);