]> git.sesse.net Git - cubemap/blobdiff - httpinput.cpp
Do not segfault on unknown options.
[cubemap] / httpinput.cpp
index 8a3c371a7df88a618caa92227be4b77e50bf110c..72a8f3aaf021e3c96afe345c6c7635b506ebb251 100644 (file)
@@ -93,6 +93,8 @@ int HTTPInput::lookup_and_connect(const string &host, const string &port)
                return -1;
        }
 
+       addrinfo *base_ai = ai;
+
        // Connect to everything in turn until we have a socket.
        while (ai && !should_stop) {
                int sock = socket(ai->ai_family, SOCK_STREAM, IPPROTO_TCP);
@@ -106,7 +108,7 @@ int HTTPInput::lookup_and_connect(const string &host, const string &port)
                } while (err == -1 && errno == EINTR);
 
                if (err != -1) {
-                       freeaddrinfo(ai);
+                       freeaddrinfo(base_ai);
                        return sock;
                }
 
@@ -125,7 +127,7 @@ int HTTPInput::lookup_and_connect(const string &host, const string &port)
        // Give the last one as error.
        log(WARNING, "[%s] Connect to '%s' failed (%s)",
                stream_id.c_str(), host.c_str(), strerror(errno));
-       freeaddrinfo(ai);
+       freeaddrinfo(base_ai);
        return -1;
 }
        
@@ -332,6 +334,8 @@ void HTTPInput::do_work()
                                process_data(&extra_data[0], extra_data.size());
                        }
 
+                       log(INFO, "[%s] Connected to '%s', receiving data.",
+                                  stream_id.c_str(), url.c_str());
                        state = RECEIVING_DATA;
                        break;
                }