Removed 5s timeout from streamAlive call.
This commit is contained in:
parent
6386060c10
commit
fa41e02047
8 changed files with 36 additions and 27 deletions
|
@ -95,13 +95,13 @@ namespace IPC {
|
|||
///\param oflag The flags with which to open the semaphore
|
||||
///\param mode The mode in which to create the semaphore, if O_CREAT is given in oflag, ignored otherwise
|
||||
///\param value The initial value of the semaphore if O_CREAT is given in oflag, ignored otherwise
|
||||
semaphore::semaphore(const char * name, int oflag, mode_t mode, unsigned int value) {
|
||||
semaphore::semaphore(const char * name, int oflag, mode_t mode, unsigned int value, bool noWait) {
|
||||
#if defined(__CYGWIN__) || defined(_WIN32)
|
||||
mySem = 0;
|
||||
#else
|
||||
mySem = SEM_FAILED;
|
||||
#endif
|
||||
open(name, oflag, mode, value);
|
||||
open(name, oflag, mode, value, noWait);
|
||||
}
|
||||
|
||||
///\brief The deconstructor
|
||||
|
@ -126,7 +126,7 @@ namespace IPC {
|
|||
///\param oflag The flags with which to open the semaphore
|
||||
///\param mode The mode in which to create the semaphore, if O_CREAT is given in oflag, ignored otherwise
|
||||
///\param value The initial value of the semaphore if O_CREAT is given in oflag, ignored otherwise
|
||||
void semaphore::open(const char * name, int oflag, mode_t mode, unsigned int value) {
|
||||
void semaphore::open(const char * name, int oflag, mode_t mode, unsigned int value, bool noWait) {
|
||||
close();
|
||||
int timer = 0;
|
||||
while (!(*this) && timer++ < 10) {
|
||||
|
@ -165,7 +165,7 @@ namespace IPC {
|
|||
mySem = sem_open(name, oflag);
|
||||
}
|
||||
if (!(*this)) {
|
||||
if (errno == ENOENT) {
|
||||
if (errno == ENOENT && !noWait) {
|
||||
Util::wait(500);
|
||||
} else {
|
||||
break;
|
||||
|
|
|
@ -60,10 +60,10 @@ namespace IPC {
|
|||
class semaphore {
|
||||
public:
|
||||
semaphore();
|
||||
semaphore(const char * name, int oflag, mode_t mode = 0, unsigned int value = 0);
|
||||
semaphore(const char * name, int oflag, mode_t mode = 0, unsigned int value = 0, bool noWait = false);
|
||||
~semaphore();
|
||||
operator bool() const;
|
||||
void open(const char * name, int oflag, mode_t mode = 0, unsigned int value = 0);
|
||||
void open(const char * name, int oflag, mode_t mode = 0, unsigned int value = 0, bool noWait = false);
|
||||
int getVal() const;
|
||||
void post();
|
||||
void wait();
|
||||
|
|
|
@ -109,7 +109,7 @@ JSON::Value Util::getStreamConfig(std::string streamname){
|
|||
bool Util::streamAlive(std::string & streamname){
|
||||
char semName[NAME_BUFFER_SIZE];
|
||||
snprintf(semName, NAME_BUFFER_SIZE, SEM_INPUT, streamname.c_str());
|
||||
IPC::semaphore playerLock(semName, O_RDWR, ACCESSPERMS, 1);
|
||||
IPC::semaphore playerLock(semName, O_RDWR, ACCESSPERMS, 1, true);
|
||||
if (!playerLock){return false;}
|
||||
if (!playerLock.tryWait()) {
|
||||
playerLock.close();
|
||||
|
@ -310,7 +310,13 @@ bool Util::startInput(std::string streamname, std::string filename, bool forkFir
|
|||
FAIL_MSG("Starting process %s for stream %s failed: %s", argv[0], streamname.c_str(), strerror(errno));
|
||||
_exit(42);
|
||||
}
|
||||
return true;
|
||||
|
||||
unsigned int waiting = 0;
|
||||
while (!streamAlive(streamname) && ++waiting < 40){
|
||||
Util::sleep(250);
|
||||
}
|
||||
|
||||
return streamAlive(streamname);
|
||||
}
|
||||
|
||||
/* roxlu-begin */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue