summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-11-14 11:47:26 -0500
committerJune McEnroe <june@causal.agency>2020-11-14 11:47:26 -0500
commit70c3c9156a64c9053978e499328a121757628ed2 (patch)
tree978a97afca4539be291cd6aec5e8df20e5f44e6b
parentOnly send shutdown QUIT and ERROR to registered clients (diff)
downloadpounce-70c3c9156a64c9053978e499328a121757628ed2.tar.gz
pounce-70c3c9156a64c9053978e499328a121757628ed2.zip
Swap localAccept parameter order
-rw-r--r--bounce.c6
-rw-r--r--bounce.h2
-rw-r--r--local.c22
3 files changed, 15 insertions, 15 deletions
diff --git a/bounce.c b/bounce.c
index f460d74..b0cdca2 100644
--- a/bounce.c
+++ b/bounce.c
@@ -480,9 +480,9 @@ int main(int argc, char *argv[]) {
 			}
 
 			if (!event.clients[i]) {
-				int fd;
-				struct tls *tls = localAccept(&fd, event.fds[i].fd);
-				if (!tls) {
+				struct tls *tls;
+				int fd = localAccept(&tls, event.fds[i].fd);
+				if (fd < 0) {
 					warn("accept");
 					continue;
 				}
diff --git a/bounce.h b/bounce.h
index a6ad31f..77e0164 100644
--- a/bounce.h
+++ b/bounce.h
@@ -171,7 +171,7 @@ void ringLoad(FILE *file);
 void localConfig(FILE *cert, FILE *priv, FILE *ca, bool require);
 size_t localBind(int fds[], size_t cap, const char *host, const char *port);
 size_t localUnix(int fds[], size_t cap, const char *path);
-struct tls *localAccept(int *fd, int bind);
+int localAccept(struct tls **tls, int bind);
 
 extern struct timeval serverQueueInterval;
 void serverConfig(bool insecure, const char *cert, const char *priv);
diff --git a/local.c b/local.c
index a697e15..21e7cb1 100644
--- a/local.c
+++ b/local.c
@@ -221,29 +221,29 @@ static int recvfd(int sock) {
 	return *(int *)CMSG_DATA(cmsg);
 }
 
-struct tls *localAccept(int *fd, int bind) {
-	*fd = accept(bind, NULL, NULL);
-	if (*fd < 0) return NULL;
+int localAccept(struct tls **client, int bind) {
+	int fd = accept(bind, NULL, NULL);
+	if (fd < 0) return fd;
 
 	if (unix) {
-		int sent = recvfd(*fd);
+		int sent = recvfd(fd);
 		if (sent < 0) err(EX_IOERR, "recvfd");
-		close(*fd);
-		*fd = sent;
+		close(fd);
+		fd = sent;
 	}
 
 	int on = 1;
-	int error = setsockopt(*fd, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on));
+	int error = setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on));
 	if (error) err(EX_OSERR, "setsockopt");
 
 #ifdef TCP_KEEPIDLE
 	int idle = 15 * 60;
-	error = setsockopt(*fd, IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(idle));
+	error = setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(idle));
 	if (error) err(EX_OSERR, "setsockopt");
 #endif
 
-	struct tls *client;
-	error = tls_accept_socket(server, &client, *fd);
+	error = tls_accept_socket(server, client, fd);
 	if (error) errx(EX_SOFTWARE, "tls_accept_socket: %s", tls_error(server));
-	return client;
+
+	return fd;
 }