myserver-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myserver-commit] [3091] While copying a file, use the `posix_fallocate


From: Giuseppe Scrivano
Subject: [myserver-commit] [3091] While copying a file, use the `posix_fallocate () system call if it is available.
Date: Fri, 22 May 2009 20:21:32 +0000

Revision: 3091
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3091
Author:   gscrivano
Date:     2009-05-22 20:21:30 +0000 (Fri, 22 May 2009)
Log Message:
-----------
While copying a file, use the `posix_fallocate () system call if it is 
available.

Modified Paths:
--------------
    trunk/myserver/configure.in
    trunk/myserver/src/base/file/files_utility.cpp

Modified: trunk/myserver/configure.in
===================================================================
--- trunk/myserver/configure.in 2009-05-22 20:21:23 UTC (rev 3090)
+++ trunk/myserver/configure.in 2009-05-22 20:21:30 UTC (rev 3091)
@@ -94,6 +94,8 @@
 
 AC_CHECK_FUNCS(pipe, AC_DEFINE(PIPE, 1, [Define if the pipe function is 
present]) )
 
+AC_CHECK_FUNCS(posix_fallocate, AC_DEFINE(POSIX_FALLOCATE, 1, [Define if the 
posix_fallocate function is present]) )
+
 AC_CHECK_FUNCS(snprintf, AC_DEFINE(SNPRINTF, 1, [Define if the snprintf 
function is present]) )
 
 AC_CHECK_FUNCS(getpwnam, AC_DEFINE(GETPWNAM, 1, [Define if the getpwnam 
function is present]) )

Modified: trunk/myserver/src/base/file/files_utility.cpp
===================================================================
--- trunk/myserver/src/base/file/files_utility.cpp      2009-05-22 20:21:23 UTC 
(rev 3090)
+++ trunk/myserver/src/base/file/files_utility.cpp      2009-05-22 20:21:30 UTC 
(rev 3091)
@@ -193,6 +193,12 @@
   u_long nbr, nbw;
   int ret;
 
+#ifdef HAVE_POSIX_FALLOCATE
+  if (posix_fallocate (dest.getHandle (), dest.getSeek (),
+                       src.getFileSize () - src.getSeek ()))
+    return -1;
+#endif
+
   for (;;) 
   {
     ret = src.read (buffer, 4096, &nbr);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]