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