in ptp/ptp4u/server/subscription.go [83:123]
func (sc *SubscriptionClient) Start(ctx context.Context) {
log.Infof("Starting a new %s subscription for %s", sc.subscriptionType, timestamp.SockaddrToIP(sc.eclisa))
sc.setRunning(true)
over := fmt.Sprintf("Subscription %s is over for %s", sc.subscriptionType, timestamp.SockaddrToIP(sc.eclisa))
// Send first message right away
if sc.subscriptionType != ptp.MessageDelayResp {
sc.Once()
}
intervalTicker := time.NewTicker(sc.interval)
oldInterval := sc.interval
defer intervalTicker.Stop()
defer sc.setRunning(false)
for {
select {
case <-ctx.Done():
log.Infof(over)
// TODO send cancellation
return
case <-intervalTicker.C:
if sc.Expired() {
log.Infof(over)
// TODO send cancellation
return
}
// check if interval changed, maybe update our ticker
if oldInterval != sc.interval {
intervalTicker.Reset(sc.interval)
oldInterval = sc.interval
}
if sc.subscriptionType != ptp.MessageDelayResp {
// Add myself to the worker queue
sc.Once()
}
}
}
}