[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

patch on 18.12



Hi Peter and all,

Did some changes:

  artefacts patch (very simple!)
  more logical implementation of the main loop

Seems to fix most artefact bugs in w2k and the Netscape menu bug I reported.

Regards,
Svenni.

-- 
Sveinn Sveinsson                      | mailto:svenni@strengur.is
Strengur ltd Computer Consultants     | mailto:ssveinss@informix.com
Ármúla 7                              | Phone: +354-550-9000
IS-108 Reykjavik                      | Fax: +354-550-9010
Iceland
 
diff -Naur rdesktop-patched/Makefile rdesktop-patched2/Makefile
--- rdesktop-patched/Makefile	Thu Jan 11 12:52:11 2001
+++ rdesktop-patched2/Makefile	Thu Jan 11 18:17:31 2001
@@ -24,7 +24,7 @@
 	cproto -DMAKE_PROTO -o proto.h *.c
 
 clean:
-	rm -f *.o crypto/*.o *~ *.out
+	rm -f *.o crypto/*.o *~ *.out rdesktop core
 
 .SUFFIXES:
 .SUFFIXES: .c .o
diff -Naur rdesktop-patched/proto.h rdesktop-patched2/proto.h
--- rdesktop-patched/proto.h	Thu Jan 11 12:52:11 2001
+++ rdesktop-patched2/proto.h	Thu Jan 11 13:21:38 2001
@@ -51,6 +51,7 @@
 BOOL sec_connect(char *server);
 void sec_disconnect(void);
 /* tcp.c */
+int rdp_socket();
 STREAM tcp_init(int maxlen);
 void tcp_send(STREAM s);
 STREAM tcp_recv(int length);
diff -Naur rdesktop-patched/rdp.c rdesktop-patched2/rdp.c
--- rdesktop-patched/rdp.c	Thu Jan 11 18:03:21 2001
+++ rdesktop-patched2/rdp.c	Thu Jan 11 18:09:54 2001
@@ -18,6 +18,9 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
+#include <sys/time.h>
+#include <errno.h>
+
 #include "rdesktop.h"
 extern uint16 mcs_userid;
 extern char username[64];
@@ -58,11 +61,11 @@
 }
 
 
+static STREAM rdp_s;
 /* Receive an RDP packet */
 static STREAM
 rdp_recv (uint8 * type)
 {
-  static STREAM rdp_s;
   uint16 length, pdu_type;
   if ((rdp_s == NULL) || (next_packet >= rdp_s->end))
 
@@ -554,7 +557,7 @@
 	    }
 	  ui_paint_bitmap (left, top, cx, cy, width, height, rawdata);
 	  xfree (rawdata);
-	  return;
+	  continue;
 	}
       in_uint8s (s, 2);		/* pad */
       in_uint16_le (s, size);
