summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-11-17 01:50:46 +0100
committerLennart Poettering <lennart@poettering.net>2010-11-17 01:50:46 +0100
commit72bc55ded76c567adee241094ba3147c72706f79 (patch)
treef5ffc0dd6c3db350b4ebe340e3cbb9c376ac815b
parentd36415dcc3cd26a7d1def2f12b4d1c59e13d704e (diff)
Revert "linux: Use VT_WAITEVENT if available to avoid spawn too many threads"
This reverts commit 2782cc8d4950effbc4407455e72bd4750cef6e11. VT_WAITEVENT is racy unfortunately, since events that happen between the time we woke up from a VT_WAITEVENT and we go into the next VT_WAITEVENT are lost completely.
-rw-r--r--NEWS1
-rw-r--r--src/ck-sysdeps-unix.c44
-rw-r--r--src/ck-sysdeps.h2
-rw-r--r--src/ck-vt-monitor.c48
4 files changed, 8 insertions, 87 deletions
diff --git a/NEWS b/NEWS
index 807e9c4..101cb1c 100644
--- a/NEWS
+++ b/NEWS
@@ -8,7 +8,6 @@ Version 0.4.2
* Don't take bus name until ready (Ray Strode)
* systemd hookup (Lennart Poettering)
* add --since option to ck-history (William Jon McCann)
- * Reduce number of threads on Linux (Kan-Ru Chen)
* Other fixes (Anders Kaseor, Frederic Crozat, Matthias Clasen, Michael Biebl, William Jon McCann)
==============
diff --git a/src/ck-sysdeps-unix.c b/src/ck-sysdeps-unix.c
index 6a8b5f8..e4ab16b 100644
--- a/src/ck-sysdeps-unix.c
+++ b/src/ck-sysdeps-unix.c
@@ -296,50 +296,6 @@ ck_wait_for_active_console_num (int console_fd,
return ret;
}
-#ifdef VT_WAITEVENT
-gboolean
-ck_wait_for_console_switch (int console_fd,
- guint *num)
-{
- gboolean ret;
- int res;
- struct vt_event vt;
-
- g_assert (console_fd != -1);
-
- again:
- ret = FALSE;
- errno = 0;
- vt.event = VT_EVENT_SWITCH;
- vt.oldev = *num;
- res = ioctl (console_fd, VT_WAITEVENT, &vt);
-
- if (res == ERROR) {
- const char *errmsg;
-
- errmsg = g_strerror (errno);
-
- if (errno == EINTR) {
- g_debug ("Interrupted waiting for native console event: %s",
- errmsg);
- goto again;
- } else if (errno == ENOTSUP) {
- g_debug ("Console event not supported on this system");
- } else {
- g_warning ("Error waiting for native console event: %s",
- errmsg);
- }
- goto out;
- }
-
- ret = TRUE;
- *num = vt.newev;
-
- out:
- return ret;
-}
-#endif
-
gboolean
ck_activate_console_num (int console_fd,
guint num)
diff --git a/src/ck-sysdeps.h b/src/ck-sysdeps.h
index 5dd573f..8f22d52 100644
--- a/src/ck-sysdeps.h
+++ b/src/ck-sysdeps.h
@@ -72,8 +72,6 @@ gboolean ck_activate_console_num (int console_fd,
guint num);
gboolean ck_wait_for_active_console_num (int console_fd,
guint num);
-gboolean ck_wait_for_console_switch (int console_fd,
- guint *num);
G_END_DECLS
diff --git a/src/ck-vt-monitor.c b/src/ck-vt-monitor.c
index d7d1f0b..cf44983 100644
--- a/src/ck-vt-monitor.c
+++ b/src/ck-vt-monitor.c
@@ -26,7 +26,6 @@
#include <unistd.h>
#include <string.h>
#include <errno.h>
-#include <signal.h>
#include <glib.h>
#include <glib/gi18n.h>
@@ -40,11 +39,9 @@
#include "ck-sysdeps.h"
#include "ck-marshal.h"
-#ifdef HAVE_SYS_VT_H
+#if defined (__sun) && defined (HAVE_SYS_VT_H)
#include <sys/vt.h>
-#endif
-
-#ifdef __sun
+#include <signal.h>
#include <stropts.h>
#endif
@@ -165,7 +162,7 @@ ck_vt_monitor_get_active (CkVtMonitor *vt_monitor,
return TRUE;
}
-#if defined(HAVE_SYS_VT_H) && defined(__sun)
+#if defined (__sun) && defined (HAVE_SYS_VT_H)
static void
handle_vt_active (void)
{
@@ -315,31 +312,11 @@ vt_thread_start (ThreadData *data)
{
CkVtMonitor *vt_monitor;
gboolean res;
- guint num;
+ gint32 num;
vt_monitor = data->vt_monitor;
num = data->num;
-#ifdef VT_WAITEVENT
- for (;;) {
- res = ck_wait_for_console_switch (vt_monitor->priv->vfd, &num);
- if (! res) {
- break;
- } else {
- EventData *event;
-
- /* add event to queue */
- event = g_new0 (EventData, 1);
- event->num = num;
- g_debug ("Pushing activation event for VT %d onto queue", num);
-
- g_async_queue_push (vt_monitor->priv->event_queue, event);
-
- /* schedule processing of queue */
- schedule_process_queue (vt_monitor);
- }
- }
-#else
res = ck_wait_for_active_console_num (vt_monitor->priv->vfd, num);
if (! res) {
/* FIXME: what do we do if it fails? */
@@ -356,7 +333,6 @@ vt_thread_start (ThreadData *data)
/* schedule processing of queue */
schedule_process_queue (vt_monitor);
}
-#endif
G_LOCK (hash_lock);
if (vt_monitor->priv->vt_thread_hash != NULL) {
@@ -400,6 +376,10 @@ vt_add_watch_unlocked (CkVtMonitor *vt_monitor,
static void
vt_add_watches (CkVtMonitor *vt_monitor)
{
+ guint max_consoles;
+ int i;
+ gint32 current_num;
+
#if defined (__sun) && !defined (HAVE_SYS_VT_H)
/* Best to do nothing if VT is not supported */
#elif defined (__sun) && defined (HAVE_SYS_VT_H)
@@ -417,19 +397,7 @@ vt_add_watches (CkVtMonitor *vt_monitor)
sigaction (SIGPOLL, &act, NULL);
ioctl (vt_monitor->priv->vfd, I_SETSIG, S_MSG);
-#elif defined (VT_WAITEVENT)
- gpointer id;
-
- G_LOCK (hash_lock);
- id = GINT_TO_POINTER (1);
- if (g_hash_table_lookup (vt_monitor->priv->vt_thread_hash, id) == NULL)
- vt_add_watch_unlocked (vt_monitor, 1);
- G_UNLOCK (hash_lock);
#else
- guint max_consoles;
- int i;
- gint32 current_num;
-
G_LOCK (hash_lock);
current_num = vt_monitor->priv->active_num;