gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r12276 - gnunet/src/vpn


From: gnunet
Subject: [GNUnet-SVN] r12276 - gnunet/src/vpn
Date: Tue, 20 Jul 2010 13:36:45 +0200

Author: toelke
Date: 2010-07-20 13:36:45 +0200 (Tue, 20 Jul 2010)
New Revision: 12276

Modified:
   gnunet/src/vpn/gnunet-vpn-helper.c
Log:
only select for write, if it was not possible before

Modified: gnunet/src/vpn/gnunet-vpn-helper.c
===================================================================
--- gnunet/src/vpn/gnunet-vpn-helper.c  2010-07-20 11:36:45 UTC (rev 12275)
+++ gnunet/src/vpn/gnunet-vpn-helper.c  2010-07-20 11:36:45 UTC (rev 12276)
@@ -139,6 +139,9 @@
 
        int rea = 1;
        int wri = 1;
+
+       int write_fd_possible = 0;
+       int write_stdout_possible = 0;
 outer:
        while(rea != 0 && wri != 0 && running == 1) {
                FD_ZERO(&fds_w);
@@ -146,18 +149,24 @@
 
                if (rea) {
                        FD_SET(fd_tun, &fds_r);
-                       FD_SET(1, &fds_w);
+                       if (!write_stdout_possible)
+                               FD_SET(1, &fds_w);
                }
 
                if (wri) {
                        FD_SET(0, &fds_r);
-                       FD_SET(fd_tun, &fds_w);
+                       if (!write_fd_possible)
+                               FD_SET(fd_tun, &fds_w);
                }
 
                int r = select(fd_tun+1, &fds_r, &fds_w, (fd_set*)0, 0);
 
                if(r > 0) {
-                       if (FD_ISSET(0, &fds_r) && FD_ISSET(fd_tun, &fds_w)) {
+                       if (FD_ISSET(fd_tun, &fds_w)) write_fd_possible = 1;
+                       if (FD_ISSET(1, &fds_w)) write_stdout_possible = 1;
+
+                       if (FD_ISSET(0, &fds_r) && write_fd_possible) {
+                               write_fd_possible = 0;
                                struct suid_packet *pkt = (struct suid_packet*) 
buf;
                                r = read(0, buf, sizeof(struct 
suid_packet_header));
                                if (r < 0) {
@@ -190,7 +199,8 @@
                                        }
                                        r += t;
                                }
-                       } else if (FD_ISSET(1, &fds_w) && FD_ISSET(fd_tun, 
&fds_r)) {
+                       } else if (write_stdout_possible && FD_ISSET(fd_tun, 
&fds_r)) {
+                               write_stdout_possible = 0;
                                r = read(fd_tun, buf, 65600);
                                if (r < 0) {
                                        fprintf(stderr, "read-error: %m\n");




reply via email to

[Prev in Thread] Current Thread [Next in Thread]