<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">Hello Systemd developers!<div><br><div><blockquote type="cite"><div dir="ltr"><div>I asked this question earlier but I haven’t gotten any reply so I thought asking again.</div></div></blockquote><br><blockquote type="cite"><div dir="ltr"><div>Question regarding sd_bus_add_match (sd-bus.c):<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>Is there any bad consequences to use the same callback for multiple signal match and then using the userdata parameter to distinguish among the different signals? See the sample code below for a reference of what I am trying to do.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>/*Beginning=========================================*/<br>int callback(sd_bus_message *message, void *userdata, sd_bus_error *error) {</div><div> //there should be a lock applied here?<br> if(get_signal_id(userdata) == 1) {<br> //do something<br> }<br>}<br><br>int main(...) {<br> r = sd_bus_add_match(bus, &slot, "type='signal'", test_callback, userdata);<br> int r;<br> sd_bus *bus = NULL;<br> sd_event *event = NULL;<br> sd_bus_slot *slot = NULL;<br><br> r = sd_bus_default_system(&bus);<br> assert(r >= 0);<br><br> r = sd_event_default(&event);<br> assert(r >= 0);<br><br> void *userdata1 = set_signal_id(1);<br> r = sd_bus_add_match(bus, &slot, "type='signal',interface='org.interface2'", callback, userdata1);<br><br> void *userdata2 = set_signal_id(2);<br> r = sd_bus_add_match(bus, &slot, "type='signal',interface='org.interface1'", callback, userdata2);<br><br> r = sd_event_loop(event);<br> assert(r >= 0);</div><div> </div><div> bus = sd_bus_flush_close_unref(bus);<br> slot = sd_bus_slot_unref(slot);<br> event = sd_event_unref(event);<br>}</div><div><br data-mce-bogus="1"></div><div>/*End =========================================*/</div><div><br data-mce-bogus="1"></div><div>I appreciate your help and your time.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>Thank you,<br data-mce-bogus="1"></div><div>David J (<a href="mailto:emacsd@icloud.com">emacsd@icloud.com</a>)<br data-mce-bogus="1"></div></div></blockquote></div><div><div dir="ltr"><div><br></div></div></div></div></body></html>