@@ -648,27 +651,97 @@
 {
   uint8 type;
   STREAM s;
-  while ((s = rdp_recv (&type)) != NULL)
+  struct timeval tv;
+  fd_set rfds;
+  int do_ui_sync = 0;
+  int rdpsocket = rdp_socket();
+  int uisocket = ui_select_fd();
+  int maxsocket = 0;
+  int ret = 0;
+
+  if (rdpsocket < 0) {
+    STATUS ("rdp socket");
+    return;
+  }
+
+  if (uisocket < 0) {
+    STATUS ("ui socket");
+    return;
+  }
+  
+  maxsocket = ((rdpsocket > uisocket) ? rdpsocket : uisocket);
+  DEBUG ("rdp=%d, ui=%d\n", rdpsocket , uisocket);
+
+  for (;;) {
+
+    DEBUG  ("sync=%d\n", do_ui_sync);
+    FD_ZERO (&rfds);
+    FD_SET(rdpsocket, &rfds);
+    FD_SET(uisocket, &rfds);
+
+    if (do_ui_sync) {
+      tv.tv_sec = 0;
+      tv.tv_usec = 100000; // 0.1sec
+    }
+    else {
+      tv.tv_sec = 300;
+      tv.tv_usec = 0;
+    }
 
-    {
-      DEBUG ("main loop type=%d\n", type);
-      switch (type)
+    ret = select (maxsocket + 1, &rfds, NULL, NULL, &tv);
+    DEBUG  ("ret=%d\n", ret);
 
-	{
-	case RDP_PDU_DEMAND_ACTIVE:
-	  process_demand_active (s);
-	  break;
-	case RDP_PDU_DEACTIVATE:
-	  break;
-	case RDP_PDU_DATA:
-	  process_data_pdu (s);
-	  break;
-	default:
-	  NOTIMP ("PDU %d\n", type);
-	}
-    }
-}
+    if (ret == -1)
+        {
+          STATUS ("tcp_recv: select: %s\n", strerror (errno));
+          break;
+        }
+      else if (ret)
+        {
+          if (FD_ISSET (rdpsocket, &rfds)) 
+            {
+
+             DEBUG  ("rdp\n");
+             do {
+              if ((s = rdp_recv (&type)) == NULL)
+                return;
+
+              DEBUG ("main loop type=%d\n", type);
+              switch (type)
+	      {
+	        case RDP_PDU_DEMAND_ACTIVE:
+	          process_demand_active (s);
+	          break;
+	        case RDP_PDU_DEACTIVATE:
+	          break;
+	        case RDP_PDU_DATA:
+	          process_data_pdu (s);
+	          break;
+	        default:
+	          NOTIMP ("PDU %d\n", type);
+	      }
+              DEBUG ("switch type done\n");
+             } while (next_packet < rdp_s->end);
+            }
+
+          if (FD_ISSET (uisocket, &rfds))
+            {
+              ui_process_events ();
+            }
+
+          do_ui_sync = 1;
+
+         }
+      else
+         {
+           DEBUG ("tcp_recv: timeout\n");
+           ui_sync();
+           do_ui_sync = 0;
+         }
 
+  }
+
+}
 
 /* Establish a connection up to the RDP layer */
 BOOL
diff -Naur rdesktop-patched/tcp.c rdesktop-patched2/tcp.c
--- rdesktop-patched/tcp.c	Thu Jan 11 12:52:11 2001
+++ rdesktop-patched2/tcp.c	Thu Jan 11 18:17:49 2001
@@ -31,7 +31,12 @@
 static int sock;
 static struct stream in;
 static struct stream out;
-static int do_ui_sync = 0;
+
+int
+rdp_socket()
+{
+  return (sock);
+}
 
 /* Initialise TCP transport data packet */
 STREAM tcp_init (int maxlen)
@@ -71,10 +76,7 @@
 /* Receive a message on the TCP layer */
 STREAM tcp_recv (int length)
 {
-  int ret, rcvd = 0;
-  struct timeval tv;
-  fd_set rfds;
-  int uisocket, maxsocket;	// ss
+  int rcvd = 0;
 
   if (length > in.size)
     {
@@ -86,37 +88,7 @@
 
   while (length > 0)
     {
-      maxsocket = sock;		// ss
-      tv.tv_sec = 0;
-      tv.tv_usec = 100;
-      FD_ZERO (&rfds);
-      FD_SET (sock, &rfds);
-      if ((uisocket = ui_select_fd ()) != -1)
-	{
-	  FD_SET (uisocket, &rfds);
-	  if (uisocket > sock)
-	    maxsocket = uisocket;
-          if (do_ui_sync) {
-            tv.tv_sec = 0;
-            tv.tv_usec = 100000; // 0.1sec
-            do_ui_sync = 0;
-          }
-          else {
-           tv.tv_sec = 300;
-           tv.tv_usec = 0;
-          }
-	}
-
-      ret = select (maxsocket + 1, &rfds, NULL, NULL, &tv);
-
-      if (ret == -1)
-	{
-	  STATUS ("tcp_recv: select: %s\n", strerror (errno));
-	}
-      else if (ret)
-	{
-	  if (FD_ISSET (sock, &rfds))
-	    {
+      DEBUG ("length=%d\n", length);
 	      rcvd = read (sock, in.end, length);
 
 	      if (rcvd <= 0)
@@ -127,18 +99,7 @@
 
 	      in.end += rcvd;
 	      length -= rcvd;
-	    }
-	  if (uisocket != -1 && FD_ISSET (uisocket, &rfds))
-	    {
-	      ui_process_events ();
-	    }
-	}
-        else{
-          DEBUG ("tcp_recv: timeout\n");
-          ui_sync();
-        }
     }
-  do_ui_sync = 1;
   return &in;
 }