@@ -42,6 +42,14 @@ type item struct {
4242 item gregor.Item
4343 ctime time.Time
4444 dtime * time.Time
45+
46+ // If we received a message from the server that a message should be dimissed,
47+ // do so immediately, so as not to introduce clock-skew bugs. We previously
48+ // had a bug here --- a message would come in to dismiss a message M at server time T,
49+ // but then we would wait around for S seconds before marking that message as
50+ // dismissed, where S is the clock skew between the client and server. This seems
51+ // unnecessary, we should just mark the message dismissed when it comes in.
52+ dismissedImmediate bool
4553}
4654
4755// loggedMsg is a message that we've logged on arrival into this state machine
@@ -60,8 +68,12 @@ type user struct {
6068 log []loggedMsg
6169}
6270
63- // isDismissedAt returns true if item i is dismissed at time t
71+ // isDismissedAt returns true if item i is dismissed at time t. It will always return
72+ // true if the `dismissedImmediate` flag was turned out.
6473func (i item ) isDismissedAt (t time.Time ) bool {
74+ if i .dismissedImmediate {
75+ return true
76+ }
6577 if i .dtime != nil && isBeforeOrSame (* i .dtime , t ) {
6678 return true
6779 }
@@ -126,6 +138,7 @@ func (u *user) dismissMsgIDs(now time.Time, ids []gregor.MsgID) {
126138 for _ , i := range u .items {
127139 if _ , found := set [msgIDtoString (i .item .Metadata ().MsgID ())]; found {
128140 i .dtime = & now
141+ i .dismissedImmediate = true
129142 }
130143 }
131144}
@@ -156,6 +169,7 @@ func (u *user) dismissRanges(now time.Time, rs []gregor.MsgRange) {
156169 if r .Category ().String () == i .item .Category ().String () &&
157170 isBeforeOrSame (i .ctime , toTime (now , r .EndTime ())) {
158171 i .dtime = & now
172+ i .dismissedImmediate = true
159173 break
160174 }
161175 }
0 commit comments