Make sure that we don't try to use iconv() without iconv.h.
[rsync/rsync.git] / main.c
diff --git a/main.c b/main.c
index 58ea8b0..e8b5efd 100644 (file)
--- a/main.c
+++ b/main.c
@@ -68,8 +68,12 @@ struct file_list *the_file_list;
  * but set it higher, just in case. */
 #define MAXCHILDPROCS 7
 
-#if defined HAVE_SIGACTION && defined HAVE_SIGPROCMASK
-#define SIGACTMASK(n,h) SIGACTION(n,h), sigaddset(&sigmask,(n))
+#ifdef HAVE_SIGACTION
+# ifdef HAVE_SIGPROCMASK
+#  define SIGACTMASK(n,h) SIGACTION(n,h), sigaddset(&sigmask,(n))
+# else
+#  define SIGACTMASK(n,h) SIGACTION(n,h)
+# endif
 static struct sigaction sigact;
 #endif
 
@@ -788,6 +792,9 @@ void start_server(int f_in, int f_out, int argc, char *argv[])
 
        io_set_sock_fds(f_in, f_out);
        setup_protocol(f_out, f_in);
+#if defined HAVE_ICONV_OPEN && defined HAVE_ICONV_H
+       setup_iconv();
+#endif
 
        if (protocol_version >= 23)
                io_start_multiplex_out();
@@ -824,6 +831,9 @@ int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[])
 
        io_set_sock_fds(f_in, f_out);
        setup_protocol(f_out,f_in);
+#if defined HAVE_ICONV_OPEN && defined HAVE_ICONV_H
+       setup_iconv();
+#endif
 
        if (protocol_version >= 23 && !read_batch)
                io_start_multiplex_in();
@@ -1104,7 +1114,7 @@ static RETSIGTYPE sigchld_handler(UNUSED(int val))
                }
        }
 #endif
-#if !defined HAVE_SIGACTION && !defined HAVE_SIGPROCMASK
+#ifndef HAVE_SIGACTION
        signal(SIGCHLD, sigchld_handler);
 #endif
 }
@@ -1166,10 +1176,12 @@ int main(int argc,char *argv[])
        int ret;
        int orig_argc = argc;
        char **orig_argv = argv;
-#if defined HAVE_SIGACTION && defined HAVE_SIGPROCMASK
+#ifdef HAVE_SIGACTION
+# ifdef HAVE_SIGPROCMASK
        sigset_t sigmask;
 
        sigemptyset(&sigmask);
+# endif
        sigact.sa_flags = SA_NOCLDSTOP;
 #endif
        SIGACTMASK(SIGUSR1, sigusr1_handler);