code: func (s *StanServer) performDurableRedelivery(c *channel, sub *subState) {
  	// Sort our messages outstanding from acksPending, grab some state and unlock.
  	sub.RLock()
  	sortedSeqs := makeSortedSequences(sub.acksPending)
  	clientID := sub.ClientID
  	newOnHold := sub.newOnHold
  	subID := sub.ID
  	sub.RUnlock()
  
  	if s.debug && len(sortedSeqs) > 0 {
  		sub.RLock()
  		durName := sub.DurableName
  		if durName == "" {
  			durName = sub.QGroup
  		}
  		sub.RUnlock()
  		s.log.Debugf("[Client:%s] Redelivering to subid=%d, durable=%s", clientID, subID, durName)
  	}
  
  	// If we don't find the client, we are done.
  	if s.clients.lookup(clientID) != nil {
  		// Go through all messages
  		for _, seq := range sortedSeqs {
  			m := s.getMsgForRedelivery(c, sub, seq)
  			if m == nil {
  				continue
  			}
  
  			if s.trace {
  				s.log.Tracef("[Client:%s] Redelivering to subid=%d, seq=%d", clientID, subID, m.Sequence)
  			}
  
  			// Flag as redelivered.
  			m.Redelivered = true
  
  			sub.Lock()
  			// Force delivery
  			s.sendMsgToSub(sub, m, forceDelivery)
  			sub.Unlock()
  		}
  	}
  	// Release newOnHold if needed.
  	if newOnHold {
  		sub.Lock()
  		sub.newOnHold = false
  		sub.Unlock()
  	}
  }
docs: // Redeliver all outstanding messages to a durable subscriber, used on resubscribe.