aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranklin Wei <me@fwei.tk>2018-07-19 23:42:28 -0400
committerFranklin Wei <me@fwei.tk>2018-07-19 23:42:28 -0400
commit4ef7acdbe514cd7e13c62ff22d8b0eb8c04cce1f (patch)
treef676864a8a706a456a82fd572b12b636a0fb54e7
parent75e5bf09506412ac679d60dc051f97d99d24702d (diff)
downloadcsaa-4ef7acdbe514cd7e13c62ff22d8b0eb8c04cce1f.zip
csaa-4ef7acdbe514cd7e13c62ff22d8b0eb8c04cce1f.tar.gz
csaa-4ef7acdbe514cd7e13c62ff22d8b0eb8c04cce1f.tar.bz2
csaa-4ef7acdbe514cd7e13c62ff22d8b0eb8c04cce1f.tar.xz
Implement dummy prepopulation (with a separate script)
-rw-r--r--Makefile2
-rw-r--r--crypto.c2
-rw-r--r--dummy_service.c46
-rwxr-xr-xprepopulate_dummy.sh15
4 files changed, 51 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index ffd0944..94dd005 100644
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,7 @@ dummy_main.o: main.c
dummy_client: dummy_client.o crypto.o test.o iomt.o sqlinit.o
cc -o $@ $^ -lcrypto $(CFLAGS)
-dummy_server: dummy_service.o dummy_main.o sqlinit.o
+dummy_server: dummy_service.o dummy_main.o sqlinit.o crypto.o
cc -o $@ $^ -lcrypto $(CFLAGS)
client: client.o crypto.o test.o iomt.o
cc -o $@ $^ -lcrypto $(CFLAGS)
diff --git a/crypto.c b/crypto.c
index 5d10101..21ca87a 100644
--- a/crypto.c
+++ b/crypto.c
@@ -526,7 +526,7 @@ void write_file(const char *path, const void *contents, size_t len)
void crypto_test(void)
{
-#if 1
+#if 0
int *orders;
uint64_t *comp = bintree_complement(6, 4, &orders);
uint64_t correct[] = { 22, 9, 3, 2 };
diff --git a/dummy_service.c b/dummy_service.c
index f0d275c..7be38f9 100644
--- a/dummy_service.c
+++ b/dummy_service.c
@@ -25,6 +25,9 @@
#include "trusted_module.h"
#include "service_provider.h"
+#define PREPOPULATE
+#define RUNS_TEST 500
+
/* arbitrary */
#define ACL_LOGLEAVES 4
@@ -138,18 +141,6 @@ void *db_init(const char *filename)
return db;
}
-void begin_transaction(void *db)
-{
- sqlite3 *handle = db;
- sqlite3_exec(handle, "BEGIN;", 0, 0, 0);
-}
-
-void commit_transaction(void *db)
-{
- sqlite3 *handle = db;
- sqlite3_exec(handle, "COMMIT;", 0, 0, 0);
-}
-
/* leaf count will be 2^logleaves */
struct service_provider *sp_new(const void *key, size_t keylen, int logleaves, const char *data_dir, const char *dbpath)
{
@@ -281,9 +272,11 @@ void sp_request(struct service_provider *sp,
{
rec->version++;
+#ifndef PREPOPULATE
/* write to disk */
write_contents(sp, req->idx, rec->version,
encrypted_contents, contents_len);
+#endif
}
if(need_insert)
@@ -476,9 +469,38 @@ static void sp_handle_client(struct service_provider *sp, int cl)
}
}
+static void sp_prepopulate(int logleaves, const char *dbpath)
+{
+ struct service_provider *sp = sp_new("a", 1, logleaves, "files", dbpath);
+
+ uint64_t n = (1 << logleaves) - RUNS_TEST;
+
+ const char *filename = "container1/hello-world.tar";
+ size_t file_len;
+
+ const void *file = load_file(filename, &file_len);
+
+ for(uint64_t i = 0; i < n; ++i)
+ {
+ sp_createfile(sp, 1);
+ sp_modifyfile(sp, 1, i + 1,
+ file, file_len);
+ }
+
+ sp_free(sp);
+}
+
int sp_main(int sockfd, int logleaves, const char *dbpath, bool overwrite)
{
(void) overwrite;
+
+#ifdef PREPOPULATE
+ /* prepopulate only */
+ sp_prepopulate(logleaves, dbpath);
+
+ return 0;
+#endif
+
#define BACKLOG 10
if(listen(sockfd, BACKLOG) < 0)
diff --git a/prepopulate_dummy.sh b/prepopulate_dummy.sh
new file mode 100755
index 0000000..2b84a5c
--- /dev/null
+++ b/prepopulate_dummy.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+mkdir -p databases
+
+pids=""
+
+for i in `seq 10 25`
+do
+ echo $i
+ rm -f socket
+ ./dummy_server $i databases/dummy_$i.db > /dev/null &
+ pids=$pids" "$!
+done
+
+wait $pids