Changeset 61fc056


Ignore:
Timestamp:
2018-08-26T20:56:09Z (4 months ago)
Author:
dequis <dx@…>
Branches:
master
Children:
37437f2
Parents:
0b1448f
Message:

irc_im: fix away_reply_timeout getting reset too often

The hangouts plugin regularly sends redundant user status updates, since
that's how it works. The 'bee_irc_user_status' has some checks to not do
things on redundant changes, but they apply to other parts of the
function, not to the line that sets 'iu->away_reply_timeout = 0;'

This commit moves a bunch of the checks used for CAP_AWAY_NOTIFY to the
top of the function so it returns early if nothing was changed. It also
simplifies the flags check to plain equality, which should be good
enough.

As a side effect of this change, bee_irc_channel_update() won't be
called redundantly anymore. That function iterates over all channels,
so maybe in some workflows this improves performance? I doubt it.
There's also a risk that the redundant calls were actually needed.
I have no way to determine this, so i'll let future-dx deal with it.

Bug reported by needo, offending line pointed out by digitalcircuit,
thanks both!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc_im.c

    r0b1448f r61fc056  
    121121        }
    122122
     123        /* return early if nothing changed */
     124        if ((bu->flags == old->flags) &&
     125            (g_strcmp0(bu->status, old->status) == 0) &&
     126            (g_strcmp0(bu->status_msg, old->status_msg) == 0)) {
     127                return TRUE;
     128        }
     129
    123130        if ((bu->flags & BEE_USER_ONLINE) != (old->flags & BEE_USER_ONLINE)) {
    124131                if (bu->flags & BEE_USER_ONLINE) {
     
    144151        }
    145152
    146         /* Reset this one since the info may have changed. */
    147153        iu->away_reply_timeout = 0;
    148154
    149155        bee_irc_channel_update(irc, NULL, iu);
    150156
    151         /* If away-notify enabled, send status updates when:
    152          * Away or Online state changes
    153          * Status changes (e.g. "Away" to "Mobile")
    154          * Status message changes
    155          */
    156         if ((irc->caps & CAP_AWAY_NOTIFY) &&
    157             ((bu->flags & BEE_USER_AWAY) != (old->flags & BEE_USER_AWAY) ||
    158              (bu->flags & BEE_USER_ONLINE) != (old->flags & BEE_USER_ONLINE) ||
    159              (g_strcmp0(bu->status, old->status) != 0) ||
    160              (g_strcmp0(bu->status_msg, old->status_msg) != 0))) {
     157        if (irc->caps & CAP_AWAY_NOTIFY) {
    161158                irc_send_away_notify(iu);
    162159        }
Note: See TracChangeset for help on using the changeset viewer.