Author: titmuss
Date: Wed Nov 12 08:32:40 2008
New Revision: 3346

URL: http://svn.slimdevices.com?rev=3346&root=Jive&view=rev
Log:
Bug: 9960
Description:
Don't send comet subscriptions with the meta (re)connect requests. SC can't 
ensure the responses are returned in the correct order, 
and that confuses the state machine in the comet class. This could result in 
some subscriptions being lost, and multiple tcp 
connection requests.


Modified:
    7.3/trunk/squeezeplay/src/squeezeplay/share/jive/net/Comet.lua

Modified: 7.3/trunk/squeezeplay/src/squeezeplay/share/jive/net/Comet.lua
URL: 
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/share/jive/net/Comet.lua?rev=3346&root=Jive&r1=3345&r2=3346&view=diff
==============================================================================
--- 7.3/trunk/squeezeplay/src/squeezeplay/share/jive/net/Comet.lua (original)
+++ 7.3/trunk/squeezeplay/src/squeezeplay/share/jive/net/Comet.lua Wed Nov 12 
08:32:40 2008
@@ -89,6 +89,7 @@
 local _getHandshakeSink
 local _connect
 local _reconnect
+local _connected
 local _getEventSink
 local _getRequestSink
 local _response
@@ -669,19 +670,6 @@
                subscription = '/' .. self.clientId .. '/**',
        } }
 
-       -- Add any un-acknowledged requests to the outgoing data
-       for i, v in ipairs(self.sent_reqs) do
-               table.insert(data, v)
-       end
-
-       -- Add any other pending requests to the outgoing data
-       _addPendingRequests(self, data)
-
-       if log:isDebug() then
-               log:debug("Sending pending request(s):")
-               debug.dump(data, 5)
-       end
-
        -- This will be our last request on this connection, it is now only
        -- for listening for responses
 
@@ -717,14 +705,6 @@
                connectionType = 'streaming',
        } }
 
-       -- Add any un-acknowledged requests to the outgoing data
-       for i, v in ipairs(self.sent_reqs) do
-               table.insert(data, v)
-       end
-
-       -- Add any other pending requests to the outgoing data
-       _addPendingRequests(self, data)
-
        _state(self, CONNECTING)
        
        local req = CometRequest(
@@ -734,6 +714,38 @@
                )
 
        self.chttp:fetch(req)
+end
+
+
+_connected = function(self)
+       _state(self, CONNECTED)
+
+       local data = { }
+
+       -- Add any un-acknowledged requests to the outgoing data
+       for i, v in ipairs(self.sent_reqs) do
+               table.insert(data, v)
+       end
+
+       -- Add any other pending requests to the outgoing data
+       _addPendingRequests(self, data)
+
+       -- Only continue if we have some data to send
+       if data[1] then
+
+               if log:isDebug() then
+                       log:debug("Sending pending request(s):")
+                       debug.dump(data, 5)
+               end
+
+               local req = CometRequest(
+                       _getEventSink(self),
+                       self.uri,
+                       data
+               )
+
+               self.rhttp:fetch(req)
+       end
 end
 
 
@@ -804,10 +816,7 @@
                -- Handle response
                if event.channel == '/meta/connect' then
                        if event.successful then
-                               _state(self, CONNECTED)
-
-                               -- send any requests queued during connect
-                               _sendPendingRequests(self)
+                               _connected(self)
                        else
                                return _handleAdvice(self)
                        end
@@ -824,7 +833,7 @@
                        end
                elseif event.channel == '/meta/reconnect' then
                        if event.successful then
-                               _state(self, CONNECTED)
+                               _connected(self)
                        else
                                return _handleAdvice(self)
                        end

_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins

Reply via email to