]> git.sesse.net Git - cubemap/blobdiff - httpinput.cpp
When HTTPInput disconnects, also clear the header.
[cubemap] / httpinput.cpp
index 9d39774b70a18188fba21020421261ab56faafc5..1e607d4efc50ebbb9ed3936f4990e6b07d14c30c 100644 (file)
@@ -1,31 +1,26 @@
+#include <assert.h>
+#include <errno.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <poll.h>
+#include <stdint.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
-#include <stdint.h>
-#include <unistd.h>
-#include <assert.h>
-#include <arpa/inet.h>
-#include <sys/socket.h>
-#include <pthread.h>
-#include <sys/types.h>
 #include <sys/ioctl.h>
-#include <sys/types.h>
 #include <sys/socket.h>
-#include <netdb.h>
-#include <poll.h>
-#include <signal.h>
-#include <errno.h>
-#include <vector>
-#include <string>
+#include <unistd.h>
 #include <map>
+#include <string>
+#include <utility>
+#include <vector>
 
-#include "metacube.h"
-#include "mutexlock.h"
 #include "httpinput.h"
-#include "server.h"
-#include "serverpool.h"
+#include "metacube.h"
 #include "parse.h"
-#include "version.h"
+#include "serverpool.h"
 #include "state.pb.h"
+#include "version.h"
 
 using namespace std;
 
@@ -114,6 +109,15 @@ int HTTPInput::lookup_and_connect(const string &host, const string &port)
                        return sock;
                }
 
+               do {
+                       err = close(sock);
+               } while (err == -1 && errno == EINTR);
+
+               if (err == -1) {
+                       perror("close");
+                       // Can still continue.
+               }
+
                ai = ai->ai_next;
        }
 
@@ -229,6 +233,7 @@ void HTTPInput::do_work()
                        request_bytes_sent = 0;
                        response.clear();
                        pending_data.clear();
+                       servers->set_header(stream_id, "");
 
                        {
                                string protocol;  // Thrown away.