Tweaked debug messages.
This commit is contained in:
parent
4de598054a
commit
bca6097ae4
3 changed files with 13 additions and 9 deletions
|
@ -12,7 +12,8 @@
|
||||||
#define DLVL_DONTEVEN 10 // All messages enabled, even pointless ones.
|
#define DLVL_DONTEVEN 10 // All messages enabled, even pointless ones.
|
||||||
#if DEBUG > 0
|
#if DEBUG > 0
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#define DEBUG_MSG(lvl, msg, ...) if (DEBUG >= lvl){fprintf(stderr, "[%s:%d] " msg "\n", __FILE__, __LINE__, ##__VA_ARGS__);}
|
#include <unistd.h>
|
||||||
|
#define DEBUG_MSG(lvl, msg, ...) if (DEBUG >= lvl){fprintf(stderr, "[%d][%s:%d] " msg "\n", getpid(), __FILE__, __LINE__, ##__VA_ARGS__);}
|
||||||
#else
|
#else
|
||||||
#define DEBUG_MSG(lvl, msg, ...) // Debugging disabled.
|
#define DEBUG_MSG(lvl, msg, ...) // Debugging disabled.
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -93,16 +93,16 @@ namespace IPC {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (handle == -1) {
|
if (handle == -1) {
|
||||||
perror(std::string("shm_open for page " + name + " failed").c_str());
|
DEBUG_MSG(DLVL_FAIL, "shm_open for page %s failed: %s", name.c_str(), strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (master){
|
if (master){
|
||||||
if (ftruncate(handle, 0) < 0) {
|
if (ftruncate(handle, 0) < 0) {
|
||||||
perror(std::string("ftruncate to zero for page " + name + " failed").c_str());
|
DEBUG_MSG(DLVL_FAIL, "truncate to zero for page %s failed: %s", name.c_str(), strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ftruncate(handle, len) < 0) {
|
if (ftruncate(handle, len) < 0) {
|
||||||
perror(std::string("ftruncate to len for page " + name + " failed").c_str());
|
DEBUG_MSG(DLVL_FAIL, "truncate to %lld for page %s failed: %s", len, name.c_str(), strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
@ -391,7 +391,7 @@ namespace IPC {
|
||||||
sharedPage tmp(std::string(baseName + (char)(myPages.size() + (int)'A')), (4096 << myPages.size()), true);
|
sharedPage tmp(std::string(baseName + (char)(myPages.size() + (int)'A')), (4096 << myPages.size()), true);
|
||||||
myPages.insert(tmp);
|
myPages.insert(tmp);
|
||||||
tmp.master = false;
|
tmp.master = false;
|
||||||
DEBUG_MSG(DLVL_WARN, "Added a new page: %s", tmp.name.c_str());
|
DEBUG_MSG(DLVL_MEDIUM, "Added a new page: %s", tmp.name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void sharedServer::deletePage() {
|
void sharedServer::deletePage() {
|
||||||
|
@ -452,7 +452,7 @@ namespace IPC {
|
||||||
//increase the count if needed
|
//increase the count if needed
|
||||||
if (id >= amount){
|
if (id >= amount){
|
||||||
amount = id+1;
|
amount = id+1;
|
||||||
DEBUG_MSG(DLVL_DEVEL, "Shared memory %s is now at count %u", baseName.c_str(), amount);
|
DEBUG_MSG(DLVL_VERYHIGH, "Shared memory %s is now at count %u", baseName.c_str(), amount);
|
||||||
}
|
}
|
||||||
callback(it->mapped + offset + 1, payLen, id);
|
callback(it->mapped + offset + 1, payLen, id);
|
||||||
switch (counter) {
|
switch (counter) {
|
||||||
|
@ -483,7 +483,7 @@ namespace IPC {
|
||||||
//bring the counter down if this was the last element
|
//bring the counter down if this was the last element
|
||||||
if (id == amount - 1){
|
if (id == amount - 1){
|
||||||
amount = id;
|
amount = id;
|
||||||
DEBUG_MSG(DLVL_DEVEL, "Shared memory %s is now at count %u", baseName.c_str(), amount);
|
DEBUG_MSG(DLVL_VERYHIGH, "Shared memory %s is now at count %u", baseName.c_str(), amount);
|
||||||
}
|
}
|
||||||
//stop, we're guaranteed no more pages are full at this point
|
//stop, we're guaranteed no more pages are full at this point
|
||||||
return;
|
return;
|
||||||
|
@ -494,7 +494,7 @@ namespace IPC {
|
||||||
//increase the count if needed
|
//increase the count if needed
|
||||||
if (id >= amount){
|
if (id >= amount){
|
||||||
amount = id+1;
|
amount = id+1;
|
||||||
DEBUG_MSG(DLVL_DEVEL, "Shared memory %s is now at count %u", baseName.c_str(), amount);
|
DEBUG_MSG(DLVL_VERYHIGH, "Shared memory %s is now at count %u", baseName.c_str(), amount);
|
||||||
}
|
}
|
||||||
callback(it->mapped + offset, payLen, id);
|
callback(it->mapped + offset, payLen, id);
|
||||||
}else{
|
}else{
|
||||||
|
@ -503,7 +503,7 @@ namespace IPC {
|
||||||
//bring the counter down if this was the last element
|
//bring the counter down if this was the last element
|
||||||
if (id == amount - 1){
|
if (id == amount - 1){
|
||||||
amount = id;
|
amount = id;
|
||||||
DEBUG_MSG(DLVL_DEVEL, "Shared memory %s is now at count %u", baseName.c_str(), amount);
|
DEBUG_MSG(DLVL_VERYHIGH, "Shared memory %s is now at count %u", baseName.c_str(), amount);
|
||||||
}
|
}
|
||||||
//stop, we're guaranteed no more pages are full at this point
|
//stop, we're guaranteed no more pages are full at this point
|
||||||
if (empty){
|
if (empty){
|
||||||
|
|
|
@ -122,13 +122,16 @@ bool Util::Stream::getStream(std::string streamname){
|
||||||
sem_t * playerLock = sem_open(std::string("/lock_" + streamname).c_str(), O_CREAT | O_RDWR, ACCESSPERMS, 1);
|
sem_t * playerLock = sem_open(std::string("/lock_" + streamname).c_str(), O_CREAT | O_RDWR, ACCESSPERMS, 1);
|
||||||
if (sem_trywait(playerLock) == -1){
|
if (sem_trywait(playerLock) == -1){
|
||||||
sem_close(playerLock);
|
sem_close(playerLock);
|
||||||
|
DEBUG_MSG(DLVL_MEDIUM, "Playerlock for %s already active - not re-activating stream", streamname.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
sem_post(playerLock);
|
sem_post(playerLock);
|
||||||
sem_close(playerLock);
|
sem_close(playerLock);
|
||||||
if (ServConf["streams"][streamname]["source"].asString()[0] == '/'){
|
if (ServConf["streams"][streamname]["source"].asString()[0] == '/'){
|
||||||
|
DEBUG_MSG(DLVL_MEDIUM, "Activating VoD stream %s", streamname.c_str());
|
||||||
return getVod(ServConf["streams"][streamname]["source"].asString(), streamname);
|
return getVod(ServConf["streams"][streamname]["source"].asString(), streamname);
|
||||||
}else{
|
}else{
|
||||||
|
DEBUG_MSG(DLVL_MEDIUM, "Activating live stream %s", streamname.c_str());
|
||||||
return getLive(streamname);
|
return getLive(streamname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue