[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/workspace
From:       Oswald Buddenhagen <ossi () kde ! org>
Date:       2010-07-31 8:04:49
Message-ID: 20100731080449.52B83AC7A9 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1157486 by ossi:

revamp reserve session timeout handling

instead of hard-killing from within the subdaemon, couple it with the
user interaction in the greeter.
remove the configurability of the timeout from the socket command, as i
see no use case for that.

 M  +4 -5      doc/kdm/index.docbook  
 M  +2 -8      kdm/backend/ctrl.c  
 M  +0 -4      kdm/backend/dm.c  
 M  +1 -3      kdm/backend/dm.h  
 M  +1 -2      kdm/backend/dpylist.c  
 M  +0 -16     kdm/backend/session.c  
 M  +23 -0     kdm/kfrontend/kchooser.cpp  
 M  +7 -0      kdm/kfrontend/kchooser.h  
 M  +8 -0      kdm/kfrontend/kgverify.cpp  


--- trunk/KDE/kdebase/workspace/doc/kdm/index.docbook #1157485:1157486
@@ -1518,12 +1518,11 @@
 </varlistentry>
 
 <varlistentry>
-<term><command>reserve</command> [<parameter>timeout in
-seconds</parameter>]</term>
+<term><command>reserve</command></term>
 <listitem>
-<para>Start a reserve login screen. If nobody logs in within the specified
-amount of time (one minute by default), the display is removed again. When
-the session on the display exits, the display is removed, too.</para>
+<para>Start a reserve login screen. If nobody logs in within some
+time, the display is removed again. When the session on the display
+exits, the display is removed, too.</para>
 <para>Permitted only on sockets of local displays and the global
 socket.</para> 
 </listitem>
--- trunk/KDE/kdebase/workspace/kdm/backend/ctrl.c #1157485:1157486
@@ -537,13 +537,7 @@
             Reply("\n");
             goto bust;
         } else if (!strcmp(ar[0], "reserve")) {
-            int lt = 60; /* XXX make default timeout configurable? */
-            if (ar[1]) {
-                lt = strtol(ar[1], &bp, 10);
-                if (lt < 15 || *bp) {
-                    fLog(d, fd, "bad", "invalid timeout %\"s", ar[1]);
-                    goto bust;
-                }
+            if (ar[1]) { /* Formerly the timeout. Just ignore it. */
                 if (ar[2])
                     goto exce;
             }
@@ -551,7 +545,7 @@
                 fLog(d, fd, "perm", "display is not local");
                 goto bust;
             }
-            if (!startReserveDisplay(lt)) {
+            if (!startReserveDisplay()) {
                 fLog(d, fd, "noent", "no reserve display available");
                 goto bust;
             }
--- trunk/KDE/kdebase/workspace/kdm/backend/dm.c #1157485:1157486
@@ -1288,9 +1288,6 @@
 {
     if ((d->displayType & d_origin) == dFromFile && !d->stillThere)
         stopDisplay(d);
-    else if ((d->displayType & d_lifetime) == dReserve &&
-             d->status == running && d->userSess < 0 && !d->idleTimeout)
-        rStopDisplay(d, DS_RESERVE);
     else if (d->status == notRunning)
         if (loadDisplayResources(d) < 0) {
             logError("Unable to read configuration for display %s; "
@@ -1498,7 +1495,6 @@
 {
     debug("stopping display %s to state %d\n", d->name, endState);
     abortStartServer(d);
-    d->idleTimeout = 0;
     if (d->serverPid != -1 || d->pid != -1) {
         if (d->pid != -1)
             terminateProcess(d->pid, SIGTERM);
--- trunk/KDE/kdebase/workspace/kdm/backend/dm.h #1157485:1157486
@@ -285,8 +285,6 @@
 
     CONF_CORE_LOCAL_DEFS
 
-    int idleTimeout;            /* abort login after that time */
-
     /* information potentially derived from resources */
     Xauth **authorizations;     /* authorization data */
     int authNum;                /* number of authorizations */
@@ -418,7 +416,7 @@
 int anyRunningDisplays(void);
 int anyReserveDisplays(void);
 int idleReserveDisplays(void);
-int startReserveDisplay(int lt);
+int startReserveDisplay(void);
 const char *displayName(struct display *);
 
 /* in reset.c */
--- trunk/KDE/kdebase/workspace/kdm/backend/dpylist.c #1157485:1157486
@@ -87,7 +87,7 @@
 }
 
 int
-startReserveDisplay(int lt)
+startReserveDisplay(void)
 {
     struct display *d, *rd;
 
@@ -95,7 +95,6 @@
         if (d->status == reserve)
             rd = d;
     if (rd) {
-        rd->idleTimeout = lt;
         rd->status = notRunning;
         return True;
     }
--- trunk/KDE/kdebase/workspace/kdm/backend/session.c #1157485:1157486
@@ -502,16 +502,7 @@
     }
 }
 
-static Jmp_buf idleTOJmp;
 
-/* ARGSUSED */
-static void
-IdleTimeout(int n ATTR_UNUSED)
-{
-    Longjmp(idleTOJmp, 1);
-}
-
-
 static Jmp_buf abortSession;
 
 /* ARGSUSED */
@@ -594,12 +585,6 @@
     } else {
       regreet:
         openGreeter();
-        if (Setjmp(idleTOJmp)) {
-            closeGreeter(True);
-            sessionExit(EX_NORMAL);
-        }
-        Signal(SIGALRM, IdleTimeout);
-        alarm(td->idleTimeout);
 #ifdef XDMCP
         if (((td->displayType & d_location) == dLocal) &&
                 td->loginMode >= LOGIN_DEFAULT_REMOTE)
@@ -622,7 +607,6 @@
             if (cmd == G_DGreet)
                 continue;
 #endif
-            alarm(0);
             if (cmd == G_Ready)
                 break;
             if (cmd == -2) {
--- trunk/KDE/kdebase/workspace/kdm/kfrontend/kchooser.cpp #1157485:1157486
@@ -28,6 +28,7 @@
 
 #include <klocale.h>
 
+#include <QApplication>
 #include <QLabel>
 #include <QLineEdit>
 #include <QPushButton>
@@ -39,6 +40,10 @@
 
 #include <stdlib.h> // for free()
 
+#define CHOOSE_TO 20 // inactivity timeout for reserve displays
+#define SECONDS 1000 // reduce to 100 to speed up testing
+
+
 class ChooserListViewItem : public QTreeWidgetItem {
   public:
     ChooserListViewItem(QTreeWidget *parent, int _id, const QString &nam, const QString &sts)
@@ -118,8 +123,26 @@
     connect(acceptButton, SIGNAL(clicked()), SLOT(accept()));
 //    connect(helpButton, SIGNAL(clicked()), SLOT(slotHelp()));
     connect(host_view, SIGNAL(itemActivated(QTreeWidgetItem *, int)), SLOT(accept()));
+
+    if (_isReserve) {
+        connect(&timer, SIGNAL(timeout()), SLOT(slotTimeout()));
+        connect(qApp, SIGNAL(activity()), SLOT(slotActivity()));
+        slotActivity();
 }
+}
 
+void
+ChooserDlg::slotTimeout()
+{
+    ::exit(EX_RESERVE);
+}
+
+void
+ChooserDlg::slotActivity()
+{
+    timer.start(CHOOSE_TO * SECONDS);
+}
+
 /*
 void ChooserDlg::slotHelp()
 {
--- trunk/KDE/kdebase/workspace/kdm/kfrontend/kchooser.h #1157485:1157486
@@ -26,6 +26,8 @@
 
 #include "kgdialog.h"
 
+#include <QTimer>
+
 class ChooserListViewItem;
 
 class QLineEdit;
@@ -47,10 +49,15 @@
     void accept();
     void reject();
 
+  private Q_SLOTS:
+    void slotTimeout();
+    void slotActivity();
+
   private:
     QString recvStr();
     ChooserListViewItem *findItem(int id);
 
+    QTimer timer;
     QTreeWidget *host_view;
     QLineEdit *iline;
     QSocketNotifier *sn;
--- trunk/KDE/kdebase/workspace/kdm/kfrontend/kgverify.cpp #1157485:1157486
@@ -312,6 +312,8 @@
         } else {
             applyPreset();
         }
+        if (_isReserve)
+            timer.start(FULL_GREET_TO * SECONDS);
     }
     sockNot->setEnabled(true);
     running = true;
@@ -439,6 +441,10 @@
         else
             timer.start(1000);
         updateStatus();
+    } else if (_isReserve) {
+        // assert(ctx == Login && running);
+        abort();
+        ::exit(EX_RESERVE);
     } else {
         // assert(ctx == Login);
         isClear = true;
@@ -463,6 +469,8 @@
     } else if (timeable) {
         // timed login is possible and thus scheduled. reschedule it.
         timer.start(TIMED_GREET_TO * SECONDS);
+    } else if (_isReserve) {
+        timer.start(FULL_GREET_TO * SECONDS);
     }
 }
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic