mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-29 04:22:24 -05:00 
			
		
		
		
	[bugfix] fix possible mutex lockup during streaming code (#2633)
* rewrite Stream{} to use much less mutex locking, update related code
* use new context for the stream context
* ensure stream gets closed on return of writeTo / readFrom WSConn()
* ensure stream write timeout gets cancelled
* remove embedded context type from Stream{}, reformat log messages for consistency
* use c.Request.Context() for context passed into Stream().Open()
* only return 1 boolean, fix tests to expect multiple stream types in messages
* changes to ping logic
* further improved ping logic
* don't export unused function types, update message sending to only include relevant stream type
* ensure stream gets closed 🤦
* update to error log on failed json marshal (instead of panic)
* inverse websocket read error checking to _ignore_ expected close errors
	
	
This commit is contained in:
		
					parent
					
						
							
								8cafa6b74b
							
						
					
				
			
			
				commit
				
					
						291e180990
					
				
			
		
					 14 changed files with 535 additions and 451 deletions
				
			
		|  | @ -348,11 +348,7 @@ func (s *surface) timelineStatus( | |||
| 		err = gtserror.Newf("error converting status %s to frontend representation: %w", status.ID, err) | ||||
| 		return true, err | ||||
| 	} | ||||
| 
 | ||||
| 	if err := s.stream.Update(apiStatus, account, []string{streamType}); err != nil { | ||||
| 		err = gtserror.Newf("error streaming update for status %s: %w", status.ID, err) | ||||
| 		return true, err | ||||
| 	} | ||||
| 	s.stream.Update(ctx, account, apiStatus, streamType) | ||||
| 
 | ||||
| 	return true, nil | ||||
| } | ||||
|  | @ -363,12 +359,11 @@ func (s *surface) deleteStatusFromTimelines(ctx context.Context, statusID string | |||
| 	if err := s.state.Timelines.Home.WipeItemFromAllTimelines(ctx, statusID); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	if err := s.state.Timelines.List.WipeItemFromAllTimelines(ctx, statusID); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	return s.stream.Delete(statusID) | ||||
| 	s.stream.Delete(ctx, statusID) | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| // invalidateStatusFromTimelines does cache invalidation on the given status by | ||||
|  | @ -555,11 +550,6 @@ func (s *surface) timelineStreamStatusUpdate( | |||
| 		err = gtserror.Newf("error converting status %s to frontend representation: %w", status.ID, err) | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	if err := s.stream.StatusUpdate(apiStatus, account, []string{streamType}); err != nil { | ||||
| 		err = gtserror.Newf("error streaming update for status %s: %w", status.ID, err) | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	s.stream.StatusUpdate(ctx, account, apiStatus, streamType) | ||||
| 	return nil | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue