pombreda / libjingle

Automatically exported from code.google.com/p/libjingle
0 stars 0 forks source link

Zero length upd packet shuts down jingle port. #360

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Start a jingle connection.
2. Send a zero length packet to one of the UDP ports that is in use.
3. Watch that port never call recvfrom() ever again

Please provide any additional information below.

The problem is that libjingle has some code that consider a zero length recv on 
any socket to indicate that the socket is closed. This is valid for TCP, but is 
wrong for UDP. The following patch fixes the problem (it is against my source 
tree, but it should be trivial to find the file that needs fixing):

diff --git 
a/stacks/texas_videoconf/jingle/libjingle/talk/base/physicalsocketserver.cc 
b/stacks/texas_videoconf/jingle/libjingle/talk/base/physicalsocketserver.cc
--- a/stacks/texas_videoconf/jingle/libjingle/talk/base/physicalsocketserver.cc
+++ b/stacks/texas_videoconf/jingle/libjingle/talk/base/physicalsocketserver.cc
@@ -798,6 +798,13 @@
   }

   virtual bool IsDescriptorClosed() {
+    if (udp_)
+    {
+      // UDP is connectionless, and zero length UDP packets should not
+      // be interpreted as a close.
+      return false;
+    }
+
     // We don't have a reliable way of distinguishing end-of-stream
     // from readability.  So test on each readable call.  Is this
     // inefficient?  Probably.

Original issue reported on code.google.com by bla...@suitabletech.com on 15 Jun 2012 at 8:18