[uim-commit] r354 - trunk/uim

ekato@freedesktop.org ekato@freedesktop.org
Tue Jan 25 20:51:45 PST 2005


Author: ekato
Date: 2005-01-25 20:51:42 -0800 (Tue, 25 Jan 2005)
New Revision: 354

Modified:
   trunk/uim/uim-helper-client.c
   trunk/uim/uim-helper-server.c
   trunk/uim/uim-helper.c
Log:
* uim/uim-helper-server.c : Handle SIGPIPE properly which was
  caused from sudden disconnect of uim-im-switcher-gtk.
(parse_content) : Handle EPIPE.
(main) : SIG_IGN of SIGPIPE.
* uim/uim-helper-client.c (uim_helper_read_proc) : Check fd
  readable state properly.
* uim/uim-helper.c (uim_helper_send_message) : Check fd writable
  state properly.


Modified: trunk/uim/uim-helper-client.c
===================================================================
--- trunk/uim/uim-helper-client.c	2005-01-25 02:21:13 UTC (rev 353)
+++ trunk/uim/uim-helper-client.c	2005-01-26 04:51:42 UTC (rev 354)
@@ -186,12 +186,12 @@
   char buf[BUFFER_SIZE];
   int rc;
 
-  while(uim_helper_fd_readable(fd) > 0) {
+  while (uim_helper_fd_readable(fd) > 0) {
     
     rc = read(fd, buf, sizeof(buf)-1);
     buf[rc] = '\0';
     
-    if(rc == 0) {
+    if (rc == 0) {
       if (uim_disconnect_cb) {
 	uim_disconnect_cb();
       }

Modified: trunk/uim/uim-helper-server.c
===================================================================
--- trunk/uim/uim-helper-server.c	2005-01-25 02:21:13 UTC (rev 353)
+++ trunk/uim/uim-helper-server.c	2005-01-26 04:51:42 UTC (rev 354)
@@ -43,6 +43,7 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include <signal.h>
 #include "uim.h"
 #include "uim-helper.h"
 
@@ -127,12 +128,17 @@
 parse_content(char *content, struct client *cl)
 {
   int i;
+  int ret;
 
-  for (i = 0; i < nr_client_slots; i ++){
-    if(clients[i].fd != -1 && 
-       clients[i].fd != cl->fd && 
-       uim_helper_fd_writable(clients[i].fd)) {
-      write(clients[i].fd, content, strlen(content));
+  for (i = 0; i < nr_client_slots; i++) {
+    if (clients[i].fd != -1 && clients[i].fd != cl->fd &&
+		    (uim_helper_fd_writable(clients[i].fd) > 0)) {
+      ret = write(clients[i].fd, content, strlen(content));
+
+      if (ret == -1 && errno == EPIPE) {
+	close(clients[i].fd);
+	free_client(&clients[i]);
+      }
     }
   }
 }
@@ -267,6 +273,8 @@
 
   free(path);
 
+  signal(SIGPIPE, SIG_IGN);
+
   uim_helper_server_process_connection(serv_fd);
 
   return 0;

Modified: trunk/uim/uim-helper.c
===================================================================
--- trunk/uim/uim-helper.c	2005-01-25 02:21:13 UTC (rev 353)
+++ trunk/uim/uim-helper.c	2005-01-26 04:51:42 UTC (rev 354)
@@ -91,7 +91,7 @@
   /* readable and cannot read any character, means disconnected.
      so we should read here and proc such condition. */
 
-  if (uim_helper_fd(fd, WRITE)) {
+  if (uim_helper_fd(fd, WRITE) > 0) {
     int len = strlen(message);
     char *buf = malloc(len + 2);
     snprintf(buf, len + 2,"%s\n", message);



More information about the Uim-commit mailing list