From e80177752184bab0ec4290d1b04da9019690273f Mon Sep 17 00:00:00 2001
From: "Rafael G. Martins" <rafael@rafaelmartins.eng.br>
Date: Sun, 5 Mar 2017 01:54:54 +0100
Subject: runserver: move var declarations to loop

---
 src/blogc-runserver/httpd.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

(limited to 'src')

diff --git a/src/blogc-runserver/httpd.c b/src/blogc-runserver/httpd.c
index e4eb986..847f8f9 100644
--- a/src/blogc-runserver/httpd.c
+++ b/src/blogc-runserver/httpd.c
@@ -318,22 +318,22 @@ br_httpd_run(const char *host, const char *port, const char *docroot,
 
     size_t current_thread = 0;
 
-    struct sockaddr_in6 addr6;
-    struct sockaddr_in addr;
+    while (1) {
+        struct sockaddr_in6 addr6;
+        struct sockaddr_in addr;
 
-    socklen_t addrlen;
-    struct sockaddr *client_addr = NULL;
+        socklen_t addrlen;
+        struct sockaddr *client_addr = NULL;
 
-    if (f->ai_family == AF_INET6) {
-        addrlen = sizeof(addr6);
-        client_addr = (struct sockaddr*) &addr6;
-    }
-    else {
-        addrlen = sizeof(addr);
-        client_addr = (struct sockaddr*) &addr;
-    }
+        if (f->ai_family == AF_INET6) {
+            addrlen = sizeof(addr6);
+            client_addr = (struct sockaddr*) &addr6;
+        }
+        else {
+            addrlen = sizeof(addr);
+            client_addr = (struct sockaddr*) &addr;
+        }
 
-    while (1) {
         int client_socket = accept(server_socket, client_addr, &addrlen);
         if (client_socket == -1) {
             fprintf(stderr, "Failed to accept connection: %s\n", strerror(errno));
-- 
cgit v1.2.3-18-g5258