Re: [PATCH v10 11/20] index-helper: use watchman to avoid refreshing index with lstat()
- From
David Turner <dturner@twopensource.com>
- Date
- May 13, 2016, 17:47 UTC
- Message-ID
- <1463161645.24478.59.camel@twopensource.com>
- In-Reply-To
- <57350D7F.5030006@ramsayjones.plus.com>
On Fri, 2016-05-13 at 00:10 +0100, Ramsay Jones wrote:
Show 43 quoted lines
>
> On 12/05/16 21:20, David Turner wrote:
> > From: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> [snip]
>
> >
> > +/* 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.]Thanks for the report. I'll fix it.
I'm going to just send the requested_capabilities regardless of whether they are empty -- it won't hurt.
Show 6 quoted lines
> > + return -1; > > + if (packet_flush_gently(fd)) > > + return -1; > > Why are you sending a flush packet - doesn't the index-helper > simply ignore it?
It's not the packet that I'm excited about -- it's that later, packet_write might be buffered (according to a docstring). So I want to ensure that the writes actually go out *now*.
Show 6 quoted lines
> I haven't tried this yet BTW, just reading patches as they float > on past... ;-) > > ATB, > Ramsay Jones >