fix(push): goroutine leak (#540)
This commit is contained in:
parent
e65fc288b6
commit
bb18241ce9
|
@ -159,7 +159,7 @@ func GetHuaweiNotification(req PushNotification) (*model.MessageRequest, error)
|
|||
return nil, err
|
||||
}
|
||||
|
||||
LogAccess.Debug("Default message is %s", string(b))
|
||||
LogAccess.Debugf("Default message is %s", string(b))
|
||||
return msgRequest, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -79,16 +79,18 @@ func pushHandler(c *gin.Context) {
|
|||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
notifier := c.Writer.CloseNotify()
|
||||
go func(closer <-chan bool) {
|
||||
<-closer
|
||||
go func() {
|
||||
// Deprecated: the CloseNotifier interface predates Go's context package.
|
||||
// New code should use Request.Context instead.
|
||||
// Change to context package
|
||||
<-c.Request.Context().Done()
|
||||
// Don't send notification after client timeout or disconnected.
|
||||
// See the following issue for detail information.
|
||||
// https://github.com/appleboy/gorush/issues/422
|
||||
if PushConf.Core.Sync {
|
||||
cancel()
|
||||
}
|
||||
}(notifier)
|
||||
}()
|
||||
|
||||
counts, logs := queueNotification(ctx, form)
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ func (s *Server) Send(ctx context.Context, in *proto.NotificationRequest) (*prot
|
|||
ThreadID: in.ThreadID,
|
||||
MutableContent: in.MutableContent,
|
||||
Image: in.Image,
|
||||
Priority: strings.ToLower(in.GetPriority().String()),
|
||||
Priority: strings.ToLower(in.GetPriority().String()),
|
||||
}
|
||||
|
||||
if badge > 0 {
|
||||
|
|
Loading…
Reference in New Issue