{"thread":{"id":"23919","subject":"[PATCH 0/3] Interix support","startedAt":"2010-05-27T08:19:41Z","lastAt":"2010-05-31T13:10:18Z","messageCount":39,"participants":["Jonathan Callen","Sverre Rabbelier","Michael J Gruber","Jonathan Nieder","Erik Faye-Lund","Marko Kreen","Jeff King","Albert Dvornik","Peter Kjellerstedt","Jakub Narebski","Paolo Bonzini","Johannes Sixt","Joshua Juran"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"142403","messageId":"1274948384-167-1-git-send-email-abcd@gentoo.org","threadId":"23919","inReplyTo":null,"subject":"[PATCH 0/3] Interix support","fromName":"Jonathan Callen","fromEmail":"abcd@gentoo.org","sentAt":"2010-05-27T08:19:41Z","receivedAt":"2010-05-27T08:19:41Z","isPatch":true,"sender":{"key":"abcd@gentoo.org","avatar":null},"body":"This series of patches adds support for building git on Interix.\n\nInterix is an interesting system, as it lacks some functions that are\nnormally present on POSIX systems, such as poll().  As I did not have\ntime to implement poll() on top of select(), these patches simply\ndisable the three commands that require poll() to be present:\ngit-daemon, git-upload-archive, and git-upload-pack.\n\nJonathan Callen (3):\n      Support building on systems without poll(2)\n      Support building without inttypes.h\n      Add Interix support\n\n Makefile          |   40 +++++++++++++++++++++++++++++++++++-----\n builtin.h         |    2 ++\n git-compat-util.h |    6 ++++++\n git.c             |    2 ++\n 4 files changed, 45 insertions(+), 5 deletions(-)\n"},{"id":"142406","messageId":"1274948384-167-2-git-send-email-abcd@gentoo.org","threadId":"23919","inReplyTo":"1274948384-167-1-git-send-email-abcd@gentoo.org","subject":"[PATCH 1/3] Support building on systems without poll(2)","fromName":"Jonathan Callen","fromEmail":"abcd@gentoo.org","sentAt":"2010-05-27T08:19:42Z","receivedAt":"2010-05-27T08:19:42Z","isPatch":true,"sender":{"key":"abcd@gentoo.org","avatar":null},"body":"Some systems do not have sys/poll.h or poll(2).  Don't build\ngit-daemon, git-upload-archive, or git-upload-pack on such systems.\n\nSigned-off-by: Jonathan Callen <abcd@gentoo.org>\n---\n Makefile          |   21 ++++++++++++++++-----\n builtin.h         |    2 ++\n git-compat-util.h |    2 ++\n git.c             |    2 ++\n 4 files changed, 22 insertions(+), 5 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 07cab8f..4b36534 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -62,6 +62,8 @@ all::\n #\n # Define NO_MKSTEMPS if you don't have mkstemps in the C library.\n #\n+# Define NO_POLL if you don't have poll in the C library, or it does not work.\n+#\n # Define NO_LIBGEN_H if you don't have libgen.h.\n #\n # Define NEEDS_LIBGEN if your libgen needs -lgen when linking\n@@ -386,7 +388,6 @@ PROGRAM_OBJS += fast-import.o\n PROGRAM_OBJS += imap-send.o\n PROGRAM_OBJS += shell.o\n PROGRAM_OBJS += show-index.o\n-PROGRAM_OBJS += upload-pack.o\n PROGRAM_OBJS += http-backend.o\n \n PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))\n@@ -434,9 +435,7 @@ OTHER_PROGRAMS = git$X\n \n # what test wrappers are needed and 'install' will install, in bindir\n BINDIR_PROGRAMS_NEED_X += git\n-BINDIR_PROGRAMS_NEED_X += git-upload-pack\n BINDIR_PROGRAMS_NEED_X += git-receive-pack\n-BINDIR_PROGRAMS_NEED_X += git-upload-archive\n BINDIR_PROGRAMS_NEED_X += git-shell\n \n BINDIR_PROGRAMS_NO_X += git-cvsserver\n@@ -722,7 +721,6 @@ BUILTIN_OBJS += builtin/unpack-objects.o\n BUILTIN_OBJS += builtin/update-index.o\n BUILTIN_OBJS += builtin/update-ref.o\n BUILTIN_OBJS += builtin/update-server-info.o\n-BUILTIN_OBJS += builtin/upload-archive.o\n BUILTIN_OBJS += builtin/var.o\n BUILTIN_OBJS += builtin/verify-pack.o\n BUILTIN_OBJS += builtin/verify-tag.o\n@@ -1162,8 +1160,17 @@ ifdef ZLIB_PATH\n endif\n EXTLIBS += -lz\n \n+ifndef NO_POLL\n+\tBUILTIN_OBJS += builtin/upload-archive.o\n+\tPROGRAM_OBJS += upload-pack.o\n+\tBINDIR_PROGRAMS_NEED_X += git-upload-archive\n+\tBINDIR_PROGRAMS_NEED_X += git-upload-pack\n+endif\n+\n ifndef NO_POSIX_ONLY_PROGRAMS\n-\tPROGRAM_OBJS += daemon.o\n+\tifndef NO_POLL\n+\t\tPROGRAM_OBJS += daemon.o\n+\tendif\n endif\n ifndef NO_OPENSSL\n \tOPENSSL_LIBSSL = -lssl\n@@ -1322,6 +1329,10 @@ ifdef OLD_ICONV\n \tBASIC_CFLAGS += -DOLD_ICONV\n endif\n \n+ifdef NO_POLL\n+\tBASIC_CFLAGS += -DNO_POLL\n+endif\n+\n ifdef NO_DEFLATE_BOUND\n \tBASIC_CFLAGS += -DNO_DEFLATE_BOUND\n endif\ndiff --git a/builtin.h b/builtin.h\nindex 5c887ef..165a748 100644\n--- a/builtin.h\n+++ b/builtin.h\n@@ -127,7 +127,9 @@ extern int cmd_unpack_objects(int argc, const char **argv, const char *prefix);\n extern int cmd_update_index(int argc, const char **argv, const char *prefix);\n extern int cmd_update_ref(int argc, const char **argv, const char *prefix);\n extern int cmd_update_server_info(int argc, const char **argv, const char *prefix);\n+#ifdef NO_POLL\n extern int cmd_upload_archive(int argc, const char **argv, const char *prefix);\n+#endif\n extern int cmd_upload_tar(int argc, const char **argv, const char *prefix);\n extern int cmd_var(int argc, const char **argv, const char *prefix);\n extern int cmd_verify_tag(int argc, const char **argv, const char *prefix);\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex edf352d..c5188e5 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -94,7 +94,9 @@\n #include <utime.h>\n #ifndef __MINGW32__\n #include <sys/wait.h>\n+#ifndef NO_POLL\n #include <sys/poll.h>\n+#endif\n #include <sys/socket.h>\n #include <sys/ioctl.h>\n #include <termios.h>\ndiff --git a/git.c b/git.c\nindex 99f0363..8c081db 100644\n--- a/git.c\n+++ b/git.c\n@@ -390,7 +390,9 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"update-index\", cmd_update_index, RUN_SETUP },\n \t\t{ \"update-ref\", cmd_update_ref, RUN_SETUP },\n \t\t{ \"update-server-info\", cmd_update_server_info, RUN_SETUP },\n+#ifndef NO_POLL\n \t\t{ \"upload-archive\", cmd_upload_archive },\n+#endif\n \t\t{ \"var\", cmd_var },\n \t\t{ \"verify-tag\", cmd_verify_tag, RUN_SETUP },\n \t\t{ \"version\", cmd_version },\n-- \n1.7.1\n"},{"id":"142404","messageId":"1274948384-167-3-git-send-email-abcd@gentoo.org","threadId":"23919","inReplyTo":"1274948384-167-1-git-send-email-abcd@gentoo.org","subject":"[PATCH 2/3] Support building without inttypes.h","fromName":"Jonathan Callen","fromEmail":"abcd@gentoo.org","sentAt":"2010-05-27T08:19:43Z","receivedAt":"2010-05-27T08:19:43Z","isPatch":true,"sender":{"key":"abcd@gentoo.org","avatar":null},"body":"Some systems, such as Interix, do not have a inttypes.h header.\nAttempt to use stdint.h instead.\n\nSigned-off-by: Jonathan Callen <abcd@gentoo.org>\n---\n Makefile          |    6 ++++++\n git-compat-util.h |    4 ++++\n 2 files changed, 10 insertions(+), 0 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 4b36534..1722bf0 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -70,6 +70,8 @@ all::\n #\n # Define NO_SYS_SELECT_H if you don't have sys/select.h.\n #\n+# Define NO_INTTYPES_H if you don't have inttypes.h.\n+#\n # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.\n # Enable it on Windows.  By default, symrefs are still used.\n #\n@@ -1333,6 +1335,10 @@ ifdef NO_POLL\n \tBASIC_CFLAGS += -DNO_POLL\n endif\n \n+ifdef NO_INTTYPES_H\n+\tBASIC_CFLAGS += -DNO_INTTYPES_H\n+endif\n+\n ifdef NO_DEFLATE_BOUND\n \tBASIC_CFLAGS += -DNO_DEFLATE_BOUND\n endif\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex c5188e5..6f2aaca 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -108,7 +108,11 @@\n #include <arpa/inet.h>\n #include <netdb.h>\n #include <pwd.h>\n+#ifdef NO_INTTYPES_H\n+#include <stdint.h>\n+#else\n #include <inttypes.h>\n+#endif\n #if defined(__CYGWIN__)\n #undef _XOPEN_SOURCE\n #include <grp.h>\n-- \n1.7.1\n"},{"id":"142405","messageId":"1274948384-167-4-git-send-email-abcd@gentoo.org","threadId":"23919","inReplyTo":"1274948384-167-1-git-send-email-abcd@gentoo.org","subject":"[PATCH 3/3] Add Interix support","fromName":"Jonathan Callen","fromEmail":"abcd@gentoo.org","sentAt":"2010-05-27T08:19:44Z","receivedAt":"2010-05-27T08:19:44Z","isPatch":true,"sender":{"key":"abcd@gentoo.org","avatar":null},"body":"Add an Interix clause in the makefile.  Interix's libc does not have\nsupport for many of the functions that are generally taken for granted.\n\nSigned-off-by: Jonathan Callen <abcd@gentoo.org>\n---\n Makefile |   13 +++++++++++++\n 1 files changed, 13 insertions(+), 0 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 1722bf0..563eec2 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1071,6 +1071,19 @@ else\n \tNO_CURL = YesPlease\n endif\n endif\n+ifeq ($(uname_S),Interix)\n+\tNO_IPV6 = YesPlease\n+\tNO_MEMMEM = YesPlease\n+\tNO_MKDTEMP = YesPlease\n+\tNO_STRTOUMAX = YesPlease\n+\tNO_STRTOULL = YesPlease\n+\tNO_INET_NTOP = YesPlease\n+\tNO_INET_PTON = YesPlease\n+\tNO_NSEC = YesPlease\n+\tNO_MKSTEMPS = YesPlease\n+\tNO_POLL = YesPlease\n+\tNO_INTTYPES_H = YesPlease\n+endif\n \n -include config.mak.autogen\n -include config.mak\n-- \n1.7.1\n"},{"id":"142407","messageId":"AANLkTikoFSMmAyCYPoejTObEmCMv4TmTDx7P4sdWcOJy@mail.gmail.com","threadId":"23919","inReplyTo":"1274948384-167-2-git-send-email-abcd@gentoo.org","subject":"Re: [PATCH 1/3] Support building on systems without poll(2)","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2010-05-27T08:43:35Z","receivedAt":"2010-05-27T08:43:35Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Thu, May 27, 2010 at 10:19, Jonathan Callen <abcd@gentoo.org> wrote:\n> Some systems do not have sys/poll.h or poll(2).  Don't build\n> git-daemon, git-upload-archive, or git-upload-pack on such systems.\n\nI thought git-upload-pack is required for push support in git?\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"142408","messageId":"4BFE3286.8070508@drmicha.warpmail.net","threadId":"23919","inReplyTo":"1274948384-167-2-git-send-email-abcd@gentoo.org","subject":"Re: [PATCH 1/3] Support building on systems without poll(2)","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-05-27T08:51:18Z","receivedAt":"2010-05-27T08:51:18Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Jonathan Callen venit, vidit, dixit 27.05.2010 10:19:\n> Some systems do not have sys/poll.h or poll(2).  Don't build\n> git-daemon, git-upload-archive, or git-upload-pack on such systems.\n> \n> Signed-off-by: Jonathan Callen <abcd@gentoo.org>\n> ---\n>  Makefile          |   21 ++++++++++++++++-----\n>  builtin.h         |    2 ++\n>  git-compat-util.h |    2 ++\n>  git.c             |    2 ++\n>  4 files changed, 22 insertions(+), 5 deletions(-)\n> \n> diff --git a/Makefile b/Makefile\n> index 07cab8f..4b36534 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -62,6 +62,8 @@ all::\n>  #\n>  # Define NO_MKSTEMPS if you don't have mkstemps in the C library.\n>  #\n> +# Define NO_POLL if you don't have poll in the C library, or it does not work.\n> +#\n>  # Define NO_LIBGEN_H if you don't have libgen.h.\n>  #\n>  # Define NEEDS_LIBGEN if your libgen needs -lgen when linking\n> @@ -386,7 +388,6 @@ PROGRAM_OBJS += fast-import.o\n>  PROGRAM_OBJS += imap-send.o\n>  PROGRAM_OBJS += shell.o\n>  PROGRAM_OBJS += show-index.o\n> -PROGRAM_OBJS += upload-pack.o\n>  PROGRAM_OBJS += http-backend.o\n>  \n>  PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))\n> @@ -434,9 +435,7 @@ OTHER_PROGRAMS = git$X\n>  \n>  # what test wrappers are needed and 'install' will install, in bindir\n>  BINDIR_PROGRAMS_NEED_X += git\n> -BINDIR_PROGRAMS_NEED_X += git-upload-pack\n>  BINDIR_PROGRAMS_NEED_X += git-receive-pack\n> -BINDIR_PROGRAMS_NEED_X += git-upload-archive\n>  BINDIR_PROGRAMS_NEED_X += git-shell\n>  \n>  BINDIR_PROGRAMS_NO_X += git-cvsserver\n> @@ -722,7 +721,6 @@ BUILTIN_OBJS += builtin/unpack-objects.o\n>  BUILTIN_OBJS += builtin/update-index.o\n>  BUILTIN_OBJS += builtin/update-ref.o\n>  BUILTIN_OBJS += builtin/update-server-info.o\n> -BUILTIN_OBJS += builtin/upload-archive.o\n>  BUILTIN_OBJS += builtin/var.o\n>  BUILTIN_OBJS += builtin/verify-pack.o\n>  BUILTIN_OBJS += builtin/verify-tag.o\n> @@ -1162,8 +1160,17 @@ ifdef ZLIB_PATH\n>  endif\n>  EXTLIBS += -lz\n>  \n> +ifndef NO_POLL\n> +\tBUILTIN_OBJS += builtin/upload-archive.o\n> +\tPROGRAM_OBJS += upload-pack.o\n> +\tBINDIR_PROGRAMS_NEED_X += git-upload-archive\n> +\tBINDIR_PROGRAMS_NEED_X += git-upload-pack\n> +endif\n> +\n>  ifndef NO_POSIX_ONLY_PROGRAMS\n> -\tPROGRAM_OBJS += daemon.o\n> +\tifndef NO_POLL\n> +\t\tPROGRAM_OBJS += daemon.o\n> +\tendif\n>  endif\n>  ifndef NO_OPENSSL\n>  \tOPENSSL_LIBSSL = -lssl\n> @@ -1322,6 +1329,10 @@ ifdef OLD_ICONV\n>  \tBASIC_CFLAGS += -DOLD_ICONV\n>  endif\n>  \n> +ifdef NO_POLL\n> +\tBASIC_CFLAGS += -DNO_POLL\n> +endif\n> +\n>  ifdef NO_DEFLATE_BOUND\n>  \tBASIC_CFLAGS += -DNO_DEFLATE_BOUND\n>  endif\n> diff --git a/builtin.h b/builtin.h\n> index 5c887ef..165a748 100644\n> --- a/builtin.h\n> +++ b/builtin.h\n> @@ -127,7 +127,9 @@ extern int cmd_unpack_objects(int argc, const char **argv, const char *prefix);\n>  extern int cmd_update_index(int argc, const char **argv, const char *prefix);\n>  extern int cmd_update_ref(int argc, const char **argv, const char *prefix);\n>  extern int cmd_update_server_info(int argc, const char **argv, const char *prefix);\n> +#ifdef NO_POLL\n>  extern int cmd_upload_archive(int argc, const char **argv, const char *prefix);\n> +#endif\n\nShouldn't this be \"ifndef\"? makes me wonder how the test compile worked...\n\n>  extern int cmd_upload_tar(int argc, const char **argv, const char *prefix);\n>  extern int cmd_var(int argc, const char **argv, const char *prefix);\n>  extern int cmd_verify_tag(int argc, const char **argv, const char *prefix);\n> diff --git a/git-compat-util.h b/git-compat-util.h\n> index edf352d..c5188e5 100644\n> --- a/git-compat-util.h\n> +++ b/git-compat-util.h\n> @@ -94,7 +94,9 @@\n>  #include <utime.h>\n>  #ifndef __MINGW32__\n>  #include <sys/wait.h>\n> +#ifndef NO_POLL\n>  #include <sys/poll.h>\n> +#endif\n>  #include <sys/socket.h>\n>  #include <sys/ioctl.h>\n>  #include <termios.h>\n> diff --git a/git.c b/git.c\n> index 99f0363..8c081db 100644\n> --- a/git.c\n> +++ b/git.c\n> @@ -390,7 +390,9 @@ static void handle_internal_command(int argc, const char **argv)\n>  \t\t{ \"update-index\", cmd_update_index, RUN_SETUP },\n>  \t\t{ \"update-ref\", cmd_update_ref, RUN_SETUP },\n>  \t\t{ \"update-server-info\", cmd_update_server_info, RUN_SETUP },\n> +#ifndef NO_POLL\n>  \t\t{ \"upload-archive\", cmd_upload_archive },\n> +#endif\n>  \t\t{ \"var\", cmd_var },\n>  \t\t{ \"verify-tag\", cmd_verify_tag, RUN_SETUP },\n>  \t\t{ \"version\", cmd_version },\n"},{"id":"142411","messageId":"4BFE37CE.9090105@gentoo.org","threadId":"23919","inReplyTo":"4BFE3286.8070508@drmicha.warpmail.net","subject":"Re: [PATCH 1/3] Support building on systems without poll(2)","fromName":"Jonathan Callen","fromEmail":"abcd@gentoo.org","sentAt":"2010-05-27T09:13:50Z","receivedAt":"2010-05-27T09:13:50Z","isPatch":true,"sender":{"key":"abcd@gentoo.org","avatar":null},"body":"-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA256\n\nOn 05/27/2010 04:51 AM, Michael J Gruber wrote:\n> Jonathan Callen venit, vidit, dixit 27.05.2010 10:19:\n>> +#ifdef NO_POLL\n>>  extern int cmd_upload_archive(int argc, const char **argv, const char *prefix);\n>> +#endif\n> \n> Shouldn't this be \"ifndef\"? makes me wonder how the test compile worked...\n> \n\nYeah, that's a mistake.  It should be #ifndef. The test compile worked\nbecause cmd_upload_archive is never called when NO_POLL is defined (and\nI didn't test on a system where it wasn't).\n\n- -- \nJonathan Callen\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v2.0.15 (GNU/Linux)\nComment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/\n\niQIcBAEBCAAGBQJL/jfNAAoJELHSF2kinlg4avYP/3CxgTwg1Wcraf0JLxtg590T\nr0VPk/FJfN70kCwch1107qrXFH2Lm5j57R2qcJRPbO4xLg3/7SVDo8uh5srRVBwh\njHV/lVHiDofzAwogv0T1dAd02/WrbpBKM8Wt6sT0fz9Y3yMGPfSuYCazQ0uiH6NA\nI/Rk2CcTelNNSo4h8+XRTdMwiEVIehw1zUNX9HhH1SYWastMCgoh2PS+cpeGot+q\nIvInTpcOJfOsREXTxjer9zf/GeZsTiEVLgDWZG6Uc0JOEvLTKOqk/BcSeOn4L2zv\nlHz14vMT8NS68U/rfPvTjscgczyS2E47XHrvM0+1bswLuNVrilHdzgcnH2rhWFFP\ntU/dA6qzzFPvpqLwhXOwxECUsnJ8km5i8oR1914Qwfxr88KVR8syYyDl4eSI3qMg\nMbFRTAzRC+4KD1FcGaQ7f7f2J/2Um4wtTb5SrKUJVKk2ROI/2KfBFthI4SbIonOf\nNYJp+2XEpc3vbwE6YbiFzXBkP2z/F4fFvorYi8epa1neX7YKF7Hp+U5UJIFBb8de\nKMKCoX1ClXjsTQ3B72M29D/o52L67/xcyoPDIfmnjuxeBcrJBO82z8pqMCyF4nh+\nxa7mU4rrk6D8ZHxv1uULf8Bqz29Eq6dzzeuNkoV/5plLC2XjWJ2qsMxvZY9dED4h\n6SUO3TH9eJJW6eAZG9bB\n=RkSh\n-----END PGP SIGNATURE-----\n"},{"id":"142412","messageId":"20100527101043.GA4390@progeny.tock","threadId":"23919","inReplyTo":"1274948384-167-2-git-send-email-abcd@gentoo.org","subject":"[PATCH] compat: Add another rudimentary poll() emulation","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-05-27T10:10:43Z","receivedAt":"2010-05-27T10:10:43Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Implement the subset of poll() semantics needed by git in terms of\nselect(), for use by the Interix port.  Inspired by commit 6ed807f\n(Windows: A rudimentary poll() emulation, 2007-12-01).\n\nCc: Johannes Sixt <j6t@kdbg.org>\nCc: Jonathan Callen <abcd@gentoo.org>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nJonathan Callen wrote:\n\n> Some systems do not have sys/poll.h or poll(2).\n\nMaybe this could help.  Thanks to DrNick on IRC for the suggestion.\n\nWarning: untested.\n\n Makefile          |    8 ++++++++\n compat/poll.c     |   33 +++++++++++++++++++++++++++++++++\n compat/poll.h     |   13 +++++++++++++\n git-compat-util.h |    6 +++++-\n 4 files changed, 59 insertions(+), 1 deletions(-)\n create mode 100644 compat/poll.c\n create mode 100644 compat/poll.h\n\ndiff --git a/Makefile b/Makefile\nindex 2f5d631..6715528 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -111,6 +111,9 @@ all::\n #\n # Define NO_PTHREADS if you do not have or do not want to use Pthreads.\n #\n+# Define NO_POLL if you have a problem with the poll() system call (e.g.\n+# Interix).\n+#\n # Define NO_PREAD if you have a problem with pread() system call (e.g.\n # cygwin1.dll before v1.5.22).\n #\n@@ -470,6 +473,7 @@ LIB_H += commit.h\n LIB_H += compat/bswap.h\n LIB_H += compat/cygwin.h\n LIB_H += compat/mingw.h\n+LIB_H += compat/poll.h\n LIB_H += compat/win32/pthread.h\n LIB_H += csum-file.h\n LIB_H += decorate.h\n@@ -1284,6 +1288,10 @@ endif\n ifdef OBJECT_CREATION_USES_RENAMES\n \tCOMPAT_CFLAGS += -DOBJECT_CREATION_MODE=1\n endif\n+ifdef NO_POLL\n+\tBASIC_CFLAGS += -DNO_POLL\n+\tCOMPAT_OBJS += compat/poll.o\n+endif\n ifdef NO_PREAD\n \tCOMPAT_CFLAGS += -DNO_PREAD\n \tCOMPAT_OBJS += compat/pread.o\ndiff --git a/compat/poll.c b/compat/poll.c\nnew file mode 100644\nindex 0000000..33c6ae0\n--- /dev/null\n+++ b/compat/poll.c\n@@ -0,0 +1,33 @@\n+#include \"../git-compat-util.h\"\n+\n+int git_poll(struct git_pollfd *ufds, int nfds, int timeout)\n+{\n+\tint i, maxfd, result;\n+\tfd_set fds;\n+\n+\tif (timeout >= 0) {\n+\t\tif (nfds == 0) {\n+\t\t\tsleep(timeout);\n+\t\t\treturn 0;\n+\t\t}\n+\t\treturn errno = EINVAL, error(\"poll timeout not supported\");\n+\t}\n+\n+\tFD_ZERO(&fds);\n+\tmaxfd = 0;\n+\tfor (i = 0; i < nfds; i++) {\n+\t\tif (ufds[i].events != POLLIN)\n+\t\t\treturn errno = EINVAL, error(\"poll: unsupported events\");\n+\t\tmaxfd = (ufds[i].fd > maxfd) ? ufds[i].fd : maxfd;\n+\t\tFD_SET(ufds[i].fd, &fds);\n+\t}\n+\n+\tresult = select(maxfd + 1, &fds, NULL, NULL, NULL);\n+\tif (result == -1)\n+\t\treturn result;\n+\tfor (i = 0; i < nfds; i++) {\n+\t\tif (FD_ISSET(ufds[i].fd, &fds))\n+\t\t\tufds[i].revents |= POLLIN;\n+\t}\n+\treturn result;\n+}\ndiff --git a/compat/poll.h b/compat/poll.h\nnew file mode 100644\nindex 0000000..65775ab\n--- /dev/null\n+++ b/compat/poll.h\n@@ -0,0 +1,13 @@\n+#ifndef POLLIN\n+#define POLLIN 1\n+#define POLLHUP 2\n+#endif\n+\n+#define pollfd git_pollfd\n+#define poll git_poll\n+struct git_pollfd {\n+\tint fd;\t\t/* file descriptor */\n+\tshort events;\t/* requested events */\n+\tshort revents;\t/* returned events */\n+};\n+extern int git_poll(struct git_pollfd *fds, int nfds, int timeout);\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 824c175..2494378 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -94,13 +94,17 @@\n #include <utime.h>\n #ifndef __MINGW32__\n #include <sys/wait.h>\n-#include <sys/poll.h>\n #include <sys/socket.h>\n #include <sys/ioctl.h>\n #include <termios.h>\n #ifndef NO_SYS_SELECT_H\n #include <sys/select.h>\n #endif\n+#ifdef NO_POLL\n+#include \"compat/poll.h\"\n+#else\n+#include <sys/poll.h>\n+#endif\n #include <netinet/in.h>\n #include <netinet/tcp.h>\n #include <arpa/inet.h>\n-- \n1.7.1\n"},{"id":"142414","messageId":"AANLkTikYa2vq4PrKrO2QIkHVxYqbhUZRw42kQq875FNT@mail.gmail.com","threadId":"23919","inReplyTo":"20100527101043.GA4390@progeny.tock","subject":"Re: [PATCH] compat: Add another rudimentary poll() emulation","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2010-05-27T11:00:33Z","receivedAt":"2010-05-27T11:00:33Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Thu, May 27, 2010 at 12:10 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Implement the subset of poll() semantics needed by git in terms of\n> select(), for use by the Interix port.  Inspired by commit 6ed807f\n> (Windows: A rudimentary poll() emulation, 2007-12-01).\n>\n\nA possible problem with this approach is that the maximum number of\nfile descriptors poll can handle limited by RLIMIT_NOFILE, whereas the\nmaximum number of file descriptors select can handle is limited by\nFD_SETSIZE.\n\nI don't think this is a big problem in reality, though - both values\nseem to be pretty high in most implementations. And IIRC git-daemon is\nthe only one who needs more than 2, and it doesn't even check\nRLIMIT_NOFILE.\n\nIf we decide to go this route, perhaps it'd make sense to change to\nthis code for Windows also? Our Windows-implementation of poll() has\nsome annoying limitations...\n\n-- \nErik \"kusma\" Faye-Lund\n"},{"id":"142416","messageId":"AANLkTikfaWVEPkHBRF8WHNWmyXIH9f7wRju1wSRC_lwm@mail.gmail.com","threadId":"23919","inReplyTo":"AANLkTikYa2vq4PrKrO2QIkHVxYqbhUZRw42kQq875FNT@mail.gmail.com","subject":"Re: [PATCH] compat: Add another rudimentary poll() emulation","fromName":"Marko Kreen","fromEmail":"markokr@gmail.com","sentAt":"2010-05-27T11:39:13Z","receivedAt":"2010-05-27T11:39:13Z","isPatch":true,"sender":{"key":"markokr@gmail.com","avatar":null},"body":"On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n> On Thu, May 27, 2010 at 12:10 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>  > Implement the subset of poll() semantics needed by git in terms of\n>  > select(), for use by the Interix port.  Inspired by commit 6ed807f\n>  > (Windows: A rudimentary poll() emulation, 2007-12-01).\n>  >\n>\n>\n> A possible problem with this approach is that the maximum number of\n>  file descriptors poll can handle limited by RLIMIT_NOFILE, whereas the\n>  maximum number of file descriptors select can handle is limited by\n>  FD_SETSIZE.\n>\n>  I don't think this is a big problem in reality, though - both values\n>  seem to be pretty high in most implementations. And IIRC git-daemon is\n>  the only one who needs more than 2, and it doesn't even check\n>  RLIMIT_NOFILE.\n>\n>  If we decide to go this route, perhaps it'd make sense to change to\n>  this code for Windows also? Our Windows-implementation of poll() has\n>  some annoying limitations...\n\nExample of poll() compat without FD_SETSIZE limit:\n\n  http://github.com/markokr/plproxy-dev/blob/master/src/poll_compat.c\n\n-- \nmarko\n"},{"id":"142417","messageId":"AANLkTinXwM1fem6E3RgnLW9vqLD1fV7JvaQnxzZVRakA@mail.gmail.com","threadId":"23919","inReplyTo":"AANLkTikfaWVEPkHBRF8WHNWmyXIH9f7wRju1wSRC_lwm@mail.gmail.com","subject":"Re: [PATCH] compat: Add another rudimentary poll() emulation","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2010-05-27T12:00:02Z","receivedAt":"2010-05-27T12:00:02Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Thu, May 27, 2010 at 1:39 PM, Marko Kreen <markokr@gmail.com> wrote:\n> On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n>> On Thu, May 27, 2010 at 12:10 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>>  > Implement the subset of poll() semantics needed by git in terms of\n>>  > select(), for use by the Interix port.  Inspired by commit 6ed807f\n>>  > (Windows: A rudimentary poll() emulation, 2007-12-01).\n>>  >\n>>\n>>\n>> A possible problem with this approach is that the maximum number of\n>>  file descriptors poll can handle limited by RLIMIT_NOFILE, whereas the\n>>  maximum number of file descriptors select can handle is limited by\n>>  FD_SETSIZE.\n>>\n>>  I don't think this is a big problem in reality, though - both values\n>>  seem to be pretty high in most implementations. And IIRC git-daemon is\n>>  the only one who needs more than 2, and it doesn't even check\n>>  RLIMIT_NOFILE.\n>>\n>>  If we decide to go this route, perhaps it'd make sense to change to\n>>  this code for Windows also? Our Windows-implementation of poll() has\n>>  some annoying limitations...\n>\n> Example of poll() compat without FD_SETSIZE limit:\n>\n>  http://github.com/markokr/plproxy-dev/blob/master/src/poll_compat.c\n>\n\nHow does this code convince FD_SET() that the buffer has increased? It\nlooks to me like it depends on a specific FD_SET() implementation...\nFor instance, Windows' FD_SET() implementation is like this:\n\n#define FD_SET(fd, set) do { \\\n    if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) \\\n        ((fd_set FAR *)(set))->fd_array[((fd_set FAR\n*)(set))->fd_count++]=(fd);\\\n} while(0)\n\n...so unless another set is passed in, it won't add any more fds once\nfd_count reaches FD_SETSIZE.\n\nAlso, FD_SETSIZE is 64 on Windows. IIRC it's 1024 on Linux, so it is\nmuch more likely that we encounter this issue on Windows than on\nLinux, at least ;)\n\n-- \nErik \"kusma\" Faye-Lund\n"},{"id":"142418","messageId":"AANLkTinX8nK68rZtN5dwJ-fGQm4gR2G84xo9raxb4vLY@mail.gmail.com","threadId":"23919","inReplyTo":"AANLkTinXwM1fem6E3RgnLW9vqLD1fV7JvaQnxzZVRakA@mail.gmail.com","subject":"Re: [PATCH] compat: Add another rudimentary poll() emulation","fromName":"Marko Kreen","fromEmail":"markokr@gmail.com","sentAt":"2010-05-27T12:36:43Z","receivedAt":"2010-05-27T12:36:43Z","isPatch":true,"sender":{"key":"markokr@gmail.com","avatar":null},"body":"On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n> On Thu, May 27, 2010 at 1:39 PM, Marko Kreen <markokr@gmail.com> wrote:\n>  > On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n>  >> On Thu, May 27, 2010 at 12:10 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>  >>  > Implement the subset of poll() semantics needed by git in terms of\n>  >>  > select(), for use by the Interix port.  Inspired by commit 6ed807f\n>  >>  > (Windows: A rudimentary poll() emulation, 2007-12-01).\n>  >>  >\n>  >>\n>  >>\n>  >> A possible problem with this approach is that the maximum number of\n>  >>  file descriptors poll can handle limited by RLIMIT_NOFILE, whereas the\n>  >>  maximum number of file descriptors select can handle is limited by\n>  >>  FD_SETSIZE.\n>  >>\n>  >>  I don't think this is a big problem in reality, though - both values\n>  >>  seem to be pretty high in most implementations. And IIRC git-daemon is\n>  >>  the only one who needs more than 2, and it doesn't even check\n>  >>  RLIMIT_NOFILE.\n>  >>\n>  >>  If we decide to go this route, perhaps it'd make sense to change to\n>  >>  this code for Windows also? Our Windows-implementation of poll() has\n>  >>  some annoying limitations...\n>  >\n>  > Example of poll() compat without FD_SETSIZE limit:\n>  >\n>  >  http://github.com/markokr/plproxy-dev/blob/master/src/poll_compat.c\n>  >\n>\n>\n> How does this code convince FD_SET() that the buffer has increased? It\n>  looks to me like it depends on a specific FD_SET() implementation...\n>  For instance, Windows' FD_SET() implementation is like this:\n>\n>  #define FD_SET(fd, set) do { \\\n>     if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) \\\n>         ((fd_set FAR *)(set))->fd_array[((fd_set FAR\n>  *)(set))->fd_count++]=(fd);\\\n>  } while(0)\n>\n>  ...so unless another set is passed in, it won't add any more fds once\n>  fd_count reaches FD_SETSIZE.\n>\n>  Also, FD_SETSIZE is 64 on Windows. IIRC it's 1024 on Linux, so it is\n>  much more likely that we encounter this issue on Windows than on\n>  Linux, at least ;)\n\nHm, good catch.  Seems such compat poll() cannot be done without\nOS-specific hacks.\n\nDo you know perhaps what other OS-es have non-bitmap fd_set?\n\n-- \nmarko\n"},{"id":"142419","messageId":"AANLkTiliJFXWKXnksQryvAivadrkTUeZ1Wu7FkUGm2YZ@mail.gmail.com","threadId":"23919","inReplyTo":"AANLkTinX8nK68rZtN5dwJ-fGQm4gR2G84xo9raxb4vLY@mail.gmail.com","subject":"Re: [PATCH] compat: Add another rudimentary poll() emulation","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2010-05-27T12:57:52Z","receivedAt":"2010-05-27T12:57:52Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Thu, May 27, 2010 at 2:36 PM, Marko Kreen <markokr@gmail.com> wrote:\n> On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n>> On Thu, May 27, 2010 at 1:39 PM, Marko Kreen <markokr@gmail.com> wrote:\n>>  > On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n>>  >> On Thu, May 27, 2010 at 12:10 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>>  >>  > Implement the subset of poll() semantics needed by git in terms of\n>>  >>  > select(), for use by the Interix port.  Inspired by commit 6ed807f\n>>  >>  > (Windows: A rudimentary poll() emulation, 2007-12-01).\n>>  >>  >\n>>  >>\n>>  >>\n>>  >> A possible problem with this approach is that the maximum number of\n>>  >>  file descriptors poll can handle limited by RLIMIT_NOFILE, whereas the\n>>  >>  maximum number of file descriptors select can handle is limited by\n>>  >>  FD_SETSIZE.\n>>  >>\n>>  >>  I don't think this is a big problem in reality, though - both values\n>>  >>  seem to be pretty high in most implementations. And IIRC git-daemon is\n>>  >>  the only one who needs more than 2, and it doesn't even check\n>>  >>  RLIMIT_NOFILE.\n>>  >>\n>>  >>  If we decide to go this route, perhaps it'd make sense to change to\n>>  >>  this code for Windows also? Our Windows-implementation of poll() has\n>>  >>  some annoying limitations...\n>>  >\n>>  > Example of poll() compat without FD_SETSIZE limit:\n>>  >\n>>  >  http://github.com/markokr/plproxy-dev/blob/master/src/poll_compat.c\n>>  >\n>>\n>>\n>> How does this code convince FD_SET() that the buffer has increased? It\n>>  looks to me like it depends on a specific FD_SET() implementation...\n>>  For instance, Windows' FD_SET() implementation is like this:\n>>\n>>  #define FD_SET(fd, set) do { \\\n>>     if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) \\\n>>         ((fd_set FAR *)(set))->fd_array[((fd_set FAR\n>>  *)(set))->fd_count++]=(fd);\\\n>>  } while(0)\n>>\n>>  ...so unless another set is passed in, it won't add any more fds once\n>>  fd_count reaches FD_SETSIZE.\n>>\n>>  Also, FD_SETSIZE is 64 on Windows. IIRC it's 1024 on Linux, so it is\n>>  much more likely that we encounter this issue on Windows than on\n>>  Linux, at least ;)\n>\n> Hm, good catch.  Seems such compat poll() cannot be done without\n> OS-specific hacks.\n>\n\nPerhaps getrlimit() could overridden to return FD_SETSIZE for both the\nsoft and hard limit when asking about RLIMIT_NOFILE? In such cases,\nanyone who passes nfds above FD_SETSIZE hasn't consulted\nRLIMIT_NOFILE, and should be outside the standard. But your point\nmight have been about a limitless poll()-implementation, like the code\nyou linked tried to achieve. In that context, no. I doubt it's\npossible to do in a robust fashion.\n\nFor git, I don't think this is necessary, though. As said, I think\ngit-daemon is the only call-site for poll where nfds can be above 2.\nAnd git-daemon's default max-connection is 32, which shouldn't cause\nmuch problems. There's the theoretical problem of someone setting\n--max-connections above their platform's limit, but I don't think we\nneed to touch that ;)\n\n> Do you know perhaps what other OS-es have non-bitmap fd_set?\n\nNo, I don't have much low-level file-descriptor knowledge about other\nOS'es than Windows, really.\n\n-- \nErik \"kusma\" Faye-Lund\n"},{"id":"142420","messageId":"20100527130221.GA1672@coredump.intra.peff.net","threadId":"23919","inReplyTo":"AANLkTikoFSMmAyCYPoejTObEmCMv4TmTDx7P4sdWcOJy@mail.gmail.com","subject":"Re: [PATCH 1/3] Support building on systems without poll(2)","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-05-27T13:02:22Z","receivedAt":"2010-05-27T13:02:22Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, May 27, 2010 at 10:43:35AM +0200, Sverre Rabbelier wrote:\n\n> On Thu, May 27, 2010 at 10:19, Jonathan Callen <abcd@gentoo.org> wrote:\n> > Some systems do not have sys/poll.h or poll(2).  Don't build\n> > git-daemon, git-upload-archive, or git-upload-pack on such systems.\n> \n> I thought git-upload-pack is required for push support in git?\n\nNo, that's send-pack. Upload-pack is the server side of fetching. And\nyes, these names are confusing. Before I worked a lot on the send-pack\ncode, I used to mix them up all the time. :)\n\nSo without upload-pack, one cannot be the server side of a fetch. Which\nmeans you can still work as a client, but it does mean that even local\nclones won't work (actually, the clone will work due to the local\nhardlink optimization, but further fetches will fail).\n\n-Peff\n"},{"id":"142421","messageId":"AANLkTikezlVaX8ARkRw8kEk9wL9RL_5I6X3vK83nzFUl@mail.gmail.com","threadId":"23919","inReplyTo":"AANLkTikYa2vq4PrKrO2QIkHVxYqbhUZRw42kQq875FNT@mail.gmail.com","subject":"Re: [PATCH] compat: Add another rudimentary poll() emulation","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2010-05-27T13:06:11Z","receivedAt":"2010-05-27T13:06:11Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Thu, May 27, 2010 at 1:00 PM, Erik Faye-Lund\n<kusmabite@googlemail.com> wrote:\n> On Thu, May 27, 2010 at 12:10 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>> Implement the subset of poll() semantics needed by git in terms of\n>> select(), for use by the Interix port.  Inspired by commit 6ed807f\n>> (Windows: A rudimentary poll() emulation, 2007-12-01).\n>>\n>\n> A possible problem with this approach is that the maximum number of\n> file descriptors poll can handle limited by RLIMIT_NOFILE, whereas the\n> maximum number of file descriptors select can handle is limited by\n> FD_SETSIZE.\n>\n> I don't think this is a big problem in reality, though - both values\n> seem to be pretty high in most implementations. And IIRC git-daemon is\n> the only one who needs more than 2, and it doesn't even check\n> RLIMIT_NOFILE.\n>\n\nTo be clear: I think this strategy is the best option (at least for\nnon-Windows, where select() might be our only option).\n\nBut perhaps you should include a check along the lines of this:\n\nif (nfds > FD_SETSIZE)\n\treturn errno = EINVAL, error(\"poll: nfds must be below %d\", FD_SETSIZE);\n\nJust so we can know when the code fails :)\n\n-- \nErik \"kusma\" Faye-Lund\n"},{"id":"142422","messageId":"AANLkTil_dqbXChKpMJ_ZFTuNrF8tQRwJd5j4SkLOaPaJ@mail.gmail.com","threadId":"23919","inReplyTo":"AANLkTikezlVaX8ARkRw8kEk9wL9RL_5I6X3vK83nzFUl@mail.gmail.com","subject":"Re: [PATCH] compat: Add another rudimentary poll() emulation","fromName":"Marko Kreen","fromEmail":"markokr@gmail.com","sentAt":"2010-05-27T13:29:53Z","receivedAt":"2010-05-27T13:29:53Z","isPatch":true,"sender":{"key":"markokr@gmail.com","avatar":null},"body":"On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n> On Thu, May 27, 2010 at 1:00 PM, Erik Faye-Lund\n>  <kusmabite@googlemail.com> wrote:\n>  > On Thu, May 27, 2010 at 12:10 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>  >> Implement the subset of poll() semantics needed by git in terms of\n>  >> select(), for use by the Interix port.  Inspired by commit 6ed807f\n>  >> (Windows: A rudimentary poll() emulation, 2007-12-01).\n>  >>\n>  >\n>  > A possible problem with this approach is that the maximum number of\n>  > file descriptors poll can handle limited by RLIMIT_NOFILE, whereas the\n>  > maximum number of file descriptors select can handle is limited by\n>  > FD_SETSIZE.\n>  >\n>  > I don't think this is a big problem in reality, though - both values\n>  > seem to be pretty high in most implementations. And IIRC git-daemon is\n>  > the only one who needs more than 2, and it doesn't even check\n>  > RLIMIT_NOFILE.\n>  >\n>\n>\n> To be clear: I think this strategy is the best option (at least for\n>  non-Windows, where select() might be our only option).\n>\n>  But perhaps you should include a check along the lines of this:\n>\n>  if (nfds > FD_SETSIZE)\n>         return errno = EINVAL, error(\"poll: nfds must be below %d\", FD_SETSIZE);\n>\n>  Just so we can know when the code fails :)\n\nWell, per your own FD_SET example, the FD_SETSIZE on windows\nmeans different thing than FD_SETSIZE on old-style bitmap-based\nselect() implementation.\n\nOn Unix, it's max fd number + 1, on windows it's max count.\n\nThus on windows the nfds can safely be larger than FD_SETSIZE,\nassuming the actual count is smaller.\n\n\n\nRLIMIT_NOFILE - I don't see why it is relevant here, as you\nget error on open() when you cross the limit.  So how can you\npass more than that meny fds to select()/poll()?\n\n-- \nmarko\n"},{"id":"142424","messageId":"AANLkTikU4ZzX4yYVSCOuLxjp56cmmolHk1u0U-fhfTtN@mail.gmail.com","threadId":"23919","inReplyTo":"AANLkTiliJFXWKXnksQryvAivadrkTUeZ1Wu7FkUGm2YZ@mail.gmail.com","subject":"Re: [msysGit] Re: [PATCH] compat: Add another rudimentary poll() emulation","fromName":"Albert Dvornik","fromEmail":"dvornik+git@gmail.com","sentAt":"2010-05-27T13:43:32Z","receivedAt":"2010-05-27T13:43:32Z","isPatch":true,"sender":{"key":"dvornik+git@gmail.com","avatar":null},"body":"On Thu, May 27, 2010 at 8:57 AM, Erik Faye-Lund\n<kusmabite@googlemail.com> wrote:\n> On Thu, May 27, 2010 at 2:36 PM, Marko Kreen <markokr@gmail.com> wrote:\n[...]\n>> Hm, good catch.  Seems such compat poll() cannot be done without\n>> OS-specific hacks.\n>>\n>\n> Perhaps getrlimit() could overridden to return FD_SETSIZE for both the\n> soft and hard limit when asking about RLIMIT_NOFILE? In such cases,\n> anyone who passes nfds above FD_SETSIZE hasn't consulted\n> RLIMIT_NOFILE, and should be outside the standard. But your point\n> might have been about a limitless poll()-implementation, like the code\n> you linked tried to achieve. In that context, no. I doubt it's\n> possible to do in a robust fashion.\n\nThis is getting far off-topic, but I do think it's possible to do in a\nrobust fashion if you are willing to sacrifice some performance [i.e.\nwe should not consider this for Git =) ], by creating multiple fd_set\nstructures and only shoving up to FD_SETSIZE descriptors into each.\nCycling between the structures would cause some extra latency and a\nLOT more code complexity, but it should work.\n\n--bert\n"},{"id":"142425","messageId":"AANLkTik2UAA51BZWIKadAcIg8t2xg1u980Gq_IOSyz6o@mail.gmail.com","threadId":"23919","inReplyTo":"AANLkTil_dqbXChKpMJ_ZFTuNrF8tQRwJd5j4SkLOaPaJ@mail.gmail.com","subject":"Re: [PATCH] compat: Add another rudimentary poll() emulation","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2010-05-27T13:46:28Z","receivedAt":"2010-05-27T13:46:28Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Thu, May 27, 2010 at 3:29 PM, Marko Kreen <markokr@gmail.com> wrote:\n> On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n>> On Thu, May 27, 2010 at 1:00 PM, Erik Faye-Lund\n>>  <kusmabite@googlemail.com> wrote:\n>>  > On Thu, May 27, 2010 at 12:10 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>>  >> Implement the subset of poll() semantics needed by git in terms of\n>>  >> select(), for use by the Interix port.  Inspired by commit 6ed807f\n>>  >> (Windows: A rudimentary poll() emulation, 2007-12-01).\n>>  >>\n>>  >\n>>  > A possible problem with this approach is that the maximum number of\n>>  > file descriptors poll can handle limited by RLIMIT_NOFILE, whereas the\n>>  > maximum number of file descriptors select can handle is limited by\n>>  > FD_SETSIZE.\n>>  >\n>>  > I don't think this is a big problem in reality, though - both values\n>>  > seem to be pretty high in most implementations. And IIRC git-daemon is\n>>  > the only one who needs more than 2, and it doesn't even check\n>>  > RLIMIT_NOFILE.\n>>  >\n>>\n>>\n>> To be clear: I think this strategy is the best option (at least for\n>>  non-Windows, where select() might be our only option).\n>>\n>>  But perhaps you should include a check along the lines of this:\n>>\n>>  if (nfds > FD_SETSIZE)\n>>         return errno = EINVAL, error(\"poll: nfds must be below %d\", FD_SETSIZE);\n>>\n>>  Just so we can know when the code fails :)\n>\n> Well, per your own FD_SET example, the FD_SETSIZE on windows\n> means different thing than FD_SETSIZE on old-style bitmap-based\n> select() implementation.\n>\n> On Unix, it's max fd number + 1, on windows it's max count.\n>\n\nAre you sure this applies for all Unix, not just some given Unix-y system?\n\n> RLIMIT_NOFILE - I don't see why it is relevant here, as you\n> get error on open() when you cross the limit.  So how can you\n> pass more than that meny fds to select()/poll()?\n>\n\nGood point, this was my bad.\n\n-- \nErik \"kusma\" Faye-Lund\n"},{"id":"142426","messageId":"AANLkTiko_Azw-cXNFe11oXkijvtER2I9qiRE_gVFouht@mail.gmail.com","threadId":"23919","inReplyTo":"AANLkTik2UAA51BZWIKadAcIg8t2xg1u980Gq_IOSyz6o@mail.gmail.com","subject":"Re: [PATCH] compat: Add another rudimentary poll() emulation","fromName":"Marko Kreen","fromEmail":"markokr@gmail.com","sentAt":"2010-05-27T13:58:52Z","receivedAt":"2010-05-27T13:58:52Z","isPatch":true,"sender":{"key":"markokr@gmail.com","avatar":null},"body":"On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n> On Thu, May 27, 2010 at 3:29 PM, Marko Kreen <markokr@gmail.com> wrote:\n>  > On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n>  >> On Thu, May 27, 2010 at 1:00 PM, Erik Faye-Lund\n>  >>  <kusmabite@googlemail.com> wrote:\n>  >>  > On Thu, May 27, 2010 at 12:10 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>  >>  >> Implement the subset of poll() semantics needed by git in terms of\n>  >>  >> select(), for use by the Interix port.  Inspired by commit 6ed807f\n>  >>  >> (Windows: A rudimentary poll() emulation, 2007-12-01).\n>  >>  >>\n>  >>  >\n>  >>  > A possible problem with this approach is that the maximum number of\n>  >>  > file descriptors poll can handle limited by RLIMIT_NOFILE, whereas the\n>  >>  > maximum number of file descriptors select can handle is limited by\n>  >>  > FD_SETSIZE.\n>  >>  >\n>  >>  > I don't think this is a big problem in reality, though - both values\n>  >>  > seem to be pretty high in most implementations. And IIRC git-daemon is\n>  >>  > the only one who needs more than 2, and it doesn't even check\n>  >>  > RLIMIT_NOFILE.\n>  >>  >\n>  >>\n>  >>\n>  >> To be clear: I think this strategy is the best option (at least for\n>  >>  non-Windows, where select() might be our only option).\n>  >>\n>  >>  But perhaps you should include a check along the lines of this:\n>  >>\n>  >>  if (nfds > FD_SETSIZE)\n>  >>         return errno = EINVAL, error(\"poll: nfds must be below %d\", FD_SETSIZE);\n>  >>\n>  >>  Just so we can know when the code fails :)\n>  >\n>  > Well, per your own FD_SET example, the FD_SETSIZE on windows\n>  > means different thing than FD_SETSIZE on old-style bitmap-based\n>  > select() implementation.\n>  >\n>  > On Unix, it's max fd number + 1, on windows it's max count.\n>  >\n>\n>\n> Are you sure this applies for all Unix, not just some given Unix-y system?\n\nNot sure.  Just pointing out that the above check is not\nuniversal enough.\n\n-- \nmarko\n"},{"id":"142427","messageId":"AANLkTimyFxEYjQLefWvExBarhZAwoXNLDUum2lVj4Q3B@mail.gmail.com","threadId":"23919","inReplyTo":"AANLkTikezlVaX8ARkRw8kEk9wL9RL_5I6X3vK83nzFUl@mail.gmail.com","subject":"Re: [msysGit] Re: [PATCH] compat: Add another rudimentary poll() emulation","fromName":"Albert Dvornik","fromEmail":"dvornik@gmail.com","sentAt":"2010-05-27T14:05:02Z","receivedAt":"2010-05-27T14:05:02Z","isPatch":true,"sender":{"key":"dvornik@gmail.com","avatar":null},"body":"On Thu, May 27, 2010 at 9:06 AM, Erik Faye-Lund\n<kusmabite@googlemail.com> wrote:\n[...]\n> But perhaps you should include a check along the lines of this:\n>\n> if (nfds > FD_SETSIZE)\n>        return errno = EINVAL, error(\"poll: nfds must be below %d\", FD_SETSIZE);\n>\n> Just so we can know when the code fails :)\n\nIf you're checking against FD_SETSIZE (which is IMO a good idea), you\nshould consider that\n(a) on the one system I'm aware of where fd_set doesn't use a bitmap\n(Windows), FD_SETSIZE is a limit on the number of descriptors added to\nthe set, but\n(b) on systems where fd_set uses a bitmap (i.e. Linux, perhaps all\nUNIXes, etc), FD_SETSIZE is a limit on *each descriptor value*.  This\nis also what POSIX says.\n\nSo on the latter systems, we want something like this before each FD_SET:\n\nif (ufds[i].fd >= FD_SETSIZE) {\n    errno = EINVAL;\n    return error(\"poll: each fd must be below %d\", FD_SETSIZE);\n}\n\n(The reason to have it in the loop, rather than just check maxfd\nafterwards, is that FD_SET with an argument that's too big can trash\nthe stack.)\n\nOf course, on Windows this would impose a limitation that all\ndescriptors be < 64, which is probably crazy.  Which means that you'd\nhave to actually distinguish the two types.  Sigh.\n\n--bert\n"},{"id":"142428","messageId":"AANLkTikDcZRHpKp9phlThK5x-8A0OfTYIlhGkqookiFj@mail.gmail.com","threadId":"23919","inReplyTo":"AANLkTiko_Azw-cXNFe11oXkijvtER2I9qiRE_gVFouht@mail.gmail.com","subject":"Re: [PATCH] compat: Add another rudimentary poll() emulation","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2010-05-27T14:06:44Z","receivedAt":"2010-05-27T14:06:44Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Thu, May 27, 2010 at 3:58 PM, Marko Kreen <markokr@gmail.com> wrote:\n> On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n>> On Thu, May 27, 2010 at 3:29 PM, Marko Kreen <markokr@gmail.com> wrote:\n>>  > On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n>>  >> On Thu, May 27, 2010 at 1:00 PM, Erik Faye-Lund\n>>  >>  <kusmabite@googlemail.com> wrote:\n>>  >>  > On Thu, May 27, 2010 at 12:10 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>>  >>  >> Implement the subset of poll() semantics needed by git in terms of\n>>  >>  >> select(), for use by the Interix port.  Inspired by commit 6ed807f\n>>  >>  >> (Windows: A rudimentary poll() emulation, 2007-12-01).\n>>  >>  >>\n>>  >>  >\n>>  >>  > A possible problem with this approach is that the maximum number of\n>>  >>  > file descriptors poll can handle limited by RLIMIT_NOFILE, whereas the\n>>  >>  > maximum number of file descriptors select can handle is limited by\n>>  >>  > FD_SETSIZE.\n>>  >>  >\n>>  >>  > I don't think this is a big problem in reality, though - both values\n>>  >>  > seem to be pretty high in most implementations. And IIRC git-daemon is\n>>  >>  > the only one who needs more than 2, and it doesn't even check\n>>  >>  > RLIMIT_NOFILE.\n>>  >>  >\n>>  >>\n>>  >>\n>>  >> To be clear: I think this strategy is the best option (at least for\n>>  >>  non-Windows, where select() might be our only option).\n>>  >>\n>>  >>  But perhaps you should include a check along the lines of this:\n>>  >>\n>>  >>  if (nfds > FD_SETSIZE)\n>>  >>         return errno = EINVAL, error(\"poll: nfds must be below %d\", FD_SETSIZE);\n>>  >>\n>>  >>  Just so we can know when the code fails :)\n>>  >\n>>  > Well, per your own FD_SET example, the FD_SETSIZE on windows\n>>  > means different thing than FD_SETSIZE on old-style bitmap-based\n>>  > select() implementation.\n>>  >\n>>  > On Unix, it's max fd number + 1, on windows it's max count.\n>>  >\n>>\n>>\n>> Are you sure this applies for all Unix, not just some given Unix-y system?\n>\n> Not sure.  Just pointing out that the above check is not\n> universal enough.\n>\n\nIsn't it? How could one possibly pass more than max fd number + 1 file\ndescriptors, since they start at 0? I guess one could specify a given\nfd more than once, but that'd be kind of redundant... and also very\nunlikely in our case ;)\n\n-- \nErik \"kusma\" Faye-Lund\n"},{"id":"142429","messageId":"AANLkTil-nMo5E2laacYm48-HGbhseEICWsUHwTlc3l47@mail.gmail.com","threadId":"23919","inReplyTo":"AANLkTikDcZRHpKp9phlThK5x-8A0OfTYIlhGkqookiFj@mail.gmail.com","subject":"Re: [PATCH] compat: Add another rudimentary poll() emulation","fromName":"Marko Kreen","fromEmail":"markokr@gmail.com","sentAt":"2010-05-27T14:11:52Z","receivedAt":"2010-05-27T14:11:52Z","isPatch":true,"sender":{"key":"markokr@gmail.com","avatar":null},"body":"On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n> On Thu, May 27, 2010 at 3:58 PM, Marko Kreen <markokr@gmail.com> wrote:\n>  > On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n>  >> On Thu, May 27, 2010 at 3:29 PM, Marko Kreen <markokr@gmail.com> wrote:\n>  >>  > On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n>  >>  >> On Thu, May 27, 2010 at 1:00 PM, Erik Faye-Lund\n>  >>  >>  <kusmabite@googlemail.com> wrote:\n>  >>  >>  > On Thu, May 27, 2010 at 12:10 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>  >>  >>  >> Implement the subset of poll() semantics needed by git in terms of\n>  >>  >>  >> select(), for use by the Interix port.  Inspired by commit 6ed807f\n>  >>  >>  >> (Windows: A rudimentary poll() emulation, 2007-12-01).\n>  >>  >>  >>\n>  >>  >>  >\n>  >>  >>  > A possible problem with this approach is that the maximum number of\n>  >>  >>  > file descriptors poll can handle limited by RLIMIT_NOFILE, whereas the\n>  >>  >>  > maximum number of file descriptors select can handle is limited by\n>  >>  >>  > FD_SETSIZE.\n>  >>  >>  >\n>  >>  >>  > I don't think this is a big problem in reality, though - both values\n>  >>  >>  > seem to be pretty high in most implementations. And IIRC git-daemon is\n>  >>  >>  > the only one who needs more than 2, and it doesn't even check\n>  >>  >>  > RLIMIT_NOFILE.\n>  >>  >>  >\n>  >>  >>\n>  >>  >>\n>  >>  >> To be clear: I think this strategy is the best option (at least for\n>  >>  >>  non-Windows, where select() might be our only option).\n>  >>  >>\n>  >>  >>  But perhaps you should include a check along the lines of this:\n>  >>  >>\n>  >>  >>  if (nfds > FD_SETSIZE)\n>  >>  >>         return errno = EINVAL, error(\"poll: nfds must be below %d\", FD_SETSIZE);\n>  >>  >>\n>  >>  >>  Just so we can know when the code fails :)\n>  >>  >\n>  >>  > Well, per your own FD_SET example, the FD_SETSIZE on windows\n>  >>  > means different thing than FD_SETSIZE on old-style bitmap-based\n>  >>  > select() implementation.\n>  >>  >\n>  >>  > On Unix, it's max fd number + 1, on windows it's max count.\n>  >>  >\n>  >>\n>  >>\n>  >> Are you sure this applies for all Unix, not just some given Unix-y system?\n>  >\n>  > Not sure.  Just pointing out that the above check is not\n>  > universal enough.\n>  >\n>\n>\n> Isn't it? How could one possibly pass more than max fd number + 1 file\n>  descriptors, since they start at 0? I guess one could specify a given\n>  fd more than once, but that'd be kind of redundant... and also very\n>  unlikely in our case ;)\n\nPass one fd with value 70 it.  Check returns error, although\neverything would work.\n\n-- \nmarko\n"},{"id":"142430","messageId":"AANLkTimn3kxLajKI69E-aE8QInrPArBjEmFxVTWVFUKW@mail.gmail.com","threadId":"23919","inReplyTo":"AANLkTik2UAA51BZWIKadAcIg8t2xg1u980Gq_IOSyz6o@mail.gmail.com","subject":"Re: [msysGit] Re: [PATCH] compat: Add another rudimentary poll() emulation","fromName":"Albert Dvornik","fromEmail":"dvornik@gmail.com","sentAt":"2010-05-27T14:14:32Z","receivedAt":"2010-05-27T14:14:32Z","isPatch":true,"sender":{"key":"dvornik@gmail.com","avatar":null},"body":"On Thu, May 27, 2010 at 9:46 AM, Erik Faye-Lund\n<kusmabite@googlemail.com> wrote:\n> On Thu, May 27, 2010 at 3:29 PM, Marko Kreen <markokr@gmail.com> wrote:\n[...]\n>> Well, per your own FD_SET example, the FD_SETSIZE on windows\n>> means different thing than FD_SETSIZE on old-style bitmap-based\n>> select() implementation.\n\nYes, it sure does.  Once again, Windows seems to be a special, unique\nsnowflake. =)\n\n>> On Unix, it's max fd number + 1, on windows it's max count.\n>>\n>\n> Are you sure this applies for all Unix, not just some given Unix-y system?\n\nWhile I can't make statements about \"all UNIX\" since there are many\nobscure flavors, this is true on Linux, Solaris and various BSD\nderivatives.  It's also what's specified by POSIX:\n\nhttp://www.opengroup.org/onlinepubs/000095399/functions/select.html\n\n--bert\n"},{"id":"142431","messageId":"AANLkTimo2P3JIJ2zhD3QtT2wgfr4WmXPkVVxUDpiOfJH@mail.gmail.com","threadId":"23919","inReplyTo":"AANLkTil-nMo5E2laacYm48-HGbhseEICWsUHwTlc3l47@mail.gmail.com","subject":"Re: [PATCH] compat: Add another rudimentary poll() emulation","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2010-05-27T14:15:01Z","receivedAt":"2010-05-27T14:15:01Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Thu, May 27, 2010 at 4:11 PM, Marko Kreen <markokr@gmail.com> wrote:\n> On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n>> On Thu, May 27, 2010 at 3:58 PM, Marko Kreen <markokr@gmail.com> wrote:\n>>  > On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n>>  >> On Thu, May 27, 2010 at 3:29 PM, Marko Kreen <markokr@gmail.com> wrote:\n>>  >>  > On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n>>  >>  >> On Thu, May 27, 2010 at 1:00 PM, Erik Faye-Lund\n>>  >>  >>  <kusmabite@googlemail.com> wrote:\n>>  >>  >>  > On Thu, May 27, 2010 at 12:10 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>>  >>  >>  >> Implement the subset of poll() semantics needed by git in terms of\n>>  >>  >>  >> select(), for use by the Interix port.  Inspired by commit 6ed807f\n>>  >>  >>  >> (Windows: A rudimentary poll() emulation, 2007-12-01).\n>>  >>  >>  >>\n>>  >>  >>  >\n>>  >>  >>  > A possible problem with this approach is that the maximum number of\n>>  >>  >>  > file descriptors poll can handle limited by RLIMIT_NOFILE, whereas the\n>>  >>  >>  > maximum number of file descriptors select can handle is limited by\n>>  >>  >>  > FD_SETSIZE.\n>>  >>  >>  >\n>>  >>  >>  > I don't think this is a big problem in reality, though - both values\n>>  >>  >>  > seem to be pretty high in most implementations. And IIRC git-daemon is\n>>  >>  >>  > the only one who needs more than 2, and it doesn't even check\n>>  >>  >>  > RLIMIT_NOFILE.\n>>  >>  >>  >\n>>  >>  >>\n>>  >>  >>\n>>  >>  >> To be clear: I think this strategy is the best option (at least for\n>>  >>  >>  non-Windows, where select() might be our only option).\n>>  >>  >>\n>>  >>  >>  But perhaps you should include a check along the lines of this:\n>>  >>  >>\n>>  >>  >>  if (nfds > FD_SETSIZE)\n>>  >>  >>         return errno = EINVAL, error(\"poll: nfds must be below %d\", FD_SETSIZE);\n>>  >>  >>\n>>  >>  >>  Just so we can know when the code fails :)\n>>  >>  >\n>>  >>  > Well, per your own FD_SET example, the FD_SETSIZE on windows\n>>  >>  > means different thing than FD_SETSIZE on old-style bitmap-based\n>>  >>  > select() implementation.\n>>  >>  >\n>>  >>  > On Unix, it's max fd number + 1, on windows it's max count.\n>>  >>  >\n>>  >>\n>>  >>\n>>  >> Are you sure this applies for all Unix, not just some given Unix-y system?\n>>  >\n>>  > Not sure.  Just pointing out that the above check is not\n>>  > universal enough.\n>>  >\n>>\n>>\n>> Isn't it? How could one possibly pass more than max fd number + 1 file\n>>  descriptors, since they start at 0? I guess one could specify a given\n>>  fd more than once, but that'd be kind of redundant... and also very\n>>  unlikely in our case ;)\n>\n> Pass one fd with value 70 it.  Check returns error, although\n> everything would work.\n>\n\nNo, not with the check I posted. I checked nfds, not the value of the\nfds themselves. nfds is clearly the size of the fds array -- if it\nwasn't, it'd be impossible for the poll-implementation to know how big\nthe array is!\n\n-- \nErik \"kusma\" Faye-Lund\n"},{"id":"142433","messageId":"AANLkTilsqlqX0f8_LhXBssCGMuTdS_mCw7V3lVrMb4XK@mail.gmail.com","threadId":"23919","inReplyTo":"AANLkTimo2P3JIJ2zhD3QtT2wgfr4WmXPkVVxUDpiOfJH@mail.gmail.com","subject":"Re: [PATCH] compat: Add another rudimentary poll() emulation","fromName":"Marko Kreen","fromEmail":"markokr@gmail.com","sentAt":"2010-05-27T14:32:59Z","receivedAt":"2010-05-27T14:32:59Z","isPatch":true,"sender":{"key":"markokr@gmail.com","avatar":null},"body":"On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n> On Thu, May 27, 2010 at 4:11 PM, Marko Kreen <markokr@gmail.com> wrote:\n>  > On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n>  >> On Thu, May 27, 2010 at 3:58 PM, Marko Kreen <markokr@gmail.com> wrote:\n>  >>  > On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n>  >>  >> On Thu, May 27, 2010 at 3:29 PM, Marko Kreen <markokr@gmail.com> wrote:\n>  >>  >>  > On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n>  >>  >>  >> On Thu, May 27, 2010 at 1:00 PM, Erik Faye-Lund\n>  >>  >>  >>  <kusmabite@googlemail.com> wrote:\n>  >>  >>  >>  > On Thu, May 27, 2010 at 12:10 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>  >>  >>  >>  >> Implement the subset of poll() semantics needed by git in terms of\n>  >>  >>  >>  >> select(), for use by the Interix port.  Inspired by commit 6ed807f\n>  >>  >>  >>  >> (Windows: A rudimentary poll() emulation, 2007-12-01).\n>  >>  >>  >>  >>\n>  >>  >>  >>  >\n>  >>  >>  >>  > A possible problem with this approach is that the maximum number of\n>  >>  >>  >>  > file descriptors poll can handle limited by RLIMIT_NOFILE, whereas the\n>  >>  >>  >>  > maximum number of file descriptors select can handle is limited by\n>  >>  >>  >>  > FD_SETSIZE.\n>  >>  >>  >>  >\n>  >>  >>  >>  > I don't think this is a big problem in reality, though - both values\n>  >>  >>  >>  > seem to be pretty high in most implementations. And IIRC git-daemon is\n>  >>  >>  >>  > the only one who needs more than 2, and it doesn't even check\n>  >>  >>  >>  > RLIMIT_NOFILE.\n>  >>  >>  >>  >\n>  >>  >>  >>\n>  >>  >>  >>\n>  >>  >>  >> To be clear: I think this strategy is the best option (at least for\n>  >>  >>  >>  non-Windows, where select() might be our only option).\n>  >>  >>  >>\n>  >>  >>  >>  But perhaps you should include a check along the lines of this:\n>  >>  >>  >>\n>  >>  >>  >>  if (nfds > FD_SETSIZE)\n>  >>  >>  >>         return errno = EINVAL, error(\"poll: nfds must be below %d\", FD_SETSIZE);\n>  >>  >>  >>\n>  >>  >>  >>  Just so we can know when the code fails :)\n>  >>  >>  >\n>  >>  >>  > Well, per your own FD_SET example, the FD_SETSIZE on windows\n>  >>  >>  > means different thing than FD_SETSIZE on old-style bitmap-based\n>  >>  >>  > select() implementation.\n>  >>  >>  >\n>  >>  >>  > On Unix, it's max fd number + 1, on windows it's max count.\n>  >>  >>  >\n>  >>  >>\n>  >>  >>\n>  >>  >> Are you sure this applies for all Unix, not just some given Unix-y system?\n>  >>  >\n>  >>  > Not sure.  Just pointing out that the above check is not\n>  >>  > universal enough.\n>  >>  >\n>  >>\n>  >>\n>  >> Isn't it? How could one possibly pass more than max fd number + 1 file\n>  >>  descriptors, since they start at 0? I guess one could specify a given\n>  >>  fd more than once, but that'd be kind of redundant... and also very\n>  >>  unlikely in our case ;)\n>  >\n>  > Pass one fd with value 70 it.  Check returns error, although\n>  > everything would work.\n>  >\n>\n>\n> No, not with the check I posted. I checked nfds, not the value of the\n>  fds themselves. nfds is clearly the size of the fds array -- if it\n>  wasn't, it'd be impossible for the poll-implementation to know how big\n>  the array is!\n\nAh, ok.  I though this is the nfds for select().  In this case it can\nstill fail, as nfds=1 for poll() can still go over FD_SETSIZE for\nselect() if the fd value is big enough.  On non-windows, that is.\n\nDunno if this matters for git-daemon..\n\n-- \nmarko\n"},{"id":"142435","messageId":"AANLkTin8MTa5zUhqh3dOfNN0nmI2kAeiqNreYn7TZnf1@mail.gmail.com","threadId":"23919","inReplyTo":"AANLkTilsqlqX0f8_LhXBssCGMuTdS_mCw7V3lVrMb4XK@mail.gmail.com","subject":"Re: [PATCH] compat: Add another rudimentary poll() emulation","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2010-05-27T14:44:03Z","receivedAt":"2010-05-27T14:44:03Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Thu, May 27, 2010 at 4:32 PM, Marko Kreen <markokr@gmail.com> wrote:\n> On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n>> On Thu, May 27, 2010 at 4:11 PM, Marko Kreen <markokr@gmail.com> wrote:\n>>  > On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n>>  >> On Thu, May 27, 2010 at 3:58 PM, Marko Kreen <markokr@gmail.com> wrote:\n>>  >>  > On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n>>  >>  >> On Thu, May 27, 2010 at 3:29 PM, Marko Kreen <markokr@gmail.com> wrote:\n>>  >>  >>  > On 5/27/10, Erik Faye-Lund <kusmabite@googlemail.com> wrote:\n>>  >>  >>  >> On Thu, May 27, 2010 at 1:00 PM, Erik Faye-Lund\n>>  >>  >>  >>  <kusmabite@googlemail.com> wrote:\n>>  >>  >>  >>  > On Thu, May 27, 2010 at 12:10 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>>  >>  >>  >>  >> Implement the subset of poll() semantics needed by git in terms of\n>>  >>  >>  >>  >> select(), for use by the Interix port.  Inspired by commit 6ed807f\n>>  >>  >>  >>  >> (Windows: A rudimentary poll() emulation, 2007-12-01).\n>>  >>  >>  >>  >>\n>>  >>  >>  >>  >\n>>  >>  >>  >>  > A possible problem with this approach is that the maximum number of\n>>  >>  >>  >>  > file descriptors poll can handle limited by RLIMIT_NOFILE, whereas the\n>>  >>  >>  >>  > maximum number of file descriptors select can handle is limited by\n>>  >>  >>  >>  > FD_SETSIZE.\n>>  >>  >>  >>  >\n>>  >>  >>  >>  > I don't think this is a big problem in reality, though - both values\n>>  >>  >>  >>  > seem to be pretty high in most implementations. And IIRC git-daemon is\n>>  >>  >>  >>  > the only one who needs more than 2, and it doesn't even check\n>>  >>  >>  >>  > RLIMIT_NOFILE.\n>>  >>  >>  >>  >\n>>  >>  >>  >>\n>>  >>  >>  >>\n>>  >>  >>  >> To be clear: I think this strategy is the best option (at least for\n>>  >>  >>  >>  non-Windows, where select() might be our only option).\n>>  >>  >>  >>\n>>  >>  >>  >>  But perhaps you should include a check along the lines of this:\n>>  >>  >>  >>\n>>  >>  >>  >>  if (nfds > FD_SETSIZE)\n>>  >>  >>  >>         return errno = EINVAL, error(\"poll: nfds must be below %d\", FD_SETSIZE);\n>>  >>  >>  >>\n>>  >>  >>  >>  Just so we can know when the code fails :)\n>>  >>  >>  >\n>>  >>  >>  > Well, per your own FD_SET example, the FD_SETSIZE on windows\n>>  >>  >>  > means different thing than FD_SETSIZE on old-style bitmap-based\n>>  >>  >>  > select() implementation.\n>>  >>  >>  >\n>>  >>  >>  > On Unix, it's max fd number + 1, on windows it's max count.\n>>  >>  >>  >\n>>  >>  >>\n>>  >>  >>\n>>  >>  >> Are you sure this applies for all Unix, not just some given Unix-y system?\n>>  >>  >\n>>  >>  > Not sure.  Just pointing out that the above check is not\n>>  >>  > universal enough.\n>>  >>  >\n>>  >>\n>>  >>\n>>  >> Isn't it? How could one possibly pass more than max fd number + 1 file\n>>  >>  descriptors, since they start at 0? I guess one could specify a given\n>>  >>  fd more than once, but that'd be kind of redundant... and also very\n>>  >>  unlikely in our case ;)\n>>  >\n>>  > Pass one fd with value 70 it.  Check returns error, although\n>>  > everything would work.\n>>  >\n>>\n>>\n>> No, not with the check I posted. I checked nfds, not the value of the\n>>  fds themselves. nfds is clearly the size of the fds array -- if it\n>>  wasn't, it'd be impossible for the poll-implementation to know how big\n>>  the array is!\n>\n> Ah, ok.  I though this is the nfds for select().  In this case it can\n> still fail, as nfds=1 for poll() can still go over FD_SETSIZE for\n> select() if the fd value is big enough.  On non-windows, that is.\n>\n\nI don't quite get where one would get a fd that's value is FD_SETSIZE\nor above from. I mean, FD_SETSIZE would have to be the maximum value\nof a file descriptor, or else you risk open() or socket() returning\nfile descriptors that cannot be select()'ed. Which would just be\ninsane, no?\n\n-- \nErik \"kusma\" Faye-Lund\n"},{"id":"142442","messageId":"A612847CFE53224C91B23E3A5B48BAC74483678383@xmail3.se.axis.com","threadId":"23919","inReplyTo":"AANLkTin8MTa5zUhqh3dOfNN0nmI2kAeiqNreYn7TZnf1@mail.gmail.com","subject":"RE: [PATCH] compat: Add another rudimentary poll() emulation","fromName":"Peter Kjellerstedt","fromEmail":"peter.kjellerstedt@axis.com","sentAt":"2010-05-27T15:17:54Z","receivedAt":"2010-05-27T15:17:54Z","isPatch":true,"sender":{"key":"peter.kjellerstedt@axis.com","avatar":"https://gravatar.com/avatar/6d5a0182283c8eccd7b134a54dbfd5f30038f3ad4d38b96f424884b614a61ca2?d=mp&s=160"},"body":"> -----Original Message-----\n> From: git-owner@vger.kernel.org [mailto:git-owner@vger.kernel.org] On\n> Behalf Of Erik Faye-Lund\n> Sent: den 27 maj 2010 16:44\n> To: Marko Kreen\n> Cc: Jonathan Nieder; Jonathan Callen; git@vger.kernel.org;\n> mduft@gentoo.org; Sverre Rabbelier; Michael J Gruber; Johannes Sixt;\n> msysGit\n> Subject: Re: [PATCH] compat: Add another rudimentary poll() emulation\n> \n> On Thu, May 27, 2010 at 4:32 PM, Marko Kreen <markokr@gmail.com> wrote:\n\n[cut]\n\n> > Ah, ok.  I though this is the nfds for select().  In this case it can\n> > still fail, as nfds=1 for poll() can still go over FD_SETSIZE for\n> > select() if the fd value is big enough.  On non-windows, that is.\n> \n> I don't quite get where one would get a fd that's value is FD_SETSIZE\n> or above from. I mean, FD_SETSIZE would have to be the maximum value\n> of a file descriptor, or else you risk open() or socket() returning\n> file descriptors that cannot be select()'ed. Which would just be\n> insane, no?\n> \n> --\n> Erik \"kusma\" Faye-Lund\n\nThat is exactly how e.g. Linux works. If your application can have more \nthan 1024 file descriptors open simultaneously, you are restricted to \nuse poll() as you risk having a file descriptor with a value >= 1024.\nAnd using FD_SET() with a file descriptor >= 1024 will trash memory...\n\n//Peter\n"},{"id":"142480","messageId":"m3mxvkrcyf.fsf@localhost.localdomain","threadId":"23919","inReplyTo":"1274948384-167-1-git-send-email-abcd@gentoo.org","subject":"Re: [PATCH 0/3] Interix support","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-05-28T02:11:42Z","receivedAt":"2010-05-28T02:11:42Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Jonathan Callen <abcd@gentoo.org> writes:\n\n> This series of patches adds support for building git on Interix.\n> \n> Interix is an interesting system, as it lacks some functions that are\n> normally present on POSIX systems, such as poll().  As I did not have\n> time to implement poll() on top of select(), these patches simply\n> disable the three commands that require poll() to be present:\n> git-daemon, git-upload-archive, and git-upload-pack.\n> \n> Jonathan Callen (3):\n>       Support building on systems without poll(2)\n>       Support building without inttypes.h\n>       Add Interix support\n> \n>  Makefile          |   40 +++++++++++++++++++++++++++++++++++-----\n>  builtin.h         |    2 ++\n>  git-compat-util.h |    6 ++++++\n>  git.c             |    2 ++\n>  4 files changed, 45 insertions(+), 5 deletions(-)\n\nCould you please, if you can, add support for detecting existence of\npoll(2) and existence of inttypes.h to configure.ac, to make it\nautomatically detected by\n\n  $ make configure\n  $ ./configure [options]\n\nThanks in advance.\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"142547","messageId":"20100530003718.GA27024@progeny.tock","threadId":"23919","inReplyTo":"AANLkTikezlVaX8ARkRw8kEk9wL9RL_5I6X3vK83nzFUl@mail.gmail.com","subject":"[PATCH v2] compat: Add another rudimentary poll() emulation","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-05-30T00:37:18Z","receivedAt":"2010-05-30T00:37:18Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Implement the subset of poll() semantics needed by git in terms of\nselect(), for use by the Interix port.  Inspired by commit 6ed807f\n(Windows: A rudimentary poll() emulation, 2007-12-01).\n\nThis will only poll on descriptors with value <= the maximum fd that\nselect() can portably handle, FD_SETSIZE - 1.  On Windows (and not on\nUnix), in principle git could permit higher fds as long as the number\nof descriptors used in a single select() call was limited to\nFD_SETSIZE; but such a facility would be rarely used, since the number\nof sockets the ‘git daemon’ parent process keeps open tends to be very\nsmall.\n\nHelped-by: Erik Faye-Lund <kusmabite@googlemail.com>\nCc: Johannes Sixt <j6t@kdbg.org>\nCc: Jonathan Callen <abcd@gentoo.org>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nErik Faye-Lund wrote:\n\n> But perhaps you should include a check along the lines of this:\n> \n> if (nfds > FD_SETSIZE)\n> \treturn errno = EINVAL, error(\"poll: nfds must be below %d\", FD_SETSIZE);\n> \n> Just so we can know when the code fails :)\n\nGood catch, thanks.  I opted to check each fd instead so the NO_POLL\ncode can be safely used on Unix for debugging.\n\nOther changes from v1:\n\n . use COMPAT_CFLAGS instead of BASIC_CFLAGS\n . timeout is a number of milliseconds, not seconds\n . lightly tested on Linux\n\nI would be interested to hear whether this works on msysgit and Interix.\nThanks again for the help.\n\n Makefile          |    8 +++++++\n compat/poll.c     |   56 +++++++++++++++++++++++++++++++++++++++++++++++++++++\n compat/poll.h     |   13 ++++++++++++\n git-compat-util.h |    6 ++++-\n 4 files changed, 82 insertions(+), 1 deletions(-)\n create mode 100644 compat/poll.c\n create mode 100644 compat/poll.h\n\ndiff --git a/Makefile b/Makefile\nindex 2f5d631..ed9f03b 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -111,6 +111,9 @@ all::\n #\n # Define NO_PTHREADS if you do not have or do not want to use Pthreads.\n #\n+# Define NO_POLL if you have a problem with the poll() system call (e.g.\n+# Interix).\n+#\n # Define NO_PREAD if you have a problem with pread() system call (e.g.\n # cygwin1.dll before v1.5.22).\n #\n@@ -470,6 +473,7 @@ LIB_H += commit.h\n LIB_H += compat/bswap.h\n LIB_H += compat/cygwin.h\n LIB_H += compat/mingw.h\n+LIB_H += compat/poll.h\n LIB_H += compat/win32/pthread.h\n LIB_H += csum-file.h\n LIB_H += decorate.h\n@@ -1284,6 +1288,10 @@ endif\n ifdef OBJECT_CREATION_USES_RENAMES\n \tCOMPAT_CFLAGS += -DOBJECT_CREATION_MODE=1\n endif\n+ifdef NO_POLL\n+\tCOMPAT_CFLAGS += -DNO_POLL\n+\tCOMPAT_OBJS += compat/poll.o\n+endif\n ifdef NO_PREAD\n \tCOMPAT_CFLAGS += -DNO_PREAD\n \tCOMPAT_OBJS += compat/pread.o\ndiff --git a/compat/poll.c b/compat/poll.c\nnew file mode 100644\nindex 0000000..0b3c2ae\n--- /dev/null\n+++ b/compat/poll.c\n@@ -0,0 +1,56 @@\n+#include \"../git-compat-util.h\"\n+\n+static int msleep(int timeout)\n+{\n+\tstruct timeval tv;\n+\ttv.tv_sec = 0;\n+\ttv.tv_usec = 1000 * timeout;\n+\treturn select(0, NULL, NULL, NULL, &tv);\n+}\n+\n+static int validate_fd(const struct git_pollfd *ufd)\n+{\n+\tconst int fd = ufd->fd;\n+\tif (ufd->events != POLLIN) {\n+\t\terrno = EINVAL;\n+\t\treturn error(\"poll: unsupported events\");\n+\t}\n+\tif (fd >= FD_SETSIZE) {\n+\t\terrno = EINVAL;\n+\t\treturn error(\"poll: fd must be below %d\", FD_SETSIZE);\n+\t}\n+\treturn fd;\n+}\n+\n+int git_poll(struct git_pollfd *ufds, int nfds, int timeout)\n+{\n+\tint i, maxfd, result;\n+\tfd_set fds;\n+\n+\tif (timeout >= 0) {\n+\t\tif (nfds != 0) {\n+\t\t\terrno = EINVAL;\n+\t\t\treturn error(\"poll timeout not supported\");\n+\t\t}\n+\t\treturn msleep(timeout);\n+\t}\n+\n+\tFD_ZERO(&fds);\n+\tmaxfd = -1;\n+\tfor (i = 0; i < nfds; i++) {\n+\t\tconst int fd = validate_fd(&ufds[i]);\n+\t\tif (fd < 0)\n+\t\t\treturn fd;\n+\t\tmaxfd = (fd > maxfd) ? fd : maxfd;\n+\t\tFD_SET(fd, &fds);\n+\t}\n+\n+\tresult = select(maxfd + 1, &fds, NULL, NULL, NULL);\n+\tif (result < 0)\n+\t\treturn result;\n+\tfor (i = 0; i < nfds; i++) {\n+\t\tif (FD_ISSET(ufds[i].fd, &fds))\n+\t\t\tufds[i].revents |= POLLIN;\n+\t}\n+\treturn result;\n+}\ndiff --git a/compat/poll.h b/compat/poll.h\nnew file mode 100644\nindex 0000000..65775ab\n--- /dev/null\n+++ b/compat/poll.h\n@@ -0,0 +1,13 @@\n+#ifndef POLLIN\n+#define POLLIN 1\n+#define POLLHUP 2\n+#endif\n+\n+#define pollfd git_pollfd\n+#define poll git_poll\n+struct git_pollfd {\n+\tint fd;\t\t/* file descriptor */\n+\tshort events;\t/* requested events */\n+\tshort revents;\t/* returned events */\n+};\n+extern int git_poll(struct git_pollfd *fds, int nfds, int timeout);\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 824c175..2494378 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -94,13 +94,17 @@\n #include <utime.h>\n #ifndef __MINGW32__\n #include <sys/wait.h>\n-#include <sys/poll.h>\n #include <sys/socket.h>\n #include <sys/ioctl.h>\n #include <termios.h>\n #ifndef NO_SYS_SELECT_H\n #include <sys/select.h>\n #endif\n+#ifdef NO_POLL\n+#include \"compat/poll.h\"\n+#else\n+#include <sys/poll.h>\n+#endif\n #include <netinet/in.h>\n #include <netinet/tcp.h>\n #include <arpa/inet.h>\n-- \n1.7.1\n"},{"id":"142555","messageId":"4C021755.8090307@gnu.org","threadId":"23919","inReplyTo":"AANLkTinX8nK68rZtN5dwJ-fGQm4gR2G84xo9raxb4vLY@mail.gmail.com","subject":"Re: [PATCH] compat: Add another rudimentary poll() emulation","fromName":"Paolo Bonzini","fromEmail":"bonzini@gnu.org","sentAt":"2010-05-30T07:44:21Z","receivedAt":"2010-05-30T07:44:21Z","isPatch":true,"sender":{"key":"bonzini@gnu.org","avatar":"https://avatars.githubusercontent.com/u/42082?v=4"},"body":"On 05/27/2010 02:36 PM, Marko Kreen wrote:\n> Hm, good catch.  Seems such compat poll() cannot be done without\n> OS-specific hacks.\n>\n> Do you know perhaps what other OS-es have non-bitmap fd_set?\n\nI don't think any does.  Winsock needed that because its fd_sets host \nhandles instead of small integers.\n\nPaolo\n"},{"id":"142580","messageId":"201005302119.30340.j6t@kdbg.org","threadId":"23919","inReplyTo":"20100530003718.GA27024@progeny.tock","subject":"Re: [PATCH v2] compat: Add another rudimentary poll() emulation","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2010-05-30T19:19:30Z","receivedAt":"2010-05-30T19:19:30Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Sonntag, 30. Mai 2010, Jonathan Nieder wrote:\n> I would be interested to hear whether this works on msysgit and Interix.\n\nIt cannot work on msysgit because\n\n- on Windows, select() works only for sockets, but we poll() on pipes, too;\n\n- in our emulation layer, fds that are sockets must be unpacked with \n_get_osfhandle() before they can be passed to FD_SET() because (as Paolo has \npointed out) FD_SET() must be populated with handles, not fds.\n\n-- Hannes\n"},{"id":"142584","messageId":"20100530204044.GB32728@progeny.tock","threadId":"23919","inReplyTo":"201005302119.30340.j6t@kdbg.org","subject":"Re: [PATCH v2] compat: Add another rudimentary poll() emulation","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-05-30T20:40:44Z","receivedAt":"2010-05-30T20:40:44Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Johannes Sixt wrote:\n\n> It cannot work on msysgit because\n> \n> - on Windows, select() works only for sockets, but we poll() on pipes, too;\n> \n> - in our emulation layer, fds that are sockets must be unpacked with \n> _get_osfhandle() before they can be passed to FD_SET() because (as Paolo has \n> pointed out) FD_SET() must be populated with handles, not fds.\n\nThanks for the explanation.  Alas.\n\n>From <http://www.suacommunity.com/man/2/select.2.html> I get the\nimpression that FD_SETSIZE on Interix might not be so small after all\n(good).  Apparently older versions of Interix (5.3?) do not obey\ntimeouts properly, so the poll() in compat/poll.c should probably use\nusleep() instead (meh).\n\nAnyway, I leave it to developers on that platform to take it from here\nif they so wish.\n\nCiao,\nJonathan\n"},{"id":"142595","messageId":"67A778DE-DB7E-40A3-9BE8-4D17F09B847F@gmail.com","threadId":"23919","inReplyTo":"20100530003718.GA27024@progeny.tock","subject":"Re: [PATCH v2] compat: Add another rudimentary poll() emulation","fromName":"Joshua Juran","fromEmail":"jjuran@gmail.com","sentAt":"2010-05-30T22:39:42Z","receivedAt":"2010-05-30T22:39:42Z","isPatch":true,"sender":{"key":"jjuran@gmail.com","avatar":null},"body":"On May 29, 2010, at 5:37 PM, Jonathan Nieder wrote:\n\n> Implement the subset of poll() semantics needed by git in terms of\n> select(), for use by the Interix port.  Inspired by commit 6ed807f\n> (Windows: A rudimentary poll() emulation, 2007-12-01).\n>\n> I would be interested to hear whether this works on msysgit and  \n> Interix.\n\nFor what it's worth, after creating a poll_compat library for Lamp  \n(Lamp ain't Mac POSIX) from the original plproxy code and linking git  \nagainst it, I'm able to serve fetch requests from git daemon.  I  \nhaven't tried simultaneous connections, though.\n\nhttp://github.com/jjuran/git/\n\nJosh\n"},{"id":"142599","messageId":"20100531031906.GA465@progeny.tock","threadId":"23919","inReplyTo":"67A778DE-DB7E-40A3-9BE8-4D17F09B847F@gmail.com","subject":"Mac OS 9 (Lamp) port","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-05-31T03:19:06Z","receivedAt":"2010-05-31T03:19:06Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"[new thread, cleared cc list]\n\nHi Josh,\n\nJoshua Juran wrote:\n\n> http://github.com/jjuran/git.git\n\nI assume the lamp-git branch is the interesting one.  Some of\nthese patches (e.g., a3b378781) look like they might be of general\ninterest, while others (e.g., 6e6b106d) reveal Metrowerks to be\na bit braindead.\n\nHave you thought about getting git to compile in C++ mode, where\nMetrowerks might be a little more sane[1]?  Sure, this runs into\nbasically all the major incompatibilities between C and C++[2], but\nthat might not be insurmountable:\n\n . No implicit conversion from void* to other: don’t use void *,\n   then.  With type-safe interfaces like\n\n#define typed_malloc(size, type) (type *)xmalloc(size)\n#define malloc_many(nmemb, type) typed_malloc((nmemb) * sizeof(type), type)\n\n   one can take advantage of type checking without the annoyance of\n   casts at the call site.\n\n   Another place git uses void * is for low-level access to the\n   object database, because it is not obvious whether objects data\n   should use char * or unsigned char *.  unsigned char * should\n   be fine.\n\n . Use of C++ keywords:\n\n#ifdef __cplusplus\n#define template git_template\n#define typename git_typename\n#endif\n\n   It is not like this is an actual C++ program.\n\n . Assignment of ints to enums is forbidden: okay, this one is\n   not worth working around.  Does Metrowerks have an option to turn\n   off this piece of C++ insanity?\n\nCurious,\nJonathan\n\n[1] e.g., to solve the problem you described before:\nhttp://thread.gmane.org/gmane.comp.version-control.git/115301\n\n[2] http://www2.research.att.com/~bs/bs_faq.html#merge\n"},{"id":"142600","messageId":"2776E3E5-234F-4A94-B06A-F4D83D87A414@gmail.com","threadId":"23919","inReplyTo":"20100531031906.GA465@progeny.tock","subject":"Re: Mac OS 9 (Lamp) port","fromName":"Joshua Juran","fromEmail":"jjuran@gmail.com","sentAt":"2010-05-31T04:35:58Z","receivedAt":"2010-05-31T04:35:58Z","isPatch":false,"sender":{"key":"jjuran@gmail.com","avatar":null},"body":"On May 30, 2010, at 8:19 PM, Jonathan Nieder wrote:\n\n> Joshua Juran wrote:\n>\n>> http://github.com/jjuran/git.git\n\nApparently <http://github.com/jjuran/git> works better.\n\n> I assume the lamp-git branch is the interesting one.  Some of\n\nThe lamp-git branch is the one you'd checkout to build git.  It  \nmerges the interesting ones.\n\n> these patches (e.g., a3b378781) look like they might be of general\n\n$ git show a3b378781\ncommit a3b378781228d59a13ee055d06c8f5465b543178\nAuthor: Joshua Juran <jjuran@metamage.com>\nDate:   Sun Nov 29 03:57:54 2009 -0800\n\n     Avoid pointless use of one-celled array (which also confounds  \nMetrowerks C).\n\n     Pass the address of fetch_refspec_str directly to  \nparse_refspec_internal()\n     instead of copying fetch_refspec_str to an array and passing that.\n\n     Metrowerks C won't initialize aggregates with values determined  \nat runtime, and\n     we can't use the C++ translator for parse_refspec_internal()  \nbecause it uses the\n     same identifier (refspec) for a variable as an existing struct  \ntype.\n\n     That, and there's no purpose to the array in the first place.\n\ndiff --git a/remote.c b/remote.c\nindex c70181c..ade0424 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -657,10 +657,9 @@ static struct refspec *parse_refspec_internal \n(int nr_refspec, const char **refsp\n\n  int valid_fetch_refspec(const char *fetch_refspec_str)\n  {\n-       const char *fetch_refspec[] = { fetch_refspec_str };\n         struct refspec *refspec;\n\n-       refspec = parse_refspec_internal(1, fetch_refspec, 1, 1);\n+       refspec = parse_refspec_internal(1, &fetch_refspec_str, 1, 1);\n         free_refspecs(refspec, 1);\n         return !!refspec;\n  }\n\nYes, this is the patch I suggested to Gary V. Vaughan.\n\n> interest, while others (e.g., 6e6b106d) reveal Metrowerks to be\n> a bit braindead.\n\n$ git show 6e6b106d\ncommit 6e6b106dd6c561db726f90e2db07beeef1f716f9\nAuthor: Joshua Juran <jjuran@metamage.com>\nDate:   Wed Apr 8 01:51:04 2009 -0700\n\n     Cast compare_info() arguments to (const struct pack_info *const *).\n\n     Otherwise, Metrowerks C reports \"illegal implicit conversion  \nfrom 'const void *'\n     to 'struct pack_info *const *'\".\n\ndiff --git a/server-info.c b/server-info.c\nindex 4098ca2..a9a0188 100644\n--- a/server-info.c\n+++ b/server-info.c\n@@ -132,8 +132,8 @@ static int read_pack_info_file(const char *infofile)\n\n  static int compare_info(const void *a_, const void *b_)\n  {\n-       struct pack_info *const *a = a_;\n-       struct pack_info *const *b = b_;\n+       const struct pack_info *const *a = a_;\n+       const struct pack_info *const *b = b_;\n\n         if (0 <= (*a)->old_num && 0 <= (*b)->old_num)\n                 /* Keep the order in the original */\n\nI certainly won't defend Metrowerks C 2.4.1, but the patch is  \nharmless enough.\n\n> Have you thought about getting git to compile in C++ mode, where\n\nIf the Git maintainers are interested in this, I'm glad to do it.  I  \nexpect it to require generally less maintenance than my c++- \ninitializer-fix branch, which is rather ugly to boot.\n\n> Metrowerks might be a little more sane[1]?  Sure, this runs into\n\nWell, I wasn't going to suggest general C++ compatibility just for my  \nport, but if there's interest, then yes, that would obviate my (by  \nfar) largest and nastiest patch.\n\n> basically all the major incompatibilities between C and C++[2], but\n> that might not be insurmountable:\n\nWriting code which is both valid C and valid C++ is not difficult.\n\n>  . No implicit conversion from void* to other: don’t use void *,\n>    then.  With type-safe interfaces like\n>\n> #define typed_malloc(size, type) (type *)xmalloc(size)\n> #define malloc_many(nmemb, type) typed_malloc((nmemb) * sizeof \n> (type), type)\n>\n>    one can take advantage of type checking without the annoyance of\n>    casts at the call site.\n\nReplacing xmalloc(size) with typed_malloc(size, struct foo) instead  \nof (struct foo *)xmalloc(size) still feels like a cast to me.  IMHO  \nit adds no safety and reduces readability.\n\nMaybe you could have:\n\n\t#define alloc_n(type, n)  ((type*)xmalloc(sizeof (type) * n))\n\nto factor the multiplication out of the calling code.  But for a  \nplain data buffer, nothing is shorter or clearer than a simple  \n(char*) cast.\n\n>    Another place git uses void * is for low-level access to the\n>    object database, because it is not obvious whether objects data\n>    should use char * or unsigned char *.  unsigned char * should\n>    be fine.\n\nIf there were a configurable typedef defining this, I'd use char*  \nsince the Metrowerks debugger by default displays it as a C string  \n(as opposed to a Pascal string for unsigned char* -- it's a Mac OS  \nconvention).  But that's a minor point and not one I'd spend time  \nadvocating.\n\n>  . Use of C++ keywords:\n>\n> #ifdef __cplusplus\n> #define template git_template\n> #define typename git_typename\n> #endif\n>\n>    It is not like this is an actual C++ program.\n\nMy c++initializer-fix patch does this locally in a few places.  I  \nsuppose it makes sense to nail them all at once in git-compat-util.h.\n\n>  . Assignment of ints to enums is forbidden: okay, this one is\n>    not worth working around.  Does Metrowerks have an option to turn\n>    off this piece of C++ insanity?\n\nIt's a feature.  :-)  I use enums for type-safety in my C++ POSIX  \nwrapper library.  p7::wait() returns p7::wait_t, and if you try to  \npass that to p7::exit() (which takes p7::exit_t) you get a compile  \nerror (instead of a program that 'works' when the wait status is zero).\n\n(No, I'm not aware of an option to disable this restriction.)\n\nIf you want the type-safety, you have to pay for it.  Otherwise,  \ndeclare variables and parameters as integral types instead.  I don't  \ncare one way or the other -- I just want git to work on Lamp, and if  \nthere's community interest in C++ compatibility then I can assist  \nwith that.\n\nJosh\n\nP.S.  Every patch in my git repository is Signed-off-by: Joshua Juran  \n<jjuran@gmail.com> (or s/gmail/metamage/).\n"},{"id":"142601","messageId":"20100531054947.GB3328@progeny.tock","threadId":"23919","inReplyTo":"2776E3E5-234F-4A94-B06A-F4D83D87A414@gmail.com","subject":"Re: Mac OS 9 (Lamp) port","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-05-31T05:49:48Z","receivedAt":"2010-05-31T05:49:48Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Joshua Juran wrote:\n\n> diff --git a/server-info.c b/server-info.c\n> index 4098ca2..a9a0188 100644\n> --- a/server-info.c\n> +++ b/server-info.c\n> @@ -132,8 +132,8 @@ static int read_pack_info_file(const char *infofile)\n> \n>  static int compare_info(const void *a_, const void *b_)\n>  {\n> -       struct pack_info *const *a = a_;\n> -       struct pack_info *const *b = b_;\n> +       const struct pack_info *const *a = a_;\n> +       const struct pack_info *const *b = b_;\n> \n>         if (0 <= (*a)->old_num && 0 <= (*b)->old_num)\n>                 /* Keep the order in the original */\n> \n> I certainly won't defend Metrowerks C 2.4.1, but the patch is\n> harmless enough.\n\nYes, it is even a good change.\n\nIt just emphasized for me that Metrowerks is a little confused\nabout type qualifiers.\n\n> \t#define alloc_n(type, n)  ((type*)xmalloc(sizeof (type) * n))\n> \n> to factor the multiplication out of the calling code.\n\nMaybe, imitating the signature of calloc:\n\n #define malloc_n(n, type) ((type *)xmalloc((n) * sizeof(type)))\n\nFor structs with variable-length arrays at the end:\n\n #define malloc_plus(type, extra) ((type *)xmalloc(sizeof(type) + (extra)))\n\nThat should cover most of the calls in git.\n\n> I just want git to work on Lamp, and if\n> there's community interest in C++ compatibility then I can assist\n> with that.\n\nThere probably is not much direct interest.  But if in the process we\ngain a little type-safety and portability, that would be nice. :)\n\nThanks for your hard work,\nJonathan\n"},{"id":"142607","messageId":"AANLkTinNHDZD-9uQjWr8N97tgP1SP9angXlXMUUc673x@mail.gmail.com","threadId":"23919","inReplyTo":"20100530003718.GA27024@progeny.tock","subject":"Re: [PATCH v2] compat: Add another rudimentary poll() emulation","fromName":"Albert Dvornik","fromEmail":"dvornik+git@gmail.com","sentAt":"2010-05-31T12:12:01Z","receivedAt":"2010-05-31T12:12:01Z","isPatch":true,"sender":{"key":"dvornik+git@gmail.com","avatar":null},"body":"On Sat, May 29, 2010 at 8:37 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n[,,,]\n> +static int msleep(int timeout)\n> +{\n> +       struct timeval tv;\n> +       tv.tv_sec = 0;\n> +       tv.tv_usec = 1000 * timeout;\n> +       return select(0, NULL, NULL, NULL, &tv);\n> +}\n\nThis code will do the right thing only when timeout is < 1000.  (This\nis probably true for us in practice, so this is likely just\nnitpicking.)  For the general case, you'd want\n       tv.tv_sec = timeout / 1000;\n       tv.tv_usec = 1000 * (timeout % 1000);\n\n--bert\n"},{"id":"142610","messageId":"20100531124615.GA2864@progeny.tock","threadId":"23919","inReplyTo":"AANLkTinNHDZD-9uQjWr8N97tgP1SP9angXlXMUUc673x@mail.gmail.com","subject":"Re: [PATCH v2] compat: Add another rudimentary poll() emulation","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-05-31T12:46:15Z","receivedAt":"2010-05-31T12:46:15Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Albert Dvornik wrote:\n\n> For the general case, you'd want\n>        tv.tv_sec = timeout / 1000;\n>        tv.tv_usec = 1000 * (timeout % 1000);\n\nThanks for the catch.  Actually, it is not so unlikely that someone\nwould ask the autocorrect to wait longer than a second.\n\nOn Linux this is not an issue, but maybe Interix cares.  Posix is\nvague and only says \"the timeout period is given in seconds and\nmicroseconds\", staying silent on what the range of valid values is.\n\nJonathan\n"},{"id":"142611","messageId":"AANLkTimJXEg08AlDIbPYsRZFXSDFPhN1SB6OxMyaM5PE@mail.gmail.com","threadId":"23919","inReplyTo":"20100531124615.GA2864@progeny.tock","subject":"Re: [PATCH v2] compat: Add another rudimentary poll() emulation","fromName":"Albert Dvornik","fromEmail":"dvornik+git@gmail.com","sentAt":"2010-05-31T13:10:18Z","receivedAt":"2010-05-31T13:10:18Z","isPatch":true,"sender":{"key":"dvornik+git@gmail.com","avatar":null},"body":"On Mon, May 31, 2010 at 8:46 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Albert Dvornik wrote:\n>\n>> For the general case, you'd want\n>>        tv.tv_sec = timeout / 1000;\n>>        tv.tv_usec = 1000 * (timeout % 1000);\n>\n> Thanks for the catch.  Actually, it is not so unlikely that someone\n> would ask the autocorrect to wait longer than a second.\n\nGood point, I take back what I said. =)\n\n> On Linux this is not an issue, but maybe Interix cares.  Posix is\n> vague and only says \"the timeout period is given in seconds and\n> microseconds\", staying silent on what the range of valid values is.\n\nSome traditional UNIXes are actually picky about the usec range, or at\nleast used to be (I seem to recall BSD and/or Solaris, but I really\ndon't remember for sure, this was a long time ago).\n\n--bert\n"}]}