summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2018-09-24 09:46:00 -0500
committerMatt Spinler <spinler@us.ibm.com>2018-10-02 16:43:29 -0500
commit59cbf3461a761968cc6f9f93bb0d4efaaf17ecbe (patch)
tree3901286e434935dc05abe7ddc8b6a368deded6a9
parentf9a171812b6c4823e2b7aadafee0b3179eb52370 (diff)
downloadphosphor-objmgr-59cbf3461a761968cc6f9f93bb0d4efaaf17ecbe.tar.gz
phosphor-objmgr-59cbf3461a761968cc6f9f93bb0d4efaaf17ecbe.zip
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>
-rw-r--r--libmapper/app.c16
1 files changed, 14 insertions, 2 deletions
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 @@ static int subtree_main(int argc, char* argv[])
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:
OpenPOWER on IntegriCloud