#include "settings/AdvancedSettings.h"
#include "settings/Settings.h"
#include "File.h"
+#include "threads/SystemClock.h"
#include <vector>
#include <climits>
#define XMIN(a,b) ((a)<(b)?(a):(b))
#define FITS_INT(a) (((a) <= INT_MAX) && ((a) >= INT_MIN))
-#define dllselect select
-
-
curl_proxytype proxyType2CUrlProxyType[] = {
CURLPROXY_HTTP,
CURLPROXY_SOCKS4,
if (CURLM_OK != g_curlInterface.multi_timeout(m_multiHandle, &timeout) || timeout == -1)
timeout = 200;
- struct timeval t = { timeout / 1000, (timeout % 1000) * 1000 };
+ XbmcThreads::EndTime endTime(timeout);
+ int rc;
- /* Wait until data is available or a timeout occurs.
- We call dllselect(maxfd + 1, ...), specially in case of (maxfd == -1),
- we call dllselect(0, ...), which is basically equal to sleep. */
- if (SOCKET_ERROR == dllselect(maxfd + 1, &fdread, &fdwrite, &fdexcep, &t))
+ do
{
- CLog::Log(LOGERROR, "CCurlFile::FillBuffer - Failed with socket error");
+ unsigned int time_left = endTime.MillisLeft();
+ struct timeval t = { time_left / 1000, (time_left % 1000) * 1000 };
+
+ // Wait until data is available or a timeout occurs.
+ rc = select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &t);
+#ifdef TARGET_WINDOWS
+ } while(rc == SOCKET_ERROR && WSAGetLastError() == WSAEINTR);
+#else
+ } while(rc == SOCKET_ERROR && errno == EINTR);
+#endif
+
+ if(rc == SOCKET_ERROR)
+ {
+#ifdef TARGET_WINDOWS
+ char buf[256];
+ strerror_s(buf, 256, WSAGetLastError());
+ CLog::Log(LOGERROR, "CCurlFile::FillBuffer - Failed with socket error:%s", buf);
+#else
+ char const * str = strerror(errno);
+ CLog::Log(LOGERROR, "CCurlFile::FillBuffer - Failed with socket error:%s", str);
+#endif
+
return false;
}
}