This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Tarantool -- an efficient key/value data store".

The branch master-stable has been updated
       via  25f75ec510400cfcd80924f2678b3be1d6b3997f (commit)
      from  a6c1f381f0254705bd12c2e42ab90dbcf0827982 (commit)

Summary of changes:
 core/log_io.c    |    4 +++-
 core/tarantool.c |   10 +++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

commit 25f75ec510400cfcd80924f2678b3be1d6b3997f
Author: Roman Tokarev <[email protected]>
Date:   Tue Mar 1 12:51:48 2011 +0300

    Fixes to compile on FreeBSD.
    
     - Replace strndrupa with alloca + memcpy.
     - In create_pid function do rewind before read from pid file.

diff --git a/core/log_io.c b/core/log_io.c
index b4f4f97..f41080d 100644
--- a/core/log_io.c
+++ b/core/log_io.c
@@ -576,7 +576,9 @@ inprogress_log_rename(char *filename)
        assert(strcmp(suffix, inprogress_suffix) == 0);
 
        /* Create a new filename without '.inprogress' suffix. */
-       new_filename = strndupa(filename, suffix - filename);
+       new_filename = alloca(suffix - filename + 1);
+       memcpy(new_filename, filename, suffix - filename);
+       new_filename[suffix - filename] = '\0';
 
        if (rename(filename, new_filename) != 0) {
                say_syserror("can't rename %s to %s", filename, new_filename);
diff --git a/core/tarantool.c b/core/tarantool.c
index 67c74a2..2ed0c9f 100644
--- a/core/tarantool.c
+++ b/core/tarantool.c
@@ -267,6 +267,13 @@ create_pid(void)
        f = fopen(cfg.pid_file, "a+");
        if (f == NULL)
                panic_syserror("can't open pid file");
+       /*
+        * fopen() is not guaranteed to set the seek position to
+        * the beginning of file according to ANSI C (and, e.g.,
+        * on FreeBSD.
+        */
+       if (fseeko(f, 0, SEEK_SET) != 0)
+               panic_syserror("can't fseek to the beginning of pid file");
 
        if (fgets(buf, sizeof(buf), f) != NULL && strlen(buf) > 0) {
                pid = strtol(buf, NULL, 10);
@@ -274,7 +281,8 @@ create_pid(void)
                        panic("the daemon is already running");
                else
                        say_info("updating a stale pid file");
-               fseeko(f, 0, SEEK_SET);
+               if (fseeko(f, 0, SEEK_SET) != 0)
+                       panic_syserror("can't fseek to the beginning of pid 
file");
                if (ftruncate(fileno(f), 0) == -1)
                        panic_syserror("ftruncate(`%s')", cfg.pid_file);
        }

-- 
Tarantool -- an efficient key/value data store

_______________________________________________
Mailing list: https://launchpad.net/~tarantool-developers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~tarantool-developers
More help   : https://help.launchpad.net/ListHelp

Reply via email to