aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranklin Wei <me@fwei.tk>2018-06-28 18:59:52 -0400
committerFranklin Wei <me@fwei.tk>2018-06-28 18:59:52 -0400
commitcfa1e7cbf63c242abf6de27d631674a6623dffe2 (patch)
tree698034eb22ba9b7d64952892f4b738c733be2f33
parente339c26e420d36f1482015746a95d3abfc134cb7 (diff)
downloadcsaa-cfa1e7cbf63c242abf6de27d631674a6623dffe2.zip
csaa-cfa1e7cbf63c242abf6de27d631674a6623dffe2.tar.gz
csaa-cfa1e7cbf63c242abf6de27d631674a6623dffe2.tar.bz2
csaa-cfa1e7cbf63c242abf6de27d631674a6623dffe2.tar.xz
Add configurable logleaves
-rw-r--r--main.c10
-rw-r--r--service_provider.c5
-rw-r--r--service_provider.h2
3 files changed, 11 insertions, 6 deletions
diff --git a/main.c b/main.c
index 0707216..f90a788 100644
--- a/main.c
+++ b/main.c
@@ -44,10 +44,14 @@ void run_tests(void)
sp_test();
}
-int main()
+int main(int argc, char *argv[])
{
//run_tests();
+ int logleaves = 10;
+ if(argc == 2)
+ logleaves = atol(argv[1]);
+
const char *socket_name = "socket";
int sockfd;
if((sockfd = bind_unix_socket(socket_name)) < 0)
@@ -56,7 +60,7 @@ int main()
return 1;
}
- printf("Listening on '%s'\n", socket_name);
+ printf("Listening on socket '%s'...\n", socket_name);
cleanup_socket = socket_name;
@@ -65,5 +69,5 @@ int main()
signal(SIGTERM, signal_handler);
signal(SIGSEGV, signal_handler);
- sp_main(sockfd);
+ sp_main(sockfd, logleaves);
}
diff --git a/service_provider.c b/service_provider.c
index a731759..c917387 100644
--- a/service_provider.c
+++ b/service_provider.c
@@ -1133,7 +1133,7 @@ static void sp_handle_client(struct service_provider *sp, int cl)
}
}
-int sp_main(int sockfd)
+int sp_main(int sockfd, int logleaves)
{
#define BACKLOG 10
@@ -1145,7 +1145,8 @@ int sp_main(int sockfd)
signal(SIGPIPE, SIG_IGN);
- int logleaves = 10;
+ printf("Initializing IOMT with logleaves = %d...\n", logleaves);
+
struct service_provider *sp = sp_new("a", 1, logleaves, "files");
while(1)
diff --git a/service_provider.h b/service_provider.h
index 2f2434a..79a2edf 100644
--- a/service_provider.h
+++ b/service_provider.h
@@ -125,7 +125,7 @@ void *sp_retrieve_file(struct service_provider *sp,
struct iomt **composefile,
size_t *len);
-int sp_main(int sockfd);
+int sp_main(int sockfd, int logleaves);
void sp_test(void);
#endif