Do not wake up until necessary
authorYong Wang <yong.y.wang@intel.com>
Mon, 25 Mar 2013 08:17:51 +0000 (16:17 +0800)
committerYong Wang <yong.y.wang@intel.com>
Mon, 25 Mar 2013 08:17:51 +0000 (16:17 +0800)
wrt-security-daemon currently wakes up ten times per seconds for no good
reason. This will prevent CPU from staying in low power state and thus
consume more power. This patch will let wrt-security-daemon wake up only
until necessary.

Signed-off-by: Yong Wang <yong.y.wang@intel.com>
src/daemon/sockets/security_socket_service.cpp

index 2b4615f..6795a7f 100644 (file)
@@ -37,8 +37,6 @@
 #include "security_daemon_socket_config.h"
 #include "security_socket_service.h"
 
-#define TIMEOUT_SEC 0
-#define TIMEOUT_NSEC 100000000
 #define MAX_LISTEN 5
 #define SIGNAL_TO_CLOSE SIGUSR1
 
@@ -216,7 +214,6 @@ void SecuritySocketService::mainLoop(){
     FD_ZERO(&allset);
     FD_SET(m_listenFd, &allset);
     FD_SET(signal_fd, &allset);
-    timespec timeout;
     maxfd = (m_listenFd > signal_fd) ? (m_listenFd) : (signal_fd);
     ++maxfd;
     //this will block SIGPIPE for this thread and every thread created in it
@@ -228,10 +225,8 @@ void SecuritySocketService::mainLoop(){
     pthread_sigmask(SIG_BLOCK, &set, NULL);
 
     while(1){
-        timeout.tv_sec = TIMEOUT_SEC;
-        timeout.tv_nsec = TIMEOUT_NSEC;
         rset = allset;
-        if(-1 == pselect(maxfd, &rset, NULL, NULL, &timeout, NULL)){
+        if(-1 == pselect(maxfd, &rset, NULL, NULL, NULL, NULL)){
             closeConnections();
             throwWithErrnoMessage("pselect()");
         }