channel_delete((channel_t*)self, 1);
}
+static void
+channel_class_notify_enabled ( void *obj, const char *lang )
+{
+ channel_t *ch = (channel_t *)obj;
+ if (!ch->ch_enabled)
+ channel_remove_subscriber(ch, SM_CODE_CHN_NOT_ENABLED);
+}
+
static int
channel_class_autoname_set ( void *obj, const void *p )
{
.desc = N_("Enable/disable the channel."),
.def.i = 1,
.off = offsetof(channel_t, ch_enabled),
+ .notify = channel_class_notify_enabled,
},
{
.type = PT_BOOL,
channel_event_updated(e);
}
+/**
+ * Remove all subscribers for given channel
+ */
+void channel_remove_subscriber
+ ( channel_t *ch, int reason )
+{
+ th_subscription_t *s, *s_next;
+ idnode_list_mapping_t *ilm;
+ service_t *t;
+
+ lock_assert(&global_lock);
+
+ LIST_FOREACH(ilm, &ch->ch_services, ilm_in2_link) {
+ t = (service_t *)ilm->ilm_in1;
+ for (s = LIST_FIRST(&t->s_subscriptions); s; s = s_next) {
+ s_next = LIST_NEXT(s, ths_service_link);
+ if (s->ths_channel == ch)
+ service_remove_subscriber(t, s, reason);
+ }
+ }
+}
+
/* **************************************************************************
* Property updating
* *************************************************************************/
/**
*
*/
+static void subscription_reschedule(void);
static void subscription_unsubscribe_cb(void *aux);
/**
pthread_mutex_unlock(&t->s_stream_mutex);
}
+/**
+ *
+ */
+void
+subscription_delayed_reschedule(int64_t mono)
+{
+ mtimer_arm_rel(&subscription_reschedule_timer,
+ subscription_reschedule_cb, NULL, mono);
+}
+
/**
*
*/
/**
*
*/
-void
+static void
subscription_reschedule(void)
{
static int reenter = 0;
if (postpone <= 0 || postpone == INT_MAX)
postpone = 2;
- mtimer_arm_rel(&subscription_reschedule_timer,
- subscription_reschedule_cb, NULL, sec2mono(postpone));
-
+ subscription_delayed_reschedule(sec2mono(postpone));
reenter = 0;
}
if (s->ths_postpone_end > now && s->ths_postpone_end - now > postpone2)
s->ths_postpone_end = now + postpone2;
}
- mtimer_arm_rel(&subscription_reschedule_timer,
- subscription_reschedule_cb, NULL, 0);
+ subscription_delayed_reschedule(0);
}
- pthread_mutex_unlock(&global_lock);
+ pthread_mutex_unlock(&global_lock);
return postpone;
}
th_subscription_t *s = opaque;
if (sm->sm_type == SMT_STOP && subgetstate(s) != SUBSCRIPTION_ZOMBIE) {
LIST_INSERT_HEAD(&subscriptions_remove, s, ths_remove_link);
- mtimer_arm_rel(&subscription_reschedule_timer,
- subscription_reschedule_cb, NULL, 0);
+ subscription_delayed_reschedule(0);
}
streaming_msg_free(sm);
(s->ths_flags & SUBSCRIPTION_ONESHOT) != 0)
subscription_destroy(s);
- mtimer_arm_rel(&subscription_reschedule_timer,
- subscription_reschedule_cb, NULL, 0);
+ subscription_delayed_reschedule(0);
notify_reload("subscriptions");
}
LIST_INSERT_SORTED(&subscriptions, s, ths_global_link, subscription_sort);
- mtimer_arm_rel(&subscription_reschedule_timer,
- subscription_reschedule_cb, NULL, 0);
+ subscription_delayed_reschedule(0);
notify_reload("subscriptions");
return s;
subscription_link_service(s, si->si_s);
subscription_show_info(s);
} else {
- mtimer_arm_rel(&subscription_reschedule_timer,
- subscription_reschedule_cb, NULL, 0);
+ subscription_delayed_reschedule(0);
}
return s;
}
LIST_INSERT_SORTED(&subscriptions, s, ths_global_link, subscription_sort);
- mtimer_arm_rel(&subscription_reschedule_timer,
- subscription_reschedule_cb, NULL, 0);
+ subscription_delayed_reschedule(0);
}
/**