git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v4 4/9] index-helper: new daemon for caching index and related stuff

From
David Turner <dturner@twopensource.com>
Date
Nov 2, 2015, 22:14 UTC
Message-ID
<1446502451.4131.26.camel@twopensource.com>
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:
Show 9 quoted lines
> +	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.

Show 13 quoted lines
> +#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.
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 6 of 12 in “Reduce index load time”
  1. 0/9 Reduce index load timeNguyễn Thái Ngọc Duy, Nov 1, 2015
  2. 1/9 trace.c: add GIT_TRACE_PACK_STATS for pack usage statisticsNguyễn Thái Ngọc Duy, Nov 1, 2015
  3. 2/9 read-cache.c: fix constness of verify_hdr()Nguyễn Thái Ngọc Duy, Nov 1, 2015
  4. 3/9 read-cache: allow to keep mmap'd memory after readingNguyễn Thái Ngọc Duy, Nov 1, 2015
  5. 4/9 index-helper: new daemon for caching index and related stuffNguyễn Thái Ngọc Duy, Nov 1, 2015
  6. David TurnerNov 2, 2015
  7. 5/9 trace.c: add GIT_TRACE_INDEX_STATS for index statisticsNguyễn Thái Ngọc Duy, Nov 1, 2015
  8. 6/9 index-helper: add --strictNguyễn Thái Ngọc Duy, Nov 1, 2015
  9. 7/9 daemonize(): set a flag before exiting the main processNguyễn Thái Ngọc Duy, Nov 1, 2015
  10. 8/9 index-helper: add --detachNguyễn Thái Ngọc Duy, Nov 1, 2015
  11. 9/9 index-helper: add Windows supportNguyễn Thái Ngọc Duy, Nov 1, 2015
  12. Johannes SchindelinNov 16, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.