From 895bb0f2ce317cee72a33004286eb66ffc253304 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 25 Nov 2009 19:53:26 +0100 Subject: [PATCH] src/main.c: Let ros_connect fail if logging in returns an error. --- src/main.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 82e8c7f..a941750 100644 --- a/src/main.c +++ b/src/main.c @@ -638,7 +638,13 @@ static int login2_handler (ros_connection_t *c, const ros_reply_t *r, /* {{{ */ printf ("login2_handler has been called.\n"); reply_dump (r); - if (strcmp (r->status, "done") != 0) + if (strcmp (r->status, "trap") == 0) + { + ros_debug ("login2_handler: Logging in failed: %s.\n", + ros_reply_param_val_by_key (r, "message")); + return (EACCES); + } + else if (strcmp (r->status, "done") != 0) { ros_debug ("login2_handler: Unexpected status: %s.\n", r->status); return (EPROTO); @@ -797,6 +803,13 @@ ros_connection_t *ros_connect (const char *node, const char *service, /* {{{ */ status = ros_query (c, "/login", /* args num = */ 0, /* args = */ NULL, login_handler, &user_data); + if (status != 0) + { + ros_disconnect (c); + errno = status; + return (NULL); + } + return (c); } /* }}} ros_connection_t *ros_connect */ -- 2.11.0