Lock for nc should be held here upon entry
(s *Subscription)
| 4975 | |
| 4976 | // Lock for nc should be held here upon entry |
| 4977 | func (nc *Conn) removeSub(s *Subscription) { |
| 4978 | nc.subsMu.Lock() |
| 4979 | delete(nc.subs, s.sid) |
| 4980 | nc.subsMu.Unlock() |
| 4981 | s.mu.Lock() |
| 4982 | defer s.mu.Unlock() |
| 4983 | // Release callers on NextMsg for SyncSubscription only |
| 4984 | if s.mch != nil && s.typ == SyncSubscription { |
| 4985 | close(s.mch) |
| 4986 | } |
| 4987 | s.mch = nil |
| 4988 | |
| 4989 | // If JS subscription then stop HB timer. |
| 4990 | if jsi := s.jsi; jsi != nil { |
| 4991 | if jsi.hbc != nil { |
| 4992 | jsi.hbc.Stop() |
| 4993 | jsi.hbc = nil |
| 4994 | } |
| 4995 | if jsi.csfct != nil { |
| 4996 | jsi.csfct.Stop() |
| 4997 | jsi.csfct = nil |
| 4998 | } |
| 4999 | } |
| 5000 | |
| 5001 | if s.typ != AsyncSubscription { |
| 5002 | done := s.pDone |
| 5003 | if done != nil { |
| 5004 | done(s.Subject) |
| 5005 | } |
| 5006 | } |
| 5007 | // Mark as invalid |
| 5008 | s.closed = true |
| 5009 | s.changeSubStatus(SubscriptionClosed) |
| 5010 | if s.pCond != nil { |
| 5011 | s.pCond.Broadcast() |
| 5012 | } |
| 5013 | } |
| 5014 | |
| 5015 | // SubscriptionType is the type of the Subscription. |
| 5016 | type SubscriptionType int |
no test coverage detected