diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-02-22 14:29:32 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-02-22 14:29:32 +0200 |
commit | f09763f6b6e1e84ea9968457e6cc3e7af5360671 (patch) | |
tree | 39c0539d963d3553e4103bead25f22bd8a367f31 | |
parent | 97d84293615048b936d35250c89b21259acdb18f (diff) | |
download | wydawca-f09763f6b6e1e84ea9968457e6cc3e7af5360671.tar.gz wydawca-f09763f6b6e1e84ea9968457e6cc3e7af5360671.tar.bz2 |
Remove sendfile support
-rw-r--r-- | configure.ac | 22 | ||||
-rw-r--r-- | doc/wydawca.texi | 33 | ||||
-rw-r--r-- | src/config.c | 3 | ||||
-rw-r--r-- | src/diskio.c | 126 | ||||
-rw-r--r-- | src/update-2.0.awk | 2 | ||||
-rw-r--r-- | src/wydawca.c | 1 | ||||
-rw-r--r-- | src/wydawca.h | 1 |
7 files changed, 46 insertions, 142 deletions
diff --git a/configure.ac b/configure.ac index 50ed38a..ee58f84 100644 --- a/configure.ac +++ b/configure.ac @@ -33,7 +33,7 @@ AC_PROG_RANLIB # Checks for header files. AC_HEADER_STDC AC_HEADER_SYS_WAIT -AC_CHECK_HEADERS([stdlib.h string.h sys/file.h unistd.h sys/sendfile.h]) +AC_CHECK_HEADERS([stdlib.h string.h sys/file.h unistd.h]) # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST @@ -52,26 +52,6 @@ AC_FUNC_STAT AC_FUNC_VPRINTF AC_CHECK_FUNCS([memset strchr strdup strerror strrchr setegid setregid setresgid seteuid setreuid vsyslog sysconf getdtablesize]) -# *********************************** -# Sendfile -# *********************************** -AC_ARG_ENABLE([sendfile], - [AC_HELP_STRING([--enable-sendfile], - [Attempt to use sendfile(2) when possible])], - [case $enableval in - yes) USE_SENDFILE=1;; - no) USE_SENDFILE=0;; - *) AC_MSG_FAILURE([Invalid argument for --enable-sendfile]) - esac], - [USE_SENDFILE=0]) - -if test "$USE_SENDFILE" = 1; then - case $host in - *-linux-*) AC_DEFINE_UNQUOTED([USE_SENDFILE], 1, - [Define to 1 to use sendfile(2) on GNU/Linux]);; - esac -fi - # ********************** # Mailutils # ********************** diff --git a/doc/wydawca.texi b/doc/wydawca.texi index 876a8fa..ad274b2 100644 --- a/doc/wydawca.texi +++ b/doc/wydawca.texi @@ -94,7 +94,6 @@ How to Configure @command{wydawca}. * syslog:: * sql:: * access methods:: -* copying:: * archivation:: * directory pairs:: * statistics:: @@ -388,7 +387,6 @@ configuration on a step-by-step basis. * syslog:: * sql:: * access methods:: -* copying:: * archivation:: * directory pairs:: * statistics:: @@ -736,37 +734,6 @@ verify-user sql default SELECT user.user_name \ @end smallexample @end deffn -@node copying -@section Copying -@cindex sendfile -@cindex Invalid value, warning message -@cindex Function not implemented, warning message -@UNREVISED -If compiled for GNU/Linux, @command{wydawca} tries to optimize disk -transfer operations by using @code{sendfile} system call. If it -fails, and the error is recoverable, @command{wydawca} falls back to -copying files using user space. This is indicated by one of the following -warning messages: - -@smallexample - sendfile: copying @var{source} to @var{dest} failed: Invalid value - - sendfile: copying @var{source} to @var{dest} failed: Function not - implemented -@end smallexample - -@kwindex enable-sendfile - If you encounter any of these, disable @code{sendfile} by adding the -following to your configuration file: - -@smallexample -enable-sendfile no -@end smallexample - - In particular, you need to disable sendfile when compiling -@command{wydawca} for Linux kernels starting from version 2.6.9 and -higher. - @node archivation @section Archivation @cindex archivation, defined diff --git a/src/config.c b/src/config.c index c4f50b2..dd444fe 100644 --- a/src/config.c +++ b/src/config.c @@ -1240,9 +1240,6 @@ static struct gconf_keyword wydawca_kw[] = { { "from-address", N_("email"), N_("Set sender email address"), gconf_type_string, &from_address, 0, cb_email_address }, - { "enable-sendfile", N_("arg"), N_("Enable or disable sendfile(2) support"), - gconf_type_bool, &enable_sendfile }, - /* FIXME: Must be a built-in type? */ { "file-sweep-time", N_("interval"), N_("Define file sweep time"), gconf_type_string, &file_sweep_time, 0, cb_interval }, diff --git a/src/diskio.c b/src/diskio.c index 9df7a1a..6e75ccd 100644 --- a/src/diskio.c +++ b/src/diskio.c @@ -16,13 +16,6 @@ #include "wydawca.h" #include "save-cwd.h" -#if defined USE_SENDFILE -# if defined __linux__ && defined HAVE_SYS_SENDFILE_H -# include <sys/sendfile.h> -# else -# undef USE_SENDFILE -# endif -#endif /* Return true if ARG is NULL or is a sub-directory of DIR */ int @@ -137,15 +130,17 @@ create_directory (const char *base, const char *name, uid_t uid, gid_t gid) } -/* Copy FILE to DST_FILE, creating the latter with owner UID and GID. - Prefer sendfile(2), if available. Otherwise use plain old approach. */ +/* Copy FILE to DST_FILE, creating the latter with owner UID and GID. */ int copy_file (const char *file, const char *dst_file, uid_t uid, gid_t gid) { int in_fd, out_fd; struct stat st; - enum { copy_ok, copy_fallback, copy_failed } rc = copy_fallback; - + int rc; + char *buf; + size_t bufsize; + size_t fsize; + in_fd = open (file, O_RDONLY); if (in_fd == -1) @@ -172,87 +167,52 @@ copy_file (const char *file, const char *dst_file, uid_t uid, gid_t gid) return 1; } -#ifdef USE_SENDFILE - if (enable_sendfile) + buf = NULL; + fsize = st.st_size; + + for (bufsize = fsize; bufsize > 0 && (buf = malloc (bufsize)) == NULL; + bufsize /= 2) + ; + if (bufsize == 0) + xalloc_die (); + + rc = 0; + while (fsize > 0) { - off_t offset = 0; - ssize_t count; + size_t rest; + size_t rdbytes; - count = sendfile (out_fd, in_fd, &offset, st.st_size); - if (count == -1) + rest = fsize > bufsize ? bufsize : fsize; + rdbytes = read (in_fd, buf, rest); + if (rdbytes == -1) { - if (errno == EINVAL || errno == ENOSYS) - rc = copy_fallback; - else - rc = copy_failed; - logmsg ((rc == copy_fallback) ? LOG_WARNING : LOG_ERR, - "sendfile: copying %s to %s failed: %s", - file, dst_file, strerror (errno)); + logmsg (LOG_ERR, "unexpected error reading %s: %s", + file, strerror (errno)); + rc = 1; + break; } - else if (count < st.st_size) + rest = write (out_fd, buf, rdbytes); + if (rest == -1) { - rc = copy_failed; - logmsg (LOG_ERR, "copying %s to %s failed: short write", - file, dst_file); + logmsg (LOG_ERR, "unexpected error writing to %s: %s", + dst_file, strerror (errno)); + rc = 1; + break; } - else - rc = copy_ok; - } - - if (rc == copy_fallback) -#endif - { - char *buf = NULL; - size_t bufsize; - size_t fsize = st.st_size; - - for (bufsize = fsize; bufsize > 0 && (buf = malloc (bufsize)) == NULL; - bufsize /= 2) - ; - if (bufsize == 0) - xalloc_die (); - - rc = copy_ok; - while (fsize > 0) - { - size_t rest; - size_t rdbytes; - - rest = fsize > bufsize ? bufsize : fsize; - rdbytes = read (in_fd, buf, rest); - if (rdbytes == -1) - { - logmsg (LOG_ERR, "unexpected error reading %s: %s", - file, strerror (errno)); - rc = copy_failed; - break; - } - rest = write (out_fd, buf, rdbytes); - if (rest == -1) - { - logmsg (LOG_ERR, "unexpected error writing to %s: %s", - dst_file, strerror (errno)); - rc = copy_failed; - break; - } - else if (rest != rdbytes) - { - logmsg (LOG_ERR, "short write on %s", dst_file); - rc = copy_failed; - } - fsize -= rdbytes; - } - free (buf); - } + else if (rest != rdbytes) + { + logmsg (LOG_ERR, "short write on %s", dst_file); + rc = 1; + } + fsize -= rdbytes; + } + free (buf); close (in_fd); close (out_fd); - if (rc != copy_ok) - { - unlink (dst_file); - return 1; - } - return 0; + if (rc) + unlink (dst_file); + return rc; } /* Move FILE to DST_FILE. If they reside on different devices, use copy_file diff --git a/src/update-2.0.awk b/src/update-2.0.awk index 3027275..7dfb7cd 100644 --- a/src/update-2.0.awk +++ b/src/update-2.0.awk @@ -59,6 +59,8 @@ function indent(len) { printf(" ") } +$1 == "enable-sendfile" { next } + $1 == "file-sweep-time" || $1 == "tar-program" || $1 == "admin-address" || $1 == "from-address" || $1 == "host" || $1 == "database" || $1 == "user" || $1 == "password" || diff --git a/src/wydawca.c b/src/wydawca.c index b95446c..2eb8fa2 100644 --- a/src/wydawca.c +++ b/src/wydawca.c @@ -29,7 +29,6 @@ int syslog_include_prio; /* syslog messages include priority */ unsigned long print_stats; /* Print final statistics output */ time_t file_sweep_time = 0; char *tar_command_name = "tar"; -int enable_sendfile = 1; /* Use sendfile by default */ int archive_signatures = 1; /* Archive sig files by default */ int lint_mode = 0; int preprocess_only = 0; diff --git a/src/wydawca.h b/src/wydawca.h index 948b609..eb420d0 100644 --- a/src/wydawca.h +++ b/src/wydawca.h @@ -302,7 +302,6 @@ extern time_t file_sweep_time; /* Unlink stale file after this amount of time extern char *tar_command_name; /* Name of the tar command */ extern unsigned wydawca_stat[MAX_STAT]; extern unsigned long print_stats; -extern int enable_sendfile; extern int archive_signatures; extern char *admin_stat_message; |