]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-master: Remove code for retrying interrupted config read()s
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 29 Nov 2022 17:32:41 +0000 (19:32 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 27 Jan 2023 13:01:47 +0000 (13:01 +0000)
This hasn't been working for a long time now. The fd is blocking, so
i_stream_read() returns -1 for it instead of 0 on EINTR. There's
really not supposed to be any signals happening during config reading
anyway (other than SIGALRM timeout, in which case we want to abort the
read instead of retry).

src/lib-master/master-service-settings.c

index d09dec38b24a56f3b371e442ed75242a9306bc5a..5e8a72b19254bfb83475c8bee3a67a4de262a75c 100644 (file)
@@ -455,8 +455,7 @@ config_read_reply_header(struct istream *istream, const char *path, pool_t pool,
                        break;
        }
        if (ret <= 0) {
-               if (ret == 0)
-                       return 1;
+               i_assert(ret < 0);
                *error_r = istream->stream_errno != 0 ?
                        t_strdup_printf("read(%s) failed: %s", path,
                                        i_stream_get_error(istream)) :
@@ -574,7 +573,6 @@ int master_service_settings_read(struct master_service *service,
        const char *path = NULL, *error;
        unsigned int i;
        int ret, fd = -1;
-       time_t now, timeout;
        bool use_environment, retry;
 
        i_zero(output_r);
@@ -633,36 +631,21 @@ int master_service_settings_read(struct master_service *service,
 
        if (fd != -1) {
                istream = i_stream_create_fd(fd, SIZE_MAX);
-               now = time(NULL);
-               timeout = now + CONFIG_READ_TIMEOUT_SECS;
-               do {
-                       alarm(timeout - now);
-                       ret = config_read_reply_header(istream, path,
-                                                      service->set_pool, input,
-                                                      output_r, error_r);
-                       if (ret == 0) {
-                               ret = settings_parse_stream_read(parser,
-                                                                istream);
-                               if (ret < 0)
-                                       *error_r = t_strdup(
-                                               settings_parser_get_error(parser));
-                       }
-                       alarm(0);
-                       if (ret <= 0)
-                               break;
-
-                       /* most likely timed out, but just in case some other
-                          signal was delivered early check if we need to
-                          continue */
-                       now = time(NULL);
-               } while (now < timeout);
+               alarm(CONFIG_READ_TIMEOUT_SECS);
+               ret = config_read_reply_header(istream, path,
+                                              service->set_pool, input,
+                                              output_r, error_r);
+               if (ret == 0) {
+                       ret = settings_parse_stream_read(parser, istream);
+                       i_assert(ret <= 0);
+                       if (ret < 0)
+                               *error_r = t_strdup(
+                                       settings_parser_get_error(parser));
+               }
+               alarm(0);
                i_stream_unref(&istream);
 
-               if (ret != 0) {
-                       if (ret > 0) {
-                               *error_r = t_strdup_printf(
-                                       "Timeout reading config from %s", path);
-                       }
+               if (ret < 0) {
                        i_close_fd(&fd);
                        config_exec_fallback(service, input, error_r);
                        settings_parser_unref(&parser);