on master help sign in
Fix server poll blocking indefinitely by returning empty events instead of retry
8f74adfiko
client/ViewConversations.fs+13−7
@@ -84,12 +84,18 @@ module ViewConversations =
84 )
84 )
85
85
86 let bar =
86 let bar =
87+ VStack(0.) {
88+ TextBlock($"{connStatusLabel model.Auth} | {model.PollStatus}")
89+ .fontSize(10.)
90+ .foreground(SolidColorBrush(Colors.Gray))
91+ .centerText ()
92+
87− (Grid([ Dimension.Auto; Dimension.Star; Dimension.Auto ], [ Dimension.Auto ]) {
93+ (Grid([ Dimension.Auto; Dimension.Star; Dimension.Auto ], [ Dimension.Auto ]) {
88− (smallImageButton None (SetPage Settings)).gridColumn (0)
94+ (smallImageButton None (SetPage Settings)).gridColumn (0)
89− (textField "" Search).margin(8.).verticalAlignment(VerticalAlignment.Stretch).gridColumn (1)
95+ (textField "" Search).margin(8.).verticalAlignment(VerticalAlignment.Stretch).gridColumn (1)
90− (smallTextButton "+" (SetPage(AddContact("")))).gridColumn (2)
96+ (smallTextButton "+" (SetPage(AddContact("")))).gridColumn (2)
91− })
97+ })
92− // .margin(20.)
93− .horizontalAlignment (HorizontalAlignment.Stretch)
98+ .horizontalAlignment (HorizontalAlignment.Stretch)
99+ }
94
100
95 withBottomBar bar content
101 withBottomBar bar content
server.knot+11−9
@@ -47,6 +47,9 @@ gossipOriginHops = 2
47
47
48backgroundPruneInterval : Int<Ms>
48backgroundPruneInterval : Int<Ms>
49backgroundPruneInterval = 30000 -- 30 seconds
49backgroundPruneInterval = 30000 -- 30 seconds
50+pollSleepInterval : Int<Ms>
51+pollSleepInterval = 500 -- 500ms between poll attempts
52+maxPollWaitAttempts = 60 -- 60 * 500ms = 30 second max long-poll
50federationEnabled = federationSecret != ""
53federationEnabled = federationSecret != ""
51federationAuth = "Bearer " ++ federationSecret
54federationAuth = "Bearer " ++ federationSecret
52federationUrl = \server -> federationScheme ++ server
55federationUrl = \server -> federationScheme ++ server
@@ -815,15 +818,14 @@ pruneAndRetry = \t -> do
815
818
816pollOnce = \token cursor -> do
819pollOnce = \token cursor -> do
817 t <- now
820 t <- now
818− atomic do
819− sessions <- *sessions
821+ sessions <- *sessions
820− let auth = authenticateSession sessions token t
822+ let auth = authenticateSession sessions token t
821− case auth of
823+ case auth of
822− Unauthorized {} ->
823− yield (PollUnauthorized {})
824+ Unauthorized {} -> yield (PollUnauthorized {})
824− Authorized {pubkey} -> do
825+ Authorized {pubkey} -> do
825− seqCounter <- *seqCounter
826+ seqCounter <- *seqCounter
826− let clampedCursor = clamp 0 (max seqCounter t) cursor
827+ let clampedCursor = clamp 0 (max seqCounter t) cursor
828+ atomic do
827 matchingMsgs <- do
829 matchingMsgs <- do
828 m <- *messages
830 m <- *messages
829 where m.toKey == pubkey && m.receivedAt >= t - messageMaxAge && m.receivedAt > clampedCursor
831 where m.toKey == pubkey && m.receivedAt >= t - messageMaxAge && m.receivedAt > clampedCursor