diff mcabber/src/jabglue.c @ 1426:a64778f5f26b

Implement FIFO named command pipe
author Mikael Berthe <mikael@lilotux.net>
date Mon, 18 Feb 2008 22:59:37 +0100
parents fb438482b28e
children 9bf7f3ddff10
line wrap: on
line diff
--- a/mcabber/src/jabglue.c	Sun Feb 17 21:19:58 2008 +0100
+++ b/mcabber/src/jabglue.c	Mon Feb 18 22:59:37 2008 +0100
@@ -35,6 +35,10 @@
 #include "pgp.h"
 #include "otr.h"
 
+#ifdef ENABLE_FIFO
+# include "fifo.h"
+#endif
+
 #define JABBERPORT      5222
 #define JABBERSSLPORT   5223
 
@@ -231,6 +235,10 @@
   long tmout;
   struct timeval tv;
   static time_t last_eviqs_check = 0L;
+  int maxfd;
+#ifdef ENABLE_FIFO
+  int fifofd;
+#endif
 
   if (!online) {
     safe_usleep(10000);
@@ -247,6 +255,15 @@
   FD_ZERO(&fds);
   FD_SET(0, &fds);
   FD_SET(jc->fd, &fds);
+  maxfd = jc->fd;
+
+#ifdef ENABLE_FIFO
+  fifofd = fifo_get_fd();
+  if (fifofd > 0) {
+    FD_SET(fifofd, &fds);
+    maxfd = MAX(maxfd, fifofd);
+  }
+#endif
 
   tv.tv_sec = 60;
   tv.tv_usec = 0;
@@ -276,7 +293,7 @@
     tv.tv_usec = 350000;
 
   scr_DoUpdate();
-  if (select(jc->fd + 1, &fds, NULL, NULL, &tv) > 0) {
+  if (select(maxfd + 1, &fds, NULL, NULL, &tv) > 0) {
     if (FD_ISSET(jc->fd, &fds))
       jab_poll(jc, 0);
   }