Package: uim-gtk2.0
Version: 1:1.8.6-8
Severity: normal
File: /usr/bin/uim-input-pad-ja
Tags: patch upstream

Dear Maintainer,

When uim-input-pad-ja (both gtk2 and gtk3 versions) is running for a long time, it triggers growing memory consumption in uim-helper-server, as it opens socket to uim-helper-server, but fails to process incoming messages (it only uses this socket to write new messages).

Attached patch tries to fix this by adding dummy read handler (it is not
possible to half-close connection, as uim-helper-server will close
connection in this case).
Note: this bug also affects upstream master branch and many/all older versions.

-- System Information:
Debian Release: 8.0
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 3.16.0-4-686-pae (SMP w/1 CPU core)
Locale: LANG=ru_RU.KOI8-R, LC_CTYPE=ru_RU.KOI8-R (charmap=KOI8-R)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages uim-gtk2.0 depends on:
ii  libatk1.0-0          2.14.0-1
ii  libc6                2.19-18
ii  libcairo2            1.14.0-2.1
ii  libfontconfig1       2.11.0-6.3
ii  libfreetype6         2.5.2-3
ii  libgcroots0          0.8.5-4.1
ii  libgdk-pixbuf2.0-0   2.31.1-2+b1
ii  libglib2.0-0         2.42.1-1
ii  libgtk2.0-0          2.24.25-3
ii  libpango-1.0-0       1.36.8-3
ii  libpangocairo-1.0-0  1.36.8-3
ii  libpangoft2-1.0-0    1.36.8-3
ii  libuim-custom2       1:1.8.6-8
ii  libuim-data          1:1.8.6-8
ii  libuim-scm0          1:1.8.6-8
ii  libuim8              1:1.8.6-8
ii  libx11-6             2:1.6.2-3
ii  uim-common           1:1.8.6-8
ii  uim-utils            1:1.8.6-8

uim-gtk2.0 recommends no packages.

Versions of packages uim-gtk2.0 suggests:
pn  uim-dict-gtk  <none>

-- no debconf information

Description: uim-input-ja: read (and ignore) messages from uim-helper-server to avoid clogging its queue
Origin:
Bug-Debian:
Author: "Yuriy M. Kaminskiy" <yumkam+deb...@gmail.com>
Lst-Update: 2015-05-29

Index: uim-1.8.6/gtk2/pad/ja.c
===================================================================
--- uim-1.8.6.orig/gtk2/pad/ja.c
+++ uim-1.8.6/gtk2/pad/ja.c
@@ -264,6 +264,7 @@ gchar *line[] = {
 };
 
 static int uim_fd = -1;
+static unsigned int read_tag;
 
 static GtkWidget *buttontable_create(char **table, int tablelen);
 static GtkWidget *create_hiragana_tab(void);
@@ -280,13 +281,34 @@ static GtkWidget *input_table_create(gch
 static void       padbutton_clicked(GtkButton *button, gpointer user_data);
 
 
+static gboolean
+fd_read_cb(GIOChannel *channel, GIOCondition c, gpointer p)
+{
+  gchar *msg;
+  int fd = g_io_channel_unix_get_fd(channel);
+
+  uim_helper_read_proc(fd);
+
+  while ((msg = uim_helper_get_message())) {
+    /* do nothing */
+    free(msg);
+  }
+
+  return TRUE;
+}
+
 static void
 check_helper_connection(void)
 {
   if (uim_fd < 0) {
     uim_fd = uim_helper_init_client_fd(helper_disconnect_cb);
-    if (uim_fd < 0)
-      return;
+    if (uim_fd >= 0) {
+      GIOChannel *channel;
+      channel = g_io_channel_unix_new(uim_fd);
+      read_tag = g_io_add_watch(channel, G_IO_IN | G_IO_HUP | G_IO_ERR,
+				fd_read_cb, NULL);
+      g_io_channel_unref(channel);
+    }
   }
 }
 
@@ -294,6 +316,7 @@ static void
 helper_disconnect_cb(void)
 {
   uim_fd = -1;
+  g_source_remove(read_tag);
 }
 
 static void

Reply via email to