Author: titmuss
Date: Mon Jul  7 09:00:16 2008
New Revision: 2668

URL: http://svn.slimdevices.com?rev=2668&root=Jive&view=rev
Log:
Bug: 5378
Description:
Sent pending requests after the connect/reconnect in comet. It's possible the 
(re)connect will fail, so it is better to send 
the requests after we know it's been sucessful. This may possibly fix a rare 
Comet bug following WOL.


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

Modified: 7.1/trunk/squeezeplay/src/squeezeplay/share/jive/net/Comet.lua
URL: 
http://svn.slimdevices.com/7.1/trunk/squeezeplay/src/squeezeplay/share/jive/net/Comet.lua?rev=2668&root=Jive&r1=2667&r2=2668&view=diff
==============================================================================
--- 7.1/trunk/squeezeplay/src/squeezeplay/share/jive/net/Comet.lua (original)
+++ 7.1/trunk/squeezeplay/src/squeezeplay/share/jive/net/Comet.lua Mon Jul  7 
09:00:16 2008
@@ -341,10 +341,19 @@
 
 
 -- Send any pending subscriptions and requests
-_sendPendingRequests = function(self)
+_sendPendingRequests = function(self, addSentReqs)
 
        -- add all pending unsub requests, and any others we need to send
        local data = {}
+
+       if addSentReqs then
+               -- following re-connection we also need to include any
+               --  un-acknowledged requests to the outgoing data
+               for i, v in ipairs(self.sent_reqs) do
+                       table.insert(data, v)
+               end
+       end
+
        _addPendingRequests(self, data)
        
        -- Only continue if we have some data to send
@@ -669,28 +678,12 @@
                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
-
        local req = CometRequest(
                        _getEventSink(self),
                        self.uri,
                        data
                )
-       
+
        self.chttp:fetch(req)
 end
 
@@ -716,22 +709,14 @@
                clientId       = self.clientId,
                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(
                        _getEventSink(self),
                        self.uri,
                        data
                )
+
+       _state(self, CONNECTING)
 
        self.chttp:fetch(req)
 end
@@ -807,7 +792,7 @@
                                _state(self, CONNECTED)
 
                                -- send any requests queued during connect
-                               _sendPendingRequests(self)
+                               _sendPendingRequests(self, true)
                        else
                                return _handleAdvice(self)
                        end
@@ -825,6 +810,9 @@
                elseif event.channel == '/meta/reconnect' then
                        if event.successful then
                                _state(self, CONNECTED)
+
+                               -- send any requests queued during re-connect
+                               _sendPendingRequests(self, true)
                        else
                                return _handleAdvice(self)
                        end
@@ -960,7 +948,7 @@
 
 
 _handleTimer = function(self)
-       log:debug(self, ": handleTimer state=", self.state, " advice=", 
self.advice)
+       log:debug(self, ": handleTimer state=", self.state, " 
advice.reconnect=", self.advice.reconnect)
 
        if self.state ~= UNCONNECTED then
                log:debug(self, ": ignoring timer while ", self.state)

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

Reply via email to