All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Turner <dturner@twopensource.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org, Christian Couder <christian.couder@gmail.com>
Subject: Re: [PATCH v4 4/9] index-helper: new daemon for caching index and related stuff
Date: Mon, 02 Nov 2015 17:14:11 -0500	[thread overview]
Message-ID: <1446502451.4131.26.camel@twopensource.com> (raw)
In-Reply-To: <1446385369-8669-5-git-send-email-pclouds@gmail.com>

On Sun, 2015-11-01 at 14:42 +0100, Nguyễn Thái Ngọc Duy wrote:
> +	memcpy(new_mmap, istate->mmap, istate->mmap_size - 20);
> +
> +	/*
> +	 * The trailing hash must be written last after everything is
> +	 * written. It's the indication that the shared memory is now
> +	 * ready.
> +	 */
> +	hashcpy((unsigned char *)new_mmap + istate->mmap_size - 20, is->sha1);
> +}

You need a memory barrier here.  Otherwise, compilers may reorder these
statements.

> +#define SHM_PATH_LEN 72		/* we don't create very long paths.. */
> +
> +ssize_t git_shm_map(int oflag, int perm, ssize_t length, void **mmap,
> +		    int prot, int flags, const char *fmt, ...)
> +{
> +	va_list ap;
> +	char path[SHM_PATH_LEN];
> +	int fd;
> +
> +	path[0] = '/';
> +	va_start(ap, fmt);
> +	vsprintf(path + 1, fmt, ap);
> +	va_end(ap);

This would be safer with vsnprintf.

  reply	other threads:[~2015-11-02 22:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-01 13:42 [PATCH v4 0/9] Reduce index load time Nguyễn Thái Ngọc Duy
2015-11-01 13:42 ` [PATCH v4 1/9] trace.c: add GIT_TRACE_PACK_STATS for pack usage statistics Nguyễn Thái Ngọc Duy
2015-11-01 13:42 ` [PATCH v4 2/9] read-cache.c: fix constness of verify_hdr() Nguyễn Thái Ngọc Duy
2015-11-01 13:42 ` [PATCH v4 3/9] read-cache: allow to keep mmap'd memory after reading Nguyễn Thái Ngọc Duy
2015-11-01 13:42 ` [PATCH v4 4/9] index-helper: new daemon for caching index and related stuff Nguyễn Thái Ngọc Duy
2015-11-02 22:14   ` David Turner [this message]
2015-11-01 13:42 ` [PATCH v4 5/9] trace.c: add GIT_TRACE_INDEX_STATS for index statistics Nguyễn Thái Ngọc Duy
2015-11-01 13:42 ` [PATCH v4 6/9] index-helper: add --strict Nguyễn Thái Ngọc Duy
2015-11-01 13:42 ` [PATCH v4 7/9] daemonize(): set a flag before exiting the main process Nguyễn Thái Ngọc Duy
2015-11-01 13:42 ` [PATCH v4 8/9] index-helper: add --detach Nguyễn Thái Ngọc Duy
2015-11-01 13:42 ` [PATCH v4 9/9] index-helper: add Windows support Nguyễn Thái Ngọc Duy
2015-11-16 21:51 ` [PATCH v4 0/9] Reduce index load time Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1446502451.4131.26.camel@twopensource.com \
    --to=dturner@twopensource.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.