aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ctl.c8
-rw-r--r--src/piesctl-cl.opt4
-rw-r--r--src/piesctl.c56
3 files changed, 56 insertions, 12 deletions
diff --git a/src/ctl.c b/src/ctl.c
index f7e46d0..676f93b 100644
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -1715,7 +1715,7 @@ static void
component_stop (struct ctlio *io, struct prog *prog)
{
if (prog->v.p.comp->flags & CF_DISABLED)
- ctlio_reply (io, 409, "already stopped");
+ ctlio_reply (io, 409, "Already stopped");
else
{
progman_stop_component (prog);
@@ -1727,15 +1727,15 @@ component_stop (struct ctlio *io, struct prog *prog)
static void
component_start (struct ctlio *io, struct prog *prog)
{
- if (!(prog->v.p.comp->flags & CF_DISABLED))
- ctlio_reply (io, 409, "already running");
- else
+ if (prog->v.p.comp->flags & CF_DISABLED)
{
prog->v.p.comp->flags &= ~CF_DISABLED;
prog->v.p.status = status_enabled;
kill (getpid (), SIGALRM);
ctlio_reply (io, 200, "Component started");
}
+ else
+ ctlio_reply (io, 409, "Already running");
}
static void
diff --git a/src/piesctl-cl.opt b/src/piesctl-cl.opt
index d026269..b8e4fc1 100644
--- a/src/piesctl-cl.opt
+++ b/src/piesctl-cl.opt
@@ -41,7 +41,7 @@ BEGIN
END
OPTION(,E,,
- [<preprocess config and exit>])
+ [<preprocess configuration files and exit>])
BEGIN
preprocess_only = 1;
END
@@ -53,7 +53,7 @@ BEGIN
END
OPTION(dump,d,,
- [<dump obtained responsed verbatim>])
+ [<dump obtained responses verbatim>])
BEGIN
++dump;
END
diff --git a/src/piesctl.c b/src/piesctl.c
index 3ae4af2..4319946 100644
--- a/src/piesctl.c
+++ b/src/piesctl.c
@@ -816,7 +816,8 @@ static void
shttp_fatal (struct shttp_connection *conn)
{
struct json_value *jv;
-
+ int status;
+
if (conn->result && (jv = json_value_lookup (conn->result, "error_message")))
{
if (jv->type == json_string)
@@ -827,7 +828,36 @@ shttp_fatal (struct shttp_connection *conn)
else
grecs_error (NULL, 0, "%s", conn->status_line[2]);
- exit (1);
+ switch (conn->resp.code)
+ {
+ case 400:
+ case 405:
+ case 501:
+ case 505:
+ grecs_error (NULL, 0, _("please report"));
+ status = EX_SOFTWARE;
+ break;
+
+ case 401:
+ status = EX_NOUSER;
+ break;
+
+ case 403:
+ status = EX_NOPERM;
+ break;
+
+ case 404:
+ status = EX_NOINPUT;
+ break;
+
+ default:
+ if (conn->resp.code >= 400 && conn->resp.code < 500)
+ status = EX_TEMPFAIL;
+ else
+ status = EX_UNAVAILABLE;
+ }
+
+ exit (status);
}
static void
@@ -930,12 +960,26 @@ shttp_process (struct shttp_connection *conn, int method, char const *uri)
shttp_get_reply (conn);
if (dump && conn->result)
shttp_format_result (conn, stdout);
+
if (conn->resp.code / 100 == 2)
return;
- if (conn->resp.code == 401 && isatty (fileno (stdin)))
- shttp_get_credentials (conn);
- else
- shttp_fatal (conn);
+
+ switch (conn->resp.code)
+ {
+ case 401:
+ if (isatty (fileno (stdin)))
+ shttp_get_credentials (conn);
+ else
+ shttp_fatal (conn);
+ break;
+
+ case 404: /* Not found */
+ case 409: /* Conflict */
+ return;
+
+ default:
+ shttp_fatal (conn);
+ }
}
}

Return to:

Send suggestions and report system problems to the System administrator.