summary refs log tree commit diff
path: root/listen.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-10-25 16:27:24 -0400
committerJune McEnroe <june@causal.agency>2019-10-25 16:27:24 -0400
commitffbf1635f5be94eda4ee857d51a51a1564235f5d (patch)
treef1e5cfd2feee4af202a3d2c40c8d0e0014c9bc9b /listen.c
parentUse produce/consume words for ring buffer (diff)
downloadpounce-ffbf1635f5be94eda4ee857d51a51a1564235f5d.tar.gz
pounce-ffbf1635f5be94eda4ee857d51a51a1564235f5d.zip
Clean up listen API
Diffstat (limited to '')
-rw-r--r--listen.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/listen.c b/listen.c
index 1179a8b..d6e561f 100644
--- a/listen.c
+++ b/listen.c
@@ -27,6 +27,7 @@
 
 static struct tls *server;
 
+// TODO: Make this callable more than once to reload certificates?
 void listenConfig(const char *cert, const char *priv) {
 	struct tls_config *config = tls_config_new();
 	if (!config) errx(EX_SOFTWARE, "tls_config_new");
@@ -77,16 +78,16 @@ size_t listenBind(int fds[], size_t cap, const char *host, const char *port) {
 	return len;
 }
 
-int listenAccept(struct tls **client, int fd) {
-	int sock = accept(fd, NULL, NULL);
-	if (sock < 0) err(EX_IOERR, "accept");
+struct tls *listenAccept(int *fd, int bind) {
+	*fd = accept(bind, NULL, NULL);
+	if (*fd < 0) err(EX_IOERR, "accept");
 
 	int yes = 1;
-	int error = setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, &yes, sizeof(yes));
+	int error = setsockopt(*fd, SOL_SOCKET, SO_NOSIGPIPE, &yes, sizeof(yes));
 	if (error) err(EX_OSERR, "setsockopt");
 
-	error = tls_accept_socket(server, client, sock);
+	struct tls *client;
+	error = tls_accept_socket(server, &client, *fd);
 	if (error) errx(EX_SOFTWARE, "tls_accept_socket: %s", tls_error(server));
-
-	return sock;
+	return client;
 }
class='logheader'>2020-03-03Don't use $ inside $(())June McEnroe 2020-03-03Remove setoptJune McEnroe 2020-03-03Use getopts in shell scriptsJune McEnroe WTF why did no one tell me about this? 2020-02-27Style %T outside of Rs in italicJune McEnroe 2020-02-26Add Fierce Femmes and Notorious LiarsJune McEnroe 2020-02-23Add This Is How You Lose the Time WarJune McEnroe 2020-02-22Add See Ya LaterJune McEnroe 2020-02-20Remove wiki scriptJune McEnroe Wikipedia seems to have removed the one-sentence extracts from the opensearch results. Too bad. It's not a wiki script, what we need is a command that fetches single-sentence summaries of articles on Wikipedia. 2020-02-19Add The Obelisk GateJune McEnroe 2020-02-17Add Four Tet — HandsJune McEnroe One from the cafe that caught my attention. 2020-02-12Simplify macOS notify-sendJune McEnroe 2020-02-12Add imbox and notemap to pageJune McEnroe 2020-02-12Collapse simple linksJune McEnroe 2020-02-12Move catgirl up the pageJune McEnroe 2020-02-12Update catgirl pty grabJune McEnroe 2020-02-12Link to cgit /about pages where appropriateJune McEnroe 2020-02-11Separate LINKS from BINS for html to workJune McEnroe 2020-02-11Add margin to Bl-bullet itemsJune McEnroe 2020-02-10Match URLs inside parens or with paired parens insideJune McEnroe 2020-02-10Duplicate effective URL before passing it back to curlJune McEnroe Apparently sometimes it didn't like receiving its own internal storage to parse again. Understandable. 2020-02-09Add To Be Taught, If FortunateJune McEnroe 2020-02-04Add The Future of Another TimelineJune McEnroe Wow. One of the best I've read. 2020-01-31Reorganize the Makefile for the umpteenth timeJune McEnroe Broke out LDLIBS for each bin, and made everything more uniform. 2020-01-28Change scout sensitivity to 1.4June McEnroe idk it seems to work. 2020-01-28Import shows.txtJune McEnroe