diff options
author | Pär Björklund <per.bjorklund@gmail.com> | 2015-03-29 15:10:27 +0200 |
---|---|---|
committer | Pär Björklund <per.bjorklund@gmail.com> | 2015-03-29 15:10:27 +0200 |
commit | 01e00046ac087eb7cf1cc72baa32d88819dc726c (patch) | |
tree | 8a69f9115c04d8c4b17043d047ffe1c62794aa58 | |
parent | 2c6d5a8f31afc01d3b682c83be9cee7c9c5a16ea (diff) | |
parent | 6c8d1ea0ce3f07928296691c0cc29fdc86a2b7b3 (diff) |
Merge pull request #6824 from Paxxi/silence_irss
[Remote]Only log first connection attempt to avoid spamming the logs
-rw-r--r-- | xbmc/input/linux/LIRC.cpp | 34 | ||||
-rw-r--r-- | xbmc/input/linux/LIRC.h | 2 | ||||
-rw-r--r-- | xbmc/input/windows/IRServerSuite.cpp | 30 | ||||
-rw-r--r-- | xbmc/input/windows/IRServerSuite.h | 4 |
4 files changed, 38 insertions, 32 deletions
diff --git a/xbmc/input/linux/LIRC.cpp b/xbmc/input/linux/LIRC.cpp index 944436d3f4..f0693f0f3b 100644 --- a/xbmc/input/linux/LIRC.cpp +++ b/xbmc/input/linux/LIRC.cpp @@ -37,20 +37,20 @@ #include "settings/AdvancedSettings.h" #include "utils/TimeUtils.h" -CRemoteControl::CRemoteControl() : - CThread("RemoteControl"), - m_deviceName(LIRC_DEVICE) +CRemoteControl::CRemoteControl() + : CThread("RemoteControl") + , m_fd(-1) + , m_inotify_fd(-1) + , m_inotify_wd(-1) + , m_file(nullptr) + , m_holdTime(0) + , m_button(0) + , m_bInitialized(false) + , m_used(true) + , m_deviceName(LIRC_DEVICE) + , m_inReply(false) + , m_nrSending(0) { - m_fd = -1; - m_file = NULL; - m_bInitialized = false; - m_button = 0; - m_holdTime = 0; - m_used = true; - m_inotify_fd = -1; - m_inotify_wd = -1; - m_inReply = false; - m_nrSending = 0; } CRemoteControl::~CRemoteControl() @@ -133,7 +133,7 @@ void CRemoteControl::Process() // multiple tries because LIRC service might be up and running a little later then xbmc on boot. while (!m_bStop && iAttempt <= 60) { - if (Connect(addr)) + if (Connect(addr, iAttempt == 0)) break; if (iAttempt == 0) @@ -290,7 +290,7 @@ void CRemoteControl::AddSendCommand(const std::string& command) m_sendData += '\n'; } -bool CRemoteControl::Connect(struct sockaddr_un addr) +bool CRemoteControl::Connect(struct sockaddr_un addr, bool logMessages) { // Open the socket from which we will receive the remote commands if ((m_fd = socket(AF_UNIX, SOCK_STREAM, 0)) != -1) @@ -342,10 +342,10 @@ bool CRemoteControl::Connect(struct sockaddr_un addr) else CLog::Log(LOGERROR, "LIRC %s: fcntl(F_GETFL) failed: %s", __FUNCTION__, strerror(errno)); } - else + else if (logMessages) CLog::Log(LOGINFO, "LIRC %s: connect failed: %s", __FUNCTION__, strerror(errno)); } - else + else if (logMessages) CLog::Log(LOGINFO, "LIRC %s: socket failed: %s", __FUNCTION__, strerror(errno)); return m_bInitialized; diff --git a/xbmc/input/linux/LIRC.h b/xbmc/input/linux/LIRC.h index f8e1fb2a3b..2e8bdc5512 100644 --- a/xbmc/input/linux/LIRC.h +++ b/xbmc/input/linux/LIRC.h @@ -50,7 +50,7 @@ public: protected: virtual void Process(); - bool Connect(struct sockaddr_un addr); + bool Connect(struct sockaddr_un addr, bool logMessages); private: int m_fd; diff --git a/xbmc/input/windows/IRServerSuite.cpp b/xbmc/input/windows/IRServerSuite.cpp index 281268d6ac..80477340fe 100644 --- a/xbmc/input/windows/IRServerSuite.cpp +++ b/xbmc/input/windows/IRServerSuite.cpp @@ -26,12 +26,13 @@ #define IRSS_PORT 24000 -CRemoteControl::CRemoteControl() : CThread("RemoteControl") +CRemoteControl::CRemoteControl() + : CThread("RemoteControl") + , m_button(0) + , m_bInitialized(false) + , m_socket(INVALID_SOCKET) + , m_isConnecting(false) { - m_socket = INVALID_SOCKET; - m_bInitialized = false; - m_isConnecting = false; - Reset(); } CRemoteControl::~CRemoteControl() @@ -85,7 +86,7 @@ void CRemoteControl::Process() // multiple tries because irss service might be up and running a little later then xbmc on boot. while (!m_bStop && iAttempt <= 60) { - if (Connect()) + if (Connect(iAttempt == 0)) break; if(iAttempt == 0) @@ -98,7 +99,7 @@ void CRemoteControl::Process() } } -bool CRemoteControl::Connect() +bool CRemoteControl::Connect(bool logMessages) { char namebuf[NI_MAXHOST], portbuf[NI_MAXSERV]; struct addrinfo hints = {}; @@ -114,7 +115,8 @@ bool CRemoteControl::Connect() res = getaddrinfo("localhost", service, &hints, &result); if(res) { - CLog::Log(LOGDEBUG, "CRemoteControl::Connect - getaddrinfo failed: %s", gai_strerror(res)); + if (logMessages) + CLog::Log(LOGDEBUG, "CRemoteControl::Connect - getaddrinfo failed: %s", gai_strerror(res)); return false; } @@ -126,7 +128,8 @@ bool CRemoteControl::Connect() strcpy(portbuf, "[unknown]"); } - CLog::Log(LOGDEBUG, "CRemoteControl::Connect - connecting to: %s:%s ...", namebuf, portbuf); + if (logMessages) + CLog::Log(LOGDEBUG, "CRemoteControl::Connect - connecting to: %s:%s ...", namebuf, portbuf); m_socket = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol); if(m_socket == INVALID_SOCKET) @@ -142,7 +145,8 @@ bool CRemoteControl::Connect() freeaddrinfo(result); if(m_socket == INVALID_SOCKET) { - CLog::Log(LOGDEBUG, "CRemoteControl::Connect - failed to connect"); + if (logMessages) + CLog::Log(LOGDEBUG, "CRemoteControl::Connect - failed to connect"); Close(); return false; } @@ -150,7 +154,8 @@ bool CRemoteControl::Connect() u_long iMode = 1; //non-blocking if (ioctlsocket(m_socket, FIONBIO, &iMode) == SOCKET_ERROR) { - CLog::Log(LOGERROR, "IRServerSuite: failed to set socket to non-blocking."); + if (logMessages) + CLog::Log(LOGERROR, "IRServerSuite: failed to set socket to non-blocking."); Close(); return false; } @@ -159,7 +164,8 @@ bool CRemoteControl::Connect() CIrssMessage mess(IRSSMT_RegisterClient, IRSSMF_Request); if (!SendPacket(mess)) { - CLog::Log(LOGERROR, "IRServerSuite: failed to send RegisterClient packet."); + if (logMessages) + CLog::Log(LOGERROR, "IRServerSuite: failed to send RegisterClient packet."); return false; } m_isConnecting = true; diff --git a/xbmc/input/windows/IRServerSuite.h b/xbmc/input/windows/IRServerSuite.h index dcadc6d4a9..e5f2dc1b30 100644 --- a/xbmc/input/windows/IRServerSuite.h +++ b/xbmc/input/windows/IRServerSuite.h @@ -43,7 +43,7 @@ public: bool IsInUse() {return false;} void SetEnabled(bool) { } void SetDeviceName(const std::string&) { } - void AddSendCommand(const std::string& command) {} + void AddSendCommand(const std::string&) {} protected: virtual void Process(); @@ -61,7 +61,7 @@ private: bool ReadPacket(CIrssMessage& message); int ReadN(char *buffer, int n); bool WriteN(const char *buffer, int n); - bool Connect(); + bool Connect(bool logMessages); void Close(); bool HandleRemoteEvent(CIrssMessage& message); |