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

View File

@ -55,8 +55,9 @@ bool cIptvProtocolHttp::Connect(void)
"Connection: Close\r\n" "Connection: Close\r\n"
"\r\n", streamPathM, streamAddrM, "\r\n", streamPathM, streamAddrM,
PLUGIN_NAME_I18N, VERSION); PLUGIN_NAME_I18N, VERSION);
debug("cIptvProtocolHttp::%s(): requesting: %s", __FUNCTION__, *buffer); unsigned int len = strlen(*buffer);
if (!Write(*buffer, (unsigned int)strlen(*buffer))) { debug("cIptvProtocolHttp::%s(): requesting %d: %s", __FUNCTION__, len, *buffer);
if (!Write(*buffer, len)) {
CloseSocket(); CloseSocket();
return false; 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)", ERROR_IF_FUNC(fcntl(socketDescM, F_SETFL, O_NONBLOCK), "fcntl(O_NONBLOCK)",
CloseSocket(), return false); CloseSocket(), return false);
// Allow multiple sockets to use the same PORT number // 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)", ERROR_IF_FUNC(setsockopt(socketDescM, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0,
CloseSocket(), return false); "setsockopt(SO_REUSEADDR)", CloseSocket(), return false);
#ifndef __FreeBSD__ #ifndef __FreeBSD__
// Allow packet information to be fetched // Allow packet information to be fetched
ERROR_IF_FUNC(setsockopt(socketDescM, SOL_IP, IP_PKTINFO, &yes, sizeof(yes)) < 0, "setsockopt(IP_PKTINFO)", ERROR_IF_FUNC(setsockopt(socketDescM, SOL_IP, IP_PKTINFO, &yes, sizeof(yes)) < 0,
CloseSocket(), return false); "setsockopt(IP_PKTINFO)", CloseSocket(), return false);
#endif // __FreeBSD__ #endif // __FreeBSD__
// Bind socket // Bind socket
memset(&sockAddrM, 0, sizeof(sockAddrM)); 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_port = htons((uint16_t)(portP & 0xFFFF));
sockAddrM.sin_addr.s_addr = htonl(INADDR_ANY); sockAddrM.sin_addr.s_addr = htonl(INADDR_ANY);
if (isUdpP) 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 // Update socket port
socketPortM = portP; socketPortM = portP;
} }
@ -99,7 +100,8 @@ bool cIptvSocket::CheckAddress(const char *addrP, in_addr_t *inAddrP)
struct hostent *host = gethostbyname(addrP); struct hostent *host = gethostbyname(addrP);
if (!host) { if (!host) {
char tmp[64]; 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; return false;
} }
*inAddrP = htonl(inet_addr(*host->h_addr_list)); *inAddrP = htonl(inet_addr(*host->h_addr_list));