Mercurial > dovecot > core-2.2
diff src/config/config-connection.c @ 9793:d7ccdbb58a03 HEAD
config: If master module requests configuration, reread it before replying.
If new configuration is invalid, send an ERROR reply back.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 14 Aug 2009 18:13:35 -0400 |
parents | 04cade277134 |
children | e95135898a3c |
line wrap: on
line diff
--- a/src/config/config-connection.c Fri Aug 14 17:36:27 2009 -0400 +++ b/src/config/config-connection.c Fri Aug 14 18:13:35 2009 -0400 @@ -7,6 +7,7 @@ #include "settings-parser.h" #include "master-service.h" #include "config-request.h" +#include "config-parser.h" #include "config-connection.h" #include <stdlib.h> @@ -61,11 +62,11 @@ o_stream_send_str(output, "\n"); } -static void config_connection_request(struct config_connection *conn, - const char *const *args) +static int config_connection_request(struct config_connection *conn, + const char *const *args) { struct config_filter filter; - const char *module = ""; + const char *path, *error, *module = ""; /* [<args>] */ memset(&filter, 0, sizeof(filter)); @@ -89,11 +90,23 @@ } } + if (strcmp(module, "master") == 0) { + /* master reads configuration only when reloading settings */ + path = master_service_get_config_path(master_service); + if (config_parse_file(path, TRUE, &error) < 0) { + o_stream_send_str(conn->output, + t_strconcat("ERROR ", error, "\n", NULL)); + config_connection_destroy(conn); + return -1; + } + } + o_stream_cork(conn->output); config_request_handle(&filter, module, 0, config_request_output, conn->output); o_stream_send_str(conn->output, "\n"); o_stream_uncork(conn->output); + return 0; } static void config_connection_input(void *context) @@ -130,8 +143,10 @@ while ((args = config_connection_next_line(conn)) != NULL) { if (args[0] == NULL) continue; - if (strcmp(args[0], "REQ") == 0) - config_connection_request(conn, args + 1); + if (strcmp(args[0], "REQ") == 0) { + if (config_connection_request(conn, args + 1) < 0) + break; + } } }