]> git.sesse.net Git - cubemap/blobdiff - input.cpp
Fix so clients would actually be woken up from the worker thread, not the input threa...
[cubemap] / input.cpp
index 541b5df6273bf7e59b0230acbcb1d936f679b977..de7252a3fda672682d15eb1fae2a821852e259f1 100644 (file)
--- a/input.cpp
+++ b/input.cpp
 #include "mutexlock.h"
 #include "input.h"
 #include "server.h"
+#include "serverpool.h"
 
 using namespace std;
 
-extern Server *servers;
+extern ServerPool *servers;
 
 Input::Input(const string &stream_id, const string &url)
        : stream_id(stream_id),
@@ -68,7 +69,7 @@ void Input::do_work()
                curl_easy_setopt(curl, CURLOPT_WRITEDATA, this);
                curl_easy_perform(curl);
                if (!should_stop) {
-                       printf("Transfer ended, waiting 0.2 seconds and restarting...\n");
+                       printf("Transfer of '%s' ended, waiting 0.2 seconds and restarting...\n", url.c_str());
                        usleep(200000);
                }
        }
@@ -146,13 +147,9 @@ void Input::process_block(const char *data, uint32_t size, uint32_t flags)
 {      
        if (flags & METACUBE_FLAGS_HEADER) {
                string header(data, data + size);
-               for (int i = 0; i < NUM_SERVERS; ++i) {
-                       servers[i].set_header(stream_id, header);
-               }
+               servers->set_header(stream_id, header);
        } else { 
-               for (int i = 0; i < NUM_SERVERS; ++i) {
-                       servers[i].add_data(stream_id, data, size);
-               }
+               servers->add_data(stream_id, data, size);
        }
 }