1
0
mirror of https://github.com/rofafor/vdr-plugin-iptv.git synced 2023-10-10 13:37:03 +02:00

Reverted the CURL locking changes and updated some word wrapping.

This commit is contained in:
Rolf Ahrenberg 2013-03-01 12:22:41 +02:00
parent f632650547
commit d84fd79d14
3 changed files with 13 additions and 10 deletions

View File

@ -420,7 +420,6 @@ int cIptvProtocolCurl::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
int len = 0;
if (ringBufferM) {
// Fill up the buffer
mutexM.Lock();
if (handleM && multiM) {
switch (modeM) {
case eModeRtsp:
@ -444,12 +443,14 @@ int cIptvProtocolCurl::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
} while (res == CURLM_CALL_MULTI_PERFORM);
// Shall we continue filling up the buffer?
mutexM.Lock();
if (pausedM && (ringBufferM->Free() > ringBufferM->Available())) {
debug("cIptvProtocolCurl::%s(continue): free=%d available=%d", __FUNCTION__,
ringBufferM->Free(), ringBufferM->Available());
pausedM = false;
curl_easy_pause(handleM, CURLPAUSE_CONT);
}
mutexM.Unlock();
// Check if end of file
if (running_handles == 0) {
@ -470,7 +471,6 @@ int cIptvProtocolCurl::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
break;
}
}
mutexM.Unlock();
// ... and try to empty it
unsigned char *p = GetData(&bufferLenP);

View File

@ -55,8 +55,9 @@ bool cIptvProtocolHttp::Connect(void)
"Connection: Close\r\n"
"\r\n", streamPathM, streamAddrM,
PLUGIN_NAME_I18N, VERSION);
debug("cIptvProtocolHttp::%s(): requesting: %s", __FUNCTION__, *buffer);
if (!Write(*buffer, (unsigned int)strlen(*buffer))) {
unsigned int len = strlen(*buffer);
debug("cIptvProtocolHttp::%s(): requesting %d: %s", __FUNCTION__, len, *buffer);
if (!Write(*buffer, len)) {
CloseSocket();
return false;
}

View File

@ -56,12 +56,12 @@ bool cIptvSocket::OpenSocket(const int portP, const bool isUdpP)
ERROR_IF_FUNC(fcntl(socketDescM, F_SETFL, O_NONBLOCK), "fcntl(O_NONBLOCK)",
CloseSocket(), return false);
// Allow multiple sockets to use the same PORT number
ERROR_IF_FUNC(setsockopt(socketDescM, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0, "setsockopt(SO_REUSEADDR)",
CloseSocket(), return false);
ERROR_IF_FUNC(setsockopt(socketDescM, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0,
"setsockopt(SO_REUSEADDR)", CloseSocket(), return false);
#ifndef __FreeBSD__
// Allow packet information to be fetched
ERROR_IF_FUNC(setsockopt(socketDescM, SOL_IP, IP_PKTINFO, &yes, sizeof(yes)) < 0, "setsockopt(IP_PKTINFO)",
CloseSocket(), return false);
ERROR_IF_FUNC(setsockopt(socketDescM, SOL_IP, IP_PKTINFO, &yes, sizeof(yes)) < 0,
"setsockopt(IP_PKTINFO)", CloseSocket(), return false);
#endif // __FreeBSD__
// Bind socket
memset(&sockAddrM, 0, sizeof(sockAddrM));
@ -69,7 +69,8 @@ bool cIptvSocket::OpenSocket(const int portP, const bool isUdpP)
sockAddrM.sin_port = htons((uint16_t)(portP & 0xFFFF));
sockAddrM.sin_addr.s_addr = htonl(INADDR_ANY);
if (isUdpP)
ERROR_IF_FUNC(bind(socketDescM, (struct sockaddr *)&sockAddrM, sizeof(sockAddrM)) < 0, "bind()", CloseSocket(), return false);
ERROR_IF_FUNC(bind(socketDescM, (struct sockaddr *)&sockAddrM, sizeof(sockAddrM)) < 0,
"bind()", CloseSocket(), return false);
// Update socket port
socketPortM = portP;
}
@ -99,7 +100,8 @@ bool cIptvSocket::CheckAddress(const char *addrP, in_addr_t *inAddrP)
struct hostent *host = gethostbyname(addrP);
if (!host) {
char tmp[64];
error("gethostbyname() failed: %s is not valid address: %s", addrP, strerror_r(h_errno, tmp, sizeof(tmp)));
error("gethostbyname() failed: %s is not valid address: %s", addrP,
strerror_r(h_errno, tmp, sizeof(tmp)));
return false;
}
*inAddrP = htonl(inet_addr(*host->h_addr_list));