Re: [PATCH v3 03/16] index-helper: new daemon for caching index and related stuff
From: David Turner <hidden>
Date: 2016-06-16 02:18:43
On Fri, 2016-04-08 at 18:26 +0700, Duy Nguyen wrote:
On Thu, Apr 7, 2016 at 5:11 AM, David Turner < dturner@twopensource.com> wrote:quoted
@@ -1045,4 +1046,21 @@ struct tm *git_gmtime_r(const time_t *,struct tm *); #define getc_unlocked(fh) getc(fh) #endif +#ifdef __linux__ +#define UNIX_PATH_MAX 108 +#elif defined(__APPLE__) || defined(BSD) +#define UNIX_PATH_MAX 104 +#else +/* + * Quoth POSIX: The size of sun_path has intentionally been left + * undefined. This is because different implementations use different + * sizes. For example, 4.3 BSD uses a size of 108, and 4.4 BSD uses a + * size of 104. Since most implementations originate from BSD + * versions, the size is typically in the range 92 to 108. + * + * Thanks, POSIX! Super-helpful! Hope we don't overflow any buffers! + */ +#define UNIX_PATH_MAX 92 +#endifOkay. You probably want to fix unix-socket.c too, and maybe reuse that code instead of opening unix sockets manually. There's a check in unix_sockaddr_init() about sizeof(sun_path) but I'm not sure if it suffices. BTW, it looks like you tested this on Mac. But config.mak.uname only enables HAVE_SHM on Linux. Should it be enabled on Mac as well at least?
I did not in fact test on Mac. I should have. And indeed I need to change config.mak.uname. Also I was leaking some memory. And had some whiny warnings. And had a bug around how non-blocking sockets work on Mac. And SHM on Macs works a bit differently than on Linux in at least two irritating ways. So, uh, new version to come once I actually make it work on Mac. Probably Monday.