Re: [PATCH v10 11/20] index-helper: use watchman to avoid refreshing index with lstat()
- From
Ramsay Jones <ramsay@ramsayjones.plus.com>
- Date
- May 12, 2016, 23:10 UTC
- Message-ID
- <57350D7F.5030006@ramsayjones.plus.com>
- In-Reply-To
- <1463084415-19826-12-git-send-email-dturner@twopensource.com>
On 12/05/16 21:20, David Turner wrote:
> From: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
[snip]
Show 22 quoted lines
>
> +/* in ms */
> +#define WATCHMAN_TIMEOUT 1000
> +
> +static int poke_and_wait_for_reply(int fd)
> +{
> + struct strbuf buf = STRBUF_INIT;
> + int ret = -1;
> + struct pollfd pollfd;
> + int bytes_read;
> + char reply_buf[4096];
> + const char *requested_capabilities = "";
> +
> +#ifdef USE_WATCHMAN
> + requested_capabilities = "watchman";
> +#endif
> +
> + if (fd < 0)
> + return -1;
> +
> + strbuf_addf(&buf, "poke %d %s", getpid(), requested_capabilities);
> + if (packet_write_gently(fd, buf.buf, buf.len))This is not causing a problem or bug, but is none the less not correct - as you know, packet_write_gently() takes a 'printf' like variable argument list. (So, buf.buf is the format specifier and buf.len is an unused arg).
I think I would write this as:
strbuf_addf(&buf, "poke %d", getpid()); if (requested_capabilities && *requested_capabilities) strbuf_addf(&buf, " %s", requested_capabilities); if (packet_write_gently(fd, "%s", buf.buf))
... or something similar. [Note, just typing into my email client, so it's not been close to a compiler.]
> + return -1; > + if (packet_flush_gently(fd)) > + return -1;
Why are you sending a flush packet - doesn't the index-helper simply ignore it?
I haven't tried this yet BTW, just reading patches as they float on past... ;-)
ATB, Ramsay Jones