Can mode ever be set to kLongPoll here? (cblite iOS)

20 views
Skip to first unread message

Traun Leyden

unread,
Jul 11, 2014, 12:12:06 PM7/11/14
to mobile-c...@googlegroups.com

On this line of code:


it seems like the if/then check is moot, due to 

    _caughtUp = NO;

always being called before this line.

So the above line should be change to:

    mode = kOneShot;

Any thoughts?

Jens Alfke

unread,
Jul 11, 2014, 4:38:33 PM7/11/14
to mobile-c...@googlegroups.com

On Jul 11, 2014, at 9:12 AM, Traun Leyden <tle...@couchbase.com> wrote:

> it seems like the if/then check is moot, due to
> _caughtUp = NO;
> always being called before this line.

You’re right. That ‘if’ test is a remnant of some logic that moved into CBLSocketChangeTracker (lines 212-213). In a continuous pull replication, when WebSockets aren’t available, we first get the changes feed using feed=normal, then after that switch to feed=longpoll. (The reason is so the puller can quickly tell that it’s already up to date, instead of waiting indefinitely for the longpoll feed to return something.)

I’ll make the change in the Obj-C repo.

—Jens

Jens Alfke

unread,
Jul 11, 2014, 4:41:38 PM7/11/14
to mobile-c...@googlegroups.com
On Jul 11, 2014, at 9:12 AM, Traun Leyden <tle...@couchbase.com> wrote:

So the above line should be change to:
    mode = kOneShot;

After making that change, I was able to simplify the logic for computing ‘mode’ to:

    CBLChangeTrackerMode mode = kOneShot;
    if (_continuous && pollInterval == 0.0 && self.canUseWebSockets)
        mode = kWebSocket;

—Jens
Reply all
Reply to author
Forward
0 new messages