On Tue, May 13, 2014 at 1:15 PM, Nguyễn Thái Ngọc Duy <pclo...@gmail.com> wrote:
> diff --git a/Makefile b/Makefile
> index 028749b..98d22de 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1502,6 +1502,12 @@ ifdef HAVE_DEV_TTY
>         BASIC_CFLAGS += -DHAVE_DEV_TTY
>  endif
>
> +ifdef HAVE_SHM
> +       BASIC_CFLAGS += -DHAVE_SHM
> +       EXTLIBS += -lrt
> +       PROGRAM_OBJS += read-cache--daemon.o
> +endif
> +

I think read-cache--daemon will fail in case of NO_UNIX_SOCKETS.

But, read-cache--daemon.c only gets compiled if we have shm_open...

> diff --git a/git-compat-util.h b/git-compat-util.h
> index f6d3a46..b2116ab 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -723,4 +723,12 @@ struct tm *git_gmtime_r(const time_t *, struct tm *);
>  #define gmtime_r git_gmtime_r
>  #endif
>
> +#ifndef HAVE_SHM
> +static inline int shm_open(const char *path, int flags, int mode)
> +{
> +       errno = ENOSYS;
> +       return -1;
> +}
> +#endif


...yet, you introduce a compatibility-shim...

> diff --git a/read-cache--daemon.c b/read-cache--daemon.c
> new file mode 100644
> index 0000000..52b4067
> --- /dev/null
> +++ b/read-cache--daemon.c
> @@ -0,0 +1,167 @@
> +#include "cache.h"
> +#include "sigchain.h"
> +#include "unix-socket.h"
> +#include "split-index.h"
> +#include "pkt-line.h"
> +
> +static char *socket_path;
> +static struct strbuf shm_index = STRBUF_INIT;
> +static struct strbuf shm_sharedindex = STRBUF_INIT;
> +
> +static void cleanup_socket(void)
> +{
> +       if (socket_path)
> +               unlink(socket_path);
> +       if (shm_index.len)
> +               shm_unlink(shm_index.buf);
> +       if (shm_sharedindex.len)
> +               shm_unlink(shm_sharedindex.buf);
> +}
> +
> +static void cleanup_socket_on_signal(int sig)
> +{
> +       cleanup_socket();
> +       sigchain_pop(sig);
> +       raise(sig);
> +}
> +
> +static void share_index(struct index_state *istate, struct strbuf *shm_path)
> +{
> +       struct strbuf sb = STRBUF_INIT;
> +       void *map;
> +       int fd;
> +
> +       strbuf_addf(&sb, "/git-index-%s", sha1_to_hex(istate->sha1));
> +       if (shm_path->len && strcmp(sb.buf, shm_path->buf)) {
> +               shm_unlink(shm_path->buf);
> +               strbuf_reset(shm_path);
> +       }
> +       fd = shm_open(sb.buf, O_RDWR | O_CREAT | O_TRUNC, 0700);
> +       if (fd < 0)
> +               return;

...that only gets called from read-cache--daemon.c, which already only
gets compiled if we have open?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to