summaryrefslogtreecommitdiff
path: root/src/or/control.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-04-02 22:02:13 +0000
committerNick Mathewson <nickm@torproject.org>2005-04-02 22:02:13 +0000
commit4a90d3722969f6b0c8b7a4507af0889594fbed13 (patch)
tree947f458dfa1782f2e20271e7f730a79533da07db /src/or/control.c
parenta1397b2d045b9efc05a8e2fa869a32b23074075c (diff)
downloadtor-4a90d3722969f6b0c8b7a4507af0889594fbed13.tar.gz
tor-4a90d3722969f6b0c8b7a4507af0889594fbed13.zip
Better messages when POSTDESCRIPTOR fails
svn:r3989
Diffstat (limited to 'src/or/control.c')
-rw-r--r--src/or/control.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/or/control.c b/src/or/control.c
index b59940734e..1fc0f7017a 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -230,6 +230,8 @@ send_control_done(connection_t *conn)
static void send_control_done2(connection_t *conn, const char *msg, size_t len)
{
+ if (len==0)
+ len = strlen(msg);
send_control_message(conn, CONTROL_CMD_DONE, len, msg);
}
@@ -760,10 +762,16 @@ static int
handle_control_postdescriptor(connection_t *conn, uint32_t len,
const char *body)
{
- if (router_load_single_router(body)<0) {
- /* XXXX a more specific error would be nice. */
- send_control_error(conn,ERR_UNSPECIFIED,
- "Could not parse descriptor or add it");
+ const char *msg;
+ switch (router_load_single_router(body, &msg)) {
+ case -1:
+ send_control_error(conn,ERR_SYNTAX,msg?msg: "Could not parse descriptor");
+ break;
+ case 0:
+ send_control_done2(conn,msg?msg: "Descriptor not added",0);
+ break;
+ case 1:
+ send_control_done(conn);
return 0;
}