mapper: Handle the expected GetSubTreePaths fails
The 'mapper subtree-remove' command calls GetSubTreePaths
when it starts up to check if a certain interface currently
exists on a certain path. If that interface does not exist
on that path, the current ObjectMapper implementation would
just return an empty list, and the program would exit.
The new ObjectMapper implementation will fail the GetSubTreePaths
call in that case, causing an ENXIO inside of sd_event_loop().
This commit checks for the ENXIO and then just exits immediately
with a return code of 0, as this is the case where the interface
had been removed before the program was started.
Change-Id: Iaeb908ee9a0db8952ef77cc63675e0f7abe3b6c7
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/libmapper/app.c b/libmapper/app.c
index 14d8ab0..9ead753 100644
--- a/libmapper/app.c
+++ b/libmapper/app.c
@@ -15,6 +15,7 @@
*/
#include "config.h"
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <systemd/sd-bus.h>
@@ -147,8 +148,19 @@
r = sd_event_loop(loop);
if (r < 0)
{
- fprintf(stderr, "Error starting event loop: %s\n", strerror(-r));
- goto finish;
+ /* If this function has been called after the interface in */
+ /* question has already been removed, then GetSubTree will */
+ /* fail and it will show up here. Treat as success instead. */
+ if (r == -ENXIO)
+ {
+ r = 0;
+ }
+ else
+ {
+ fprintf(stderr, "Error starting event loop: %d(%s)\n", r,
+ strerror(-r));
+ goto finish;
+ }
}
finish: