Re: [PATCH v10 11/20] index-helper: use watchman to avoid refreshing index with lstat()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2016-05-13 at 00:10 +0100, Ramsay Jones wrote:
> 
> On 12/05/16 21:20, David Turner wrote:
> > From: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
> [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.  

> > +		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*.

> I haven't tried this yet BTW, just reading patches as they float
> on past... ;-)
> 
> ATB,
> Ramsay Jones
> 
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]