would ya believe it it's another clang-format update

This commit is contained in:
aiden 2022-03-30 05:12:05 +01:00
parent 2954d3f642
commit 58971d41e5
No known key found for this signature in database
GPG Key ID: 0D87FF3415416DB1
9 changed files with 98 additions and 106 deletions

@ -36,6 +36,7 @@ BraceWrapping:
BreakBeforeTernaryOperators: true
BreakStringLiterals: false
ColumnLimit: 300
ContinuationIndentWidth: 8
DeriveLineEnding: false
DerivePointerAlignment: false
DisableFormat: false

@ -10,9 +10,9 @@ __attribute__((warn_unused_result)) int bdd_poll(struct bdd_connections *connect
struct bdd_io *io = &(connections->io[io_id]);
assert(io->fd != -1);
struct pollfd pollfd = {
.fd = io->fd,
.events = POLLIN | POLLOUT | POLLRDHUP,
.revents = 0,
.fd = io->fd,
.events = POLLIN | POLLOUT | POLLRDHUP,
.revents = 0,
};
poll(&(pollfd), 1, 0);
if (io->ssl != NULL && SSL_has_pending(io->ssl)) {

@ -13,8 +13,8 @@ struct bdd_name_description *bdd_name_description_alloc(void) {
void bdd_name_description_clean_ssl_ctx(struct bdd_name_description *name_description) {
if (name_description->ssl_ctx != NULL) {
SSL_CTX_free(name_description->ssl_ctx); // misleading function name; it actually
// decs the ref count and frees the ssl_ctx
// if the rc hits 0
// decs the ref count and frees the ssl_ctx
// if the rc hits 0
name_description->ssl_ctx = NULL;
}
return;

@ -19,12 +19,10 @@ bdd_serve__find_connections:;
n_events = epoll_wait(instance->epoll_fd, instance->epoll_oevents, instance->n_epoll_oevents, -1);
} while (n_events < 0 && errno == EINTR);
if (unlikely(n_events < 0)) {
fprintf(
stderr,
"bidirectiond epoll error: %i - try increasing your "
"rlimits for open files\n",
errno
);
fprintf(stderr,
"bidirectiond epoll error: %i - try increasing your "
"rlimits for open files\n",
errno);
bdd_stop(instance);
bdd_thread_exit(instance);
}
@ -126,8 +124,8 @@ bdd_serve__find_connections:;
pthread_mutex_lock(&(workers->available_stack.mutex));
if (workers->available_stack.idx == workers->n_workers) {
BDD_DEBUG_LOG(
"no available worker "
"threads; waiting...\n"
"no available worker "
"threads; waiting...\n"
);
do {
pthread_cond_wait(&(workers->available_stack.cond), &(workers->available_stack.mutex));

@ -4,14 +4,14 @@
void bdd_signal(struct bdd_instance *instance) {
char buf[8] = {
~0,
0,
0,
0,
0,
0,
0,
~0,
~0,
0,
0,
0,
0,
0,
0,
~0,
};
int r = write(instance->serve_eventfd, (void *)buf, 8);
assert(r == 8 || r < 0);
@ -20,14 +20,14 @@ void bdd_signal(struct bdd_instance *instance) {
void bdd_stop_accept(struct bdd_instance *instance) {
char buf[8] = {
~0,
0,
0,
0,
0,
0,
0,
~0,
~0,
0,
0,
0,
0,
0,
0,
~0,
};
int r = write(instance->accept.eventfd, (void *)buf, 8);
assert(r == 8 || r < 0);

@ -1 +1 @@
Subproject commit f610c4618f586e59abb4c46895c6287f1848707b
Subproject commit 91692ac4a29de46a1d167dd706821fd0796ab2dd

@ -50,14 +50,14 @@ void input_processor(int sfd, char *br_buf, int br_buf_sz) {
char *str;
uint8_t str_sz;
} match_list[] = {
{
.str = "TLS_PEM_LOAD",
.str_sz = 12,
},
{
.str = "PING",
.str_sz = 4,
},
{
.str = "TLS_PEM_LOAD",
.str_sz = 12,
},
{
.str = "PING",
.str_sz = 4,
},
};
input_processor__process:;
@ -154,8 +154,8 @@ input_processor__matched:;
br_ctx.byte = 1;
}
struct bdd_cp_ctx cp_ctx = {
.success = false,
.password = NULL,
.success = false,
.password = NULL,
};
if (br_ctx.byte != 1) {
char env_variable_name[0x100];

@ -27,16 +27,15 @@
#endif
struct bdd_settings settings = {
.name_descriptions = NULL,
.n_connections = 0x100,
.n_epoll_oevents = 0x100,
.buf_sz = 0x800,
.n_worker_threads = 16,
.client_timeout = 12000,
.use_stack_buf = false,
.sv_socket = -1,
.use_work_queues = false,
// .sigmask = x,
.name_descriptions = NULL,
.n_connections = 0x100,
.n_epoll_oevents = 0x100,
.buf_sz = 0x800,
.n_worker_threads = 16,
.client_timeout = 12000,
.use_stack_buf = false,
.sv_socket = -1,
.use_work_queues = false,
};
#define PASTE(x, y) x##y
@ -63,7 +62,7 @@ void storlim(rlim_t *dest, char *str) {
return;
}
if (v == (rlim_t)v) {
*dest = (rlim_t)v;
(*dest) = (rlim_t)v;
}
return;
}
@ -82,8 +81,8 @@ int main(int argc, char *argv[], char *env[]) {
struct bdd_instance *bdd_instance = NULL;
int input_fd = -1;
struct sockaddr_un input_addr = {
0,
.sun_family = AF_UNIX,
0,
.sun_family = AF_UNIX,
};
int sig_fd = -1;
@ -181,8 +180,8 @@ main__arg_iter:;
arg += 1;
} else if (strcmp((*arg), "--nohup") == 0) {
struct sigaction action = {
.sa_handler = SIG_IGN,
.sa_flags = SA_RESTART,
.sa_handler = SIG_IGN,
.sa_flags = SA_RESTART,
};
sigaction(SIGHUP, &(action), 0);
arg += 1;
@ -197,8 +196,8 @@ main__arg_iter:;
goto main__arg_creds_err;
}
struct bdd_cp_ctx cp_ctx = {
.success = false,
.password = getenv(arg[3]),
.success = false,
.password = getenv(arg[3]),
};
SSL_CTX_set_default_passwd_cb(ctx, bdd_cp_pwd);
SSL_CTX_set_default_passwd_cb_userdata(ctx, &(cp_ctx));
@ -227,11 +226,9 @@ main__arg_creds_err:;
}
arg += 4;
} else if (strcmp((*arg), "--UNSAFE allocate buffer on stack") == 0) {
fputs(
"'--UNSAFE allocate buffer on stack' is unsafe and "
"shouldn't be used\n",
stderr
);
fputs("'--UNSAFE allocate buffer on stack' is unsafe and "
"shouldn't be used\n",
stderr);
settings.use_stack_buf = true;
arg += 1;
} else if (getuid() == 0 && strcmp((*arg), "--uid") == 0) {
@ -279,31 +276,29 @@ main__arg_creds_err:;
}
}
main__arg_fuck:;
puts(
"argument parsing failed\n"
"-t: set the amount of worker threads\n"
"--client-timeout: set the timeout (in ms) for "
"client socket i/o\n"
"-l: set the rlimits for open files (soft limit, "
"hard limit)\n"
"-b: set the size of the large worker buffers\n"
"--backlog: set the tcp backlog for sv_socket\n"
"-p: set the tcp port to bind sv_socket to\n"
"--max-connections: the max amount of "
"bdd_connections structs\n"
"--disable-ipv6: sv_socket should not use ipv6\n"
"--use-work-queue: do not wait for worker threads "
"before giving them work\n"
"--nohup: SIG_IGN SIGHUP\n"
"-c: load pem-encoded tls credentials (e.g. `-c "
"cert.pem encrypted-key.pem "
"name-of-password-environment-variable`)\n"
"--input: set the path for a udp unix socket, so "
"that some bidirectiond settings can be modified "
"without restarting\n"
"--n-epoll-oevents: epoll_wait maxevents\n"
"--big-alloc: reserve some ram"
);
puts("argument parsing failed\n"
"-t: set the amount of worker threads\n"
"--client-timeout: set the timeout (in ms) for "
"client socket i/o\n"
"-l: set the rlimits for open files (soft limit, "
"hard limit)\n"
"-b: set the size of the large worker buffers\n"
"--backlog: set the tcp backlog for sv_socket\n"
"-p: set the tcp port to bind sv_socket to\n"
"--max-connections: the max amount of "
"bdd_connections structs\n"
"--disable-ipv6: sv_socket should not use ipv6\n"
"--use-work-queue: do not wait for worker threads "
"before giving them work\n"
"--nohup: SIG_IGN SIGHUP\n"
"-c: load pem-encoded tls credentials (e.g. `-c "
"cert.pem encrypted-key.pem "
"name-of-password-environment-variable`)\n"
"--input: set the path for a udp unix socket, so "
"that some bidirectiond settings can be modified "
"without restarting\n"
"--n-epoll-oevents: epoll_wait maxevents\n"
"--big-alloc: reserve some ram");
for (size_t idx = 0; idx < N_INTERNAL_SERVICES; ++idx) {
if (internal_services[idx].arguments_help != NULL) {
fputs(internal_services[idx].arguments_help, stdout);
@ -335,7 +330,7 @@ main__arg_fuck:;
struct sockaddr_in inet4;
struct sockaddr_in6 inet6;
} sv_addr = {
0,
0,
};
size_t sv_addr_sz = 0;
if (disable_ipv6) {
@ -355,11 +350,9 @@ main__arg_fuck:;
int opt = 1;
setsockopt(settings.sv_socket, SOL_SOCKET, SO_REUSEADDR | SO_REUSEPORT, &(opt), sizeof(opt));
if (bind(settings.sv_socket, (struct sockaddr *)&(sv_addr), sv_addr_sz) < 0 || listen(settings.sv_socket, backlog) < 0) {
fputs(
"failed to bind sv_socket! is the port already use? is the "
"internet protocol enabled?\n",
stderr
);
fputs("failed to bind sv_socket! is the port already use? is the "
"internet protocol enabled?\n",
stderr);
goto main__clean_up;
}
@ -402,15 +395,15 @@ main__arg_fuck:;
goto main__clean_up;
}
struct pollfd pollfds[2] = {
{
.fd = sig_fd,
.events = POLLIN,
},
{
.fd = input_fd,
.events = POLLIN,
.revents = 0,
},
{
.fd = sig_fd,
.events = POLLIN,
},
{
.fd = input_fd,
.events = POLLIN,
.revents = 0,
},
};
// serve
@ -489,4 +482,4 @@ main__clean_up:;
CRYPTO_cleanup_all_ex_data();
return 0;
}
#endif
#endif

@ -80,9 +80,9 @@ void general_service__service_info_destructor(void *hint) {
static bool handle_s(struct locked_hashmap *name_descriptions, struct bdd_internal_service *service, char *scope, char *addr, char *port, bool use_tls) {
struct general_service__info *info = malloc(sizeof(struct general_service__info));
struct addrinfo hints = {
0,
.ai_family = AF_UNSPEC,
.ai_socktype = SOCK_STREAM,
0,
.ai_family = AF_UNSPEC,
.ai_socktype = SOCK_STREAM,
};
struct addrinfo *res = NULL;
if (info == NULL) {