trinity-devel@lists.pearsoncomputing.net

Message: previous - next
Month: January 2013

Re: [trinity-devel] kdm_greet using lots and lots of CPU

From: russell@... (Russell Brown)
Date: Fri, 25 Jan 2013 12:13:24 +0000 (GMT)
Quoth Calvin Morrison.....
>You can send patches to the mailing list. Send a patch as an
>attachment using git diff

Tis attached.

-- 
 Regards,
     Russell
 --------------------------------------------------------------------
| Russell Brown          | MAIL: russell@... PHONE: 01780 471800 |
| Lady Lodge Systems     | WWW Work: http://www.lls.com              |
| Peterborough, England  | WWW Play: http://www.ruffle.me.uk         |
 --------------------------------------------------------------------
diff --git a/tdm/config.def b/tdm/config.def
index b1045b6..aecb6aa 100644
--- a/tdm/config.def
+++ b/tdm/config.def
@@ -2016,6 +2016,17 @@ Comment:
 Description:
  If true then the SAK anti-spoofing dialog will be utilized
 
+Key: UseKDMCTL
+Type: bool
+Default: true
+User: greeter
+Instance: #*/!
+Comment:
+  Turn this off if you are happy not using kdmctl and want to reduce the CPU load of
+  idle kdm_greeter processes.
+Description:
+  If true then the KDMCTL FIFO is monitored.
+
 Key: UseAdminSession
 Type: bool
 Default: false
diff --git a/tdm/kfrontend/kgapp.cpp b/tdm/kfrontend/kgapp.cpp
index d6fc4fc..ff474f0 100644
--- a/tdm/kfrontend/kgapp.cpp
+++ b/tdm/kfrontend/kgapp.cpp
@@ -71,6 +71,7 @@ bool argb_visual_available = false;
 bool has_twin = false;
 bool is_themed = false;
 bool trinity_desktop_lock_use_sak = TRUE;
+bool trinity_tdm_use_kdmctl = TRUE;
 TQPoint primaryScreenPosition;
 
 static int
@@ -208,6 +209,8 @@ kg_main( const char *argv0 )
 	TDEProcess *dcop = 0;
 	TDEProcess *twin = 0;
 
+	trinity_tdm_use_kdmctl = _useKDMCTL;
+
 #ifdef BUILD_TSAK
 	trinity_desktop_lock_use_sak = _useSAK;
 #else
diff --git a/tdm/kfrontend/kgreeter.cpp b/tdm/kfrontend/kgreeter.cpp
index 77b827f..9d2a31c 100644
--- a/tdm/kfrontend/kgreeter.cpp
+++ b/tdm/kfrontend/kgreeter.cpp
@@ -92,6 +92,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 #define FIFO_FILE "/tmp/tdesocket-global/tdm/tdmctl-%1"
 #define FIFO_SAK_FILE "/tmp/tdesocket-global/tdm/tdmctl-sak-%1"
 
+extern bool trinity_tdm_use_kdmctl;
+
 class UserListView : public KListView {
   public:
         UserListView( bool _them, TQWidget *parent = 0, const char *name = 0 )
@@ -229,6 +231,13 @@ void KGreeter::done(int r) {
 }
 
 void KGreeter::handleInputPipe(void) {
+
+	/*
+	*       This stops kdm_greet eating CPU monitoring the kdmctl FIFO.
+	*	 Enabled/disabled with UseKDMCTL in kdmrc
+	*/
+	if( !trinity_tdm_use_kdmctl ) return;
+
 	if (closingDown) {
 		::unlink(mPipeFilename.ascii());
 		return;
@@ -278,14 +287,14 @@ void KGreeter::handleInputPipe(void) {
 	int numread;
 	TQString inputcommand = "";
 	while ((!inputcommand.contains('\n')) && (!closingDown)) {
-		numread = ::read(mPipe_fd, readbuf, 2048);
-		readbuf[numread] = 0;
-		readbuf[2047] = 0;
-		inputcommand += readbuf;
+		if((numread = ::read(mPipe_fd, readbuf, 2048)) > 0 ) {
+		       readbuf[numread] = 0;
+		       readbuf[2047] = 0;
+		       inputcommand += readbuf;
+		}
 		if (!tqApp->hasPendingEvents()) {
 			usleep(500);
-		}
-		tqApp->processEvents();
+		} else tqApp->processEvents();
 	}
 	if (closingDown) {
 		::unlink(mPipeFilename.ascii());