Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stat() call #9

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions device.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ cIptvDevice::cIptvDevice(unsigned int indexP)
// Check if dvr fifo exists
struct stat sb;
cString filename = cString::sprintf(IPTV_DVR_FILENAME, deviceIndexM);
stat(filename, &sb);
if (S_ISFIFO(sb.st_mode)) {
dvrFdM = open(filename, O_RDWR | O_NONBLOCK);
if (dvrFdM >= 0)
info("IPTV device %d redirecting input stream to '%s'", deviceIndexM, *filename);
if(stat(filename, &sb) == 0) {
if (S_ISFIFO(sb.st_mode)) {
dvrFdM = open(filename, O_RDWR | O_NONBLOCK);
if (dvrFdM >= 0)
info("IPTV device %d redirecting input stream to '%s'", deviceIndexM, *filename);
}
}
}

cIptvDevice::~cIptvDevice()
Expand Down
18 changes: 9 additions & 9 deletions iptv.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,22 @@ bool cPluginIptv::ProcessArgs(int argc, char *argv[])
debug1("%s", __PRETTY_FUNCTION__);
// Implement command line argument processing here if applicable.
static const struct option long_options[] = {
{ "devices", required_argument, NULL, 'd' },
{ "trace", required_argument, NULL, 't' },
{ NULL, no_argument, NULL, 0 }
{ "devices", required_argument, NULL, 'd' },
{ "trace", required_argument, NULL, 't' },
{ NULL, no_argument, NULL, 0 }
};

int c;
while ((c = getopt_long(argc, argv, "d:", long_options, NULL)) != -1) {
while ((c = getopt_long(argc, argv, "d:t:", long_options, NULL)) != -1) {
switch (c) {
case 'd':
deviceCountM = atoi(optarg);
break;
deviceCountM = atoi(optarg);
break;
case 't':
IptvConfig.SetTraceMode(strtol(optarg, NULL, 0));
break;
IptvConfig.SetTraceMode(atoi(optarg));
break;
default:
return false;
return false;
}
}
return true;
Expand Down
5 changes: 3 additions & 2 deletions protocolcurl.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,10 @@ bool cIptvProtocolCurl::Connect()
return true;

// Initialize the curl session
if (!handleM)
if (!handleM) {
handleM = curl_easy_init();
connectedM = true;
}

if (handleM && !isempty(*streamUrlM)) {
CURLcode res = CURLE_OK;
Expand Down Expand Up @@ -428,7 +430,6 @@ bool cIptvProtocolCurl::Connect()
}

timeoutM.Set(eKeepAliveIntervalMs);
connectedM = true;
return true;
}

Expand Down
30 changes: 20 additions & 10 deletions socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,14 @@ 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,
{
int rcvbuf = 4 * 1024 * 1024;

ERROR_IF_FUNC(bind(socketDescM, (struct sockaddr *)&sockAddrM, sizeof(sockAddrM)) < 0,
"bind()", CloseSocket(), return false);

ERROR_IF_RET(setsockopt(socketDescM, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(int)) < 0, "setsockopt(SO_RCVBUF)", return false);
}
// Update socket port
socketPortM = portP;
}
Expand Down Expand Up @@ -184,11 +190,13 @@ bool cIptvUdpSocket::JoinMulticast(void)
ERROR_IF_RET(setsockopt(socketDescM, SOL_IP, MCAST_JOIN_SOURCE_GROUP, &gsr, sizeof(gsr)) < 0, "setsockopt(MCAST_JOIN_SOURCE_GROUP)", return false);
}
else {
struct ip_mreq mreq;
mreq.imr_multiaddr.s_addr = streamAddrM;
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
ERROR_IF_RET(setsockopt(socketDescM, SOL_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0, "setsockopt(IP_ADD_MEMBERSHIP)", return false);
}
if (IN_MULTICAST(ntohl(streamAddrM))) {
struct ip_mreq mreq;
mreq.imr_multiaddr.s_addr = streamAddrM;
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
ERROR_IF_RET(setsockopt(socketDescM, SOL_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0, "setsockopt(IP_ADD_MEMBERSHIP)", return false);
}
}
// Update multicasting flag
isActiveM = true;
}
Expand Down Expand Up @@ -218,11 +226,13 @@ bool cIptvUdpSocket::DropMulticast(void)
ERROR_IF_RET(setsockopt(socketDescM, SOL_IP, MCAST_LEAVE_SOURCE_GROUP, &gsr, sizeof(gsr)) < 0, "setsockopt(MCAST_LEAVE_SOURCE_GROUP)", return false);
}
else {
struct ip_mreq mreq;
mreq.imr_multiaddr.s_addr = streamAddrM;
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
ERROR_IF_RET(setsockopt(socketDescM, SOL_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)) < 0, "setsockopt(IP_DROP_MEMBERSHIP)", return false);
if (IN_MULTICAST(ntohl(streamAddrM))) {
struct ip_mreq mreq;
mreq.imr_multiaddr.s_addr = streamAddrM;
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
ERROR_IF_RET(setsockopt(socketDescM, SOL_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)) < 0, "setsockopt(IP_DROP_MEMBERSHIP)", return false);
}
}
// Update multicasting flag
isActiveM = false;
}
Expand Down
1 change: 0 additions & 1 deletion statistics.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ void cIptvStreamerStatistics::AddStreamerStatistic(long bytesP)
// Buffer statistics class
cIptvBufferStatistics::cIptvBufferStatistics()
: dataBytesM(0),
freeSpaceM(0),
usedSpaceM(0),
timerM(),
mutexM()
Expand Down
1 change: 0 additions & 1 deletion statistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class cIptvBufferStatistics {

private:
long dataBytesM;
long freeSpaceM;
long usedSpaceM;
cTimeMs timerM;
cMutex mutexM;
Expand Down