aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranklin Wei <me@fwei.tk>2018-06-28 21:14:57 -0400
committerFranklin Wei <me@fwei.tk>2018-06-28 21:14:57 -0400
commit03a354b8d0f2a8820db9571c639804648d804ac4 (patch)
treeb3328a16ee381badc89d9ae9613c0fb8658060eb
parent2c2257bf23358ec71cbe6420a3b398ffd63849cd (diff)
downloadcsaa-03a354b8d0f2a8820db9571c639804648d804ac4.zip
csaa-03a354b8d0f2a8820db9571c639804648d804ac4.tar.gz
csaa-03a354b8d0f2a8820db9571c639804648d804ac4.tar.bz2
csaa-03a354b8d0f2a8820db9571c639804648d804ac4.tar.xz
Modify for testing init only
-rw-r--r--main.c7
-rw-r--r--service_provider.c17
-rw-r--r--service_provider.h8
3 files changed, 21 insertions, 11 deletions
diff --git a/main.c b/main.c
index f90a788..bc8717a 100644
--- a/main.c
+++ b/main.c
@@ -48,9 +48,12 @@ int main(int argc, char *argv[])
{
//run_tests();
+ const char *dbpath = "csaa.db";
int logleaves = 10;
- if(argc == 2)
+ if(argc >= 2)
logleaves = atol(argv[1]);
+ if(argc >= 3)
+ dbpath = argv[2];
const char *socket_name = "socket";
int sockfd;
@@ -69,5 +72,5 @@ int main(int argc, char *argv[])
signal(SIGTERM, signal_handler);
signal(SIGSEGV, signal_handler);
- sp_main(sockfd, logleaves);
+ sp_main(sockfd, logleaves, dbpath);
}
diff --git a/service_provider.c b/service_provider.c
index 852e208..96f12d2 100644
--- a/service_provider.c
+++ b/service_provider.c
@@ -209,12 +209,12 @@ void commit_transaction(void *db)
}
/* leaf count will be 2^logleaves */
-struct service_provider *sp_new(const void *key, size_t keylen, int logleaves, const char *data_dir)
+struct service_provider *sp_new(const void *key, size_t keylen, int logleaves, const char *data_dir, const char *dbpath)
{
assert(logleaves > 0);
struct service_provider *sp = calloc(1, sizeof(*sp));
- sp->db = db_init("csaa.db");
+ sp->db = db_init(dbpath);
sp->tm = tm_new(key, keylen);
@@ -262,7 +262,7 @@ struct service_provider *sp_new(const void *key, size_t keylen, int logleaves, c
#endif
assert(tm_set_equiv_root(sp->tm, &eq, hmac));
- printf("%d\n", i);
+ //printf("%d\n", i);
}
/* now transfer to database */
@@ -288,7 +288,7 @@ struct service_provider *sp_new(const void *key, size_t keylen, int logleaves, c
clock_t stop = clock();
- printf("sp_init(): logleaves=%d, time=%.1fsec, overall_rate=%.1f/sec, db_time=%.1fsec\n",
+ printf("sp_init(): logleaves=%d, time=%.3fsec, overall_rate=%.3f/sec, db_time=%.3fsec\n",
logleaves, (double)(stop - start) / CLOCKS_PER_SEC,
(double)(1ULL << logleaves) * CLOCKS_PER_SEC / ( stop - start ),
(double)(stop - point1) / CLOCKS_PER_SEC);
@@ -1148,7 +1148,7 @@ static void sp_handle_client(struct service_provider *sp, int cl)
}
}
-int sp_main(int sockfd, int logleaves)
+int sp_main(int sockfd, int logleaves, const char *dbpath)
{
#define BACKLOG 10
@@ -1162,7 +1162,10 @@ int sp_main(int sockfd, int logleaves)
printf("Initializing IOMT with logleaves = %d...\n", logleaves);
- struct service_provider *sp = sp_new("a", 1, logleaves, "files");
+ struct service_provider *sp = sp_new("a", 1, logleaves, "files", dbpath);
+
+ /* test init only */
+ return 0;
while(1)
{
@@ -1191,7 +1194,7 @@ void sp_test(void)
printf("Initializing IOMT with %llu nodes.\n", 1ULL << logleaves);
clock_t start = clock();
- struct service_provider *sp = sp_new("a", 1, logleaves, "files");
+ struct service_provider *sp = sp_new("a", 1, logleaves, "files", "csaa.db");
clock_t stop = clock();
check("Tree initialization", sp != NULL);
diff --git a/service_provider.h b/service_provider.h
index 79a2edf..fe7a4cd 100644
--- a/service_provider.h
+++ b/service_provider.h
@@ -65,7 +65,11 @@ struct user_request {
} __attribute__((packed));
#ifndef CLIENT
-struct service_provider *sp_new(const void *key, size_t keylen, int logleaves, const char *data_dir);
+struct service_provider *sp_new(const void *key,
+ size_t keylen,
+ int logleaves,
+ const char *data_dir,
+ const char *dbpath);
void sp_free(struct service_provider *sp);
/* see .c file for documentation */
@@ -125,7 +129,7 @@ void *sp_retrieve_file(struct service_provider *sp,
struct iomt **composefile,
size_t *len);
-int sp_main(int sockfd, int logleaves);
+int sp_main(int sockfd, int logleaves, const char *dbpath);
void sp_test(void);
#endif