diff options
Diffstat (limited to 'src/c/http.c')
-rw-r--r-- | src/c/http.c | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/src/c/http.c b/src/c/http.c index 21ad809f..de2f1376 100644 --- a/src/c/http.c +++ b/src/c/http.c @@ -11,6 +11,7 @@ #include <unistd.h> #include <signal.h> #include <stdarg.h> +#include <sys/un.h> #include <pthread.h> @@ -46,6 +47,7 @@ static char *get_header(void *data, const char *h) { } static char *get_env(void *data, const char *name) { + (void)data; return getenv(name); } @@ -58,24 +60,30 @@ static void on_failure(uw_context ctx) { } static void log_error(void *data, const char *fmt, ...) { + (void)data; + va_list ap; va_start(ap, fmt); vfprintf(stderr, fmt, ap); + fflush(stderr); } static void log_debug(void *data, const char *fmt, ...) { + (void)data; + if (!quiet) { va_list ap; va_start(ap, fmt); vprintf(fmt, ap); + fflush(stdout); } } static uw_loggers ls = {NULL, log_error, log_debug}; -static unsigned max_buf_size = 1024 * 1024; // That's 1MB. +static unsigned max_buf_size = 10 * 1024 * 1024; // That's 10MB. static void *worker(void *data) { int me = *(int *)data; @@ -328,10 +336,11 @@ static void *worker(void *data) { } static void help(char *cmd) { - printf("Usage: %s [-p <port>] [-a <IPv4 address>] [-A <IPv6 address>] [-t <thread count>] [-m <bytes>] [-k] [-q] [-T SEC]\nThe '-k' option turns on HTTP keepalive.\nThe '-q' option turns off some chatter on stdout.\nThe '-T' option sets socket recv timeout (0 disables timeout, default is 5 sec).\nThe '-m' sets the maximum size (in bytes) for any buffer used to hold HTTP data sent by clients. (The default is 1 MB.)\n", cmd); + printf("Usage: %s [-p <port>] [-a <IPv4 address>] [-A <IPv6 address>] [-u <UNIX socket>] [-t <thread count>] [-m <bytes>] [-k] [-q] [-T SEC]\nThe '-k' option turns on HTTP keepalive.\nThe '-q' option turns off some chatter on stdout.\nThe '-T' option sets socket recv timeout (0 disables timeout, default is 5 sec).\nThe '-m' sets the maximum size (in bytes) for any buffer used to hold HTTP data sent by clients. (The default is 1 MB.)\n", cmd); } static void sigint(int signum) { + (void)signum; printf("Exiting....\n"); exit(0); } @@ -340,6 +349,7 @@ union uw_sockaddr { struct sockaddr sa; struct sockaddr_in ipv4; struct sockaddr_in6 ipv6; + struct sockaddr_un un; }; int main(int argc, char *argv[]) { @@ -359,7 +369,7 @@ int main(int argc, char *argv[]) { my_addr.sa.sa_family = AF_INET; my_addr.ipv4.sin_addr.s_addr = INADDR_ANY; // auto-fill with my IP - while ((opt = getopt(argc, argv, "hp:a:A:t:kqT:m:")) != -1) { + while ((opt = getopt(argc, argv, "hp:a:A:u:t:kqT:m:")) != -1) { switch (opt) { case '?': fprintf(stderr, "Unknown command-line option\n"); @@ -397,6 +407,15 @@ int main(int argc, char *argv[]) { } break; + case 'u': + my_addr.sa.sa_family = AF_UNIX; + if (!strncpy(my_addr.un.sun_path, optarg, sizeof(my_addr.un.sun_path)-1)) { + fprintf(stderr, "Invalid UNIX socket filename\n"); + help(argv[0]); + return 1; + } + break; + case 't': nthreads = atoi(optarg); if (nthreads <= 0) { @@ -466,6 +485,11 @@ int main(int argc, char *argv[]) { my_size = sizeof(my_addr.ipv6); my_addr.ipv6.sin6_port = htons(uw_port); break; + + case AF_UNIX: + unlink(my_addr.un.sun_path); + my_size = sizeof(my_addr.un); + break; } if (bind(sockfd, &my_addr.sa, my_size) < 0) { @@ -542,12 +566,17 @@ void *uw_init_client_data() { } void uw_free_client_data(void *data) { + (void)data; } void uw_copy_client_data(void *dst, void *src) { + (void)dst; + (void)src; } void uw_do_expunge(uw_context ctx, uw_Basis_client cli, void *data) { + (void)data; + uw_ensure_transaction(ctx); uw_get_app(ctx)->expunger(ctx, cli); @@ -556,6 +585,8 @@ void uw_do_expunge(uw_context ctx, uw_Basis_client cli, void *data) { } void uw_post_expunge(uw_context ctx, void *data) { + (void)ctx; + (void)data; } int uw_supports_direct_status = 1; |