+void on_no_clients(std::shared_ptr<low_can_subscription_t> can_subscription, std::map<int, std::shared_ptr<low_can_subscription_t> >& s)
+{
+ auto it = s.find(can_subscription->get_index());
+ s.erase(it);
+}
+
+int read_message(sd_event_source *event_source, int fd, uint32_t revents, void *userdata)
+{
+
+ low_can_subscription_t* can_subscription = (low_can_subscription_t*)userdata;
+
+
+ if ((revents & EPOLLIN) != 0)
+ {
+ utils::signals_manager_t& sm = utils::signals_manager_t::instance();
+ std::lock_guard<std::mutex> subscribed_signals_lock(sm.get_subscribed_signals_mutex());
+ if(can_subscription->get_index() != -1)
+ {
+ std::shared_ptr<utils::socketcan_t> s = can_subscription->get_socket();
+ if(s->socket() && s->socket() != -1)
+ {
+ std::shared_ptr<message_t> message = s->read_message();
+
+ // Sure we got a valid CAN message ?
+ if (! message->get_id() == 0 && ! message->get_length() == 0 && message->get_flags() & INVALID_FLAG)
+ push_n_notify(message);
+ }
+ }
+ }
+
+ // check if error or hangup
+ if ((revents & (EPOLLERR|EPOLLRDHUP|EPOLLHUP)) != 0)
+ {
+ sd_event_source_unref(event_source);
+ can_subscription->get_socket()->close();