{"thread":{"id":"39464","subject":"[PATCH mh/lockfile-retry] lockfile: replace random() by rand()","startedAt":"2015-05-30T06:23:44Z","lastAt":"2015-06-05T20:14:39Z","messageCount":12,"participants":["Johannes Sixt","Junio C Hamano","Michael Haggerty"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"262461","messageId":"55695770.2040303@kdbg.org","threadId":"39464","inReplyTo":null,"subject":"[PATCH mh/lockfile-retry] lockfile: replace random() by rand()","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2015-05-30T06:23:44Z","receivedAt":"2015-05-30T06:23:44Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Windows, we do not have functions srandom() and random(). Use srand()\nand rand(). These functions produce random numbers of lesser quality,\nbut for the purpose (a retry time-out) they are still good enough.\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\nThere you have it: Look the other way for a while, and people start\nusing exotic stuff... ;)\n\nThis is a build breakage of master on Windows. There are also a few\nnew test suite failures. On of them is in t1404#2, indicating that\na DF conflict takes a different error path. I haven't debugged, yet.\nThe lock file retry test fails, too. I'll report back as time permits.\n\n lockfile.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/lockfile.c b/lockfile.c\nindex 5a93bc7..ee5cb01 100644\n--- a/lockfile.c\n+++ b/lockfile.c\n@@ -191,7 +191,7 @@ static int lock_file_timeout(struct lock_file *lk, const char *path,\n \t\treturn lock_file(lk, path, flags);\n \n \tif (!random_initialized) {\n-\t\tsrandom((unsigned int)getpid());\n+\t\tsrand((unsigned int)getpid());\n \t\trandom_initialized = 1;\n \t}\n \n@@ -218,7 +218,7 @@ static int lock_file_timeout(struct lock_file *lk, const char *path,\n \n \t\tbackoff_ms = multiplier * INITIAL_BACKOFF_MS;\n \t\t/* back off for between 0.75*backoff_ms and 1.25*backoff_ms */\n-\t\twait_us = (750 + random() % 500) * backoff_ms;\n+\t\twait_us = (750 + rand() % 500) * backoff_ms;\n \t\tsleep_microseconds(wait_us);\n \t\tremaining_us -= wait_us;\n \n-- \n2.3.2.245.gb5bf9d3\n"},{"id":"262473","messageId":"xmqq7frqat0m.fsf@gitster.dls.corp.google.com","threadId":"39464","inReplyTo":"55695770.2040303@kdbg.org","subject":"Re: [PATCH mh/lockfile-retry] lockfile: replace random() by rand()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-05-30T17:12:57Z","receivedAt":"2015-05-30T17:12:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j6t@kdbg.org> writes:\n\n> There you have it: Look the other way for a while, and people start\n> using exotic stuff... ;)\n\nIs it exotic to have random/srandom?  Both are in POSIX and 4BSD;\nadmittedly rand/srand are written down in C89 and later, so they\nmight be more portable, but I recall the prevailing wisdom is to\nfavor random over rand for quality of randomness and portability, so\nI am wondering if it may be a better approach to keep the code as-is\nand do a compat/random.c based on either rand/srand (or use posix\nsample implementation [*1*]).\n\n\n[Reference]\n\n*1* http://pubs.opengroup.org/onlinepubs/9699919799/functions/rand.html\n\n\n\n>\n> This is a build breakage of master on Windows. There are also a few\n> new test suite failures. On of them is in t1404#2, indicating that\n> a DF conflict takes a different error path. I haven't debugged, yet.\n> The lock file retry test fails, too. I'll report back as time permits.\n>\n>  lockfile.c | 4 ++--\n>  1 file changed, 2 insertions(+), 2 deletions(-)\n>\n> diff --git a/lockfile.c b/lockfile.c\n> index 5a93bc7..ee5cb01 100644\n> --- a/lockfile.c\n> +++ b/lockfile.c\n> @@ -191,7 +191,7 @@ static int lock_file_timeout(struct lock_file *lk, const char *path,\n>  \t\treturn lock_file(lk, path, flags);\n>  \n>  \tif (!random_initialized) {\n> -\t\tsrandom((unsigned int)getpid());\n> +\t\tsrand((unsigned int)getpid());\n>  \t\trandom_initialized = 1;\n>  \t}\n>  \n> @@ -218,7 +218,7 @@ static int lock_file_timeout(struct lock_file *lk, const char *path,\n>  \n>  \t\tbackoff_ms = multiplier * INITIAL_BACKOFF_MS;\n>  \t\t/* back off for between 0.75*backoff_ms and 1.25*backoff_ms */\n> -\t\twait_us = (750 + random() % 500) * backoff_ms;\n> +\t\twait_us = (750 + rand() % 500) * backoff_ms;\n>  \t\tsleep_microseconds(wait_us);\n>  \t\tremaining_us -= wait_us;\n"},{"id":"262941","messageId":"55700F10.8030806@kdbg.org","threadId":"39464","inReplyTo":"xmqq7frqat0m.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH mh/lockfile-retry] lockfile: replace random() by rand()","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2015-06-04T08:40:48Z","receivedAt":"2015-06-04T08:40:48Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 30.05.2015 um 19:12 schrieb Junio C Hamano:\n> Johannes Sixt <j6t@kdbg.org> writes:\n>\n>> There you have it: Look the other way for a while, and people start\n>> using exotic stuff... ;)\n>\n> Is it exotic to have random/srandom?  Both are in POSIX and 4BSD;\n> admittedly rand/srand are written down in C89 and later, so they\n> might be more portable, but I recall the prevailing wisdom is to\n> favor random over rand for quality of randomness and portability, so\n> I am wondering if it may be a better approach to keep the code as-is\n> and do a compat/random.c based on either rand/srand (or use posix\n> sample implementation [*1*]).\n\nFor our purposes here, the linear congruence of rand() is certainly \nsufficient. At this time, compatibility functions for random/srandom \nwould just mean a lot of work for little gain.\n\n>\n>\n> [Reference]\n>\n> *1* http://pubs.opengroup.org/onlinepubs/9699919799/functions/rand.html\n>\n>\n>\n>>\n>> This is a build breakage of master on Windows. There are also a few\n>> new test suite failures. On of them is in t1404#2, indicating that\n>> a DF conflict takes a different error path. I haven't debugged, yet.\n>> The lock file retry test fails, too. I'll report back as time permits.\n>>\n>>   lockfile.c | 4 ++--\n>>   1 file changed, 2 insertions(+), 2 deletions(-)\n>>\n>> diff --git a/lockfile.c b/lockfile.c\n>> index 5a93bc7..ee5cb01 100644\n>> --- a/lockfile.c\n>> +++ b/lockfile.c\n>> @@ -191,7 +191,7 @@ static int lock_file_timeout(struct lock_file *lk, const char *path,\n>>   \t\treturn lock_file(lk, path, flags);\n>>\n>>   \tif (!random_initialized) {\n>> -\t\tsrandom((unsigned int)getpid());\n>> +\t\tsrand((unsigned int)getpid());\n>>   \t\trandom_initialized = 1;\n>>   \t}\n>>\n>> @@ -218,7 +218,7 @@ static int lock_file_timeout(struct lock_file *lk, const char *path,\n>>\n>>   \t\tbackoff_ms = multiplier * INITIAL_BACKOFF_MS;\n>>   \t\t/* back off for between 0.75*backoff_ms and 1.25*backoff_ms */\n>> -\t\twait_us = (750 + random() % 500) * backoff_ms;\n>> +\t\twait_us = (750 + rand() % 500) * backoff_ms;\n>>   \t\tsleep_microseconds(wait_us);\n>>   \t\tremaining_us -= wait_us;\n>\n\n-- Hannes\n"},{"id":"262948","messageId":"557039AE.3020107@alum.mit.edu","threadId":"39464","inReplyTo":"55700F10.8030806@kdbg.org","subject":"Re: [PATCH mh/lockfile-retry] lockfile: replace random() by rand()","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2015-06-04T11:42:38Z","receivedAt":"2015-06-04T11:42:38Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 06/04/2015 10:40 AM, Johannes Sixt wrote:\n> Am 30.05.2015 um 19:12 schrieb Junio C Hamano:\n>> Johannes Sixt <j6t@kdbg.org> writes:\n>>\n>>> There you have it: Look the other way for a while, and people start\n>>> using exotic stuff... ;)\n>>\n>> Is it exotic to have random/srandom?  Both are in POSIX and 4BSD;\n>> admittedly rand/srand are written down in C89 and later, so they\n>> might be more portable, but I recall the prevailing wisdom is to\n>> favor random over rand for quality of randomness and portability, so\n>> I am wondering if it may be a better approach to keep the code as-is\n>> and do a compat/random.c based on either rand/srand (or use posix\n>> sample implementation [*1*]).\n> \n> For our purposes here, the linear congruence of rand() is certainly\n> sufficient. At this time, compatibility functions for random/srandom\n> would just mean a lot of work for little gain.\n\nWe *certainly* don't require high-quality random numbers for this\napplication. Regarding portability, there is one definite point in favor\nof rand() (it's available on Windows) vs. Junio's recollection that\nrandom() might have portability advantages, presumably on other platforms.\n\nMaybe the easiest thing would be to switch to using rand() and see if\nthe OS/2 and VMS users complain ;-)\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\n"},{"id":"262961","messageId":"CAPc5daXsvYppq0=2EU=Ah=MMWtva4_Q8325h7g1phGiDx0RAgg@mail.gmail.com","threadId":"39464","inReplyTo":"557039AE.3020107@alum.mit.edu","subject":"Re: [PATCH mh/lockfile-retry] lockfile: replace random() by rand()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-06-04T15:57:57Z","receivedAt":"2015-06-04T15:57:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"On Thu, Jun 4, 2015 at 4:42 AM, Michael Haggerty <mhagger@alum.mit.edu> wrote:\n> On 06/04/2015 10:40 AM, Johannes Sixt wrote:\n> We *certainly* don't require high-quality random numbers for this\n> application. Regarding portability, there is one definite point in favor\n> of rand() (it's available on Windows) vs. Junio's recollection that\n> random() might have portability advantages, presumably on other platforms.\n\nI agree that anything is OK in this codepath. I just suspected that whichever\none we pick, there would be somebody who says \"oh, my system lacks it\",\nand we will end up adding one of compat/{rand,random}.c to emulate.\n\nAnd when I anticipated that future, my inclination was to prefer random(),\nnot rand(), used in the code, not the other way around. Yes, both are in\nPOSIX, but I was getting the impression that rand() is on its way out\n(and rand_r() is already marked as obsolete).\n\n> Maybe the easiest thing would be to switch to using rand() and see if\n> the OS/2 and VMS users complain ;-)\n\nWe can certainly go that route and I am fine with that as the solution for\ntoday, as long as somebody will remember this discussion when that\ncomplaint comes, and make compat/random.c, and switch the\nin-code use to random(), instead of sticking to use of rand() in code.\n"},{"id":"263061","messageId":"cover.1433532967.git.j6t@kdbg.org","threadId":"39464","inReplyTo":"55700F10.8030806@kdbg.org","subject":"[PATCH 0/4] Fix file locking with retry and timeout on Windows","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2015-06-05T19:45:03Z","receivedAt":"2015-06-05T19:45:03Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"The first patch is the same that I posted earlier. It fixes a build\nfailure on Windows on master due to missing random/srandom.\n\nThe remaining 3 patches replace the select() invocation that waits\nfor a short time period by the version with poll() that we already\nuse in help.c. This is necessary because a select() call where all\nthree sets of file descriptors are empty is not supported on Windows.\n\nJohannes Sixt (4):\n  lockfile: replace random() by rand()\n  help.c: wrap wait-only poll() invocation in sleep_millisec()\n  lockfile: convert retry timeout computations to millisecond\n  lockfile: wait using sleep_millisec() instead of select()\n\n cache.h    |  1 +\n help.c     |  2 +-\n lockfile.c | 31 +++++++++----------------------\n wrapper.c  |  5 +++++\n 4 files changed, 16 insertions(+), 23 deletions(-)\n\n-- \n2.3.2.245.gb5bf9d3\n"},{"id":"263059","messageId":"06da8b5946687223276460be4db6348938df08a4.1433532967.git.j6t@kdbg.org","threadId":"39464","inReplyTo":"55700F10.8030806@kdbg.org","subject":"[PATCH 1/4] lockfile: replace random() by rand()","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2015-06-05T19:45:04Z","receivedAt":"2015-06-05T19:45:04Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Windows, we do not have functions srandom() and random(). Use srand()\nand rand(). These functions produce random numbers of lesser quality,\nbut for the purpose (a retry time-out) they are still good enough.\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\n This is the same version I posted earlier.\n\n lockfile.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/lockfile.c b/lockfile.c\nindex 30e65e9..738f202 100644\n--- a/lockfile.c\n+++ b/lockfile.c\n@@ -191,7 +191,7 @@ static int lock_file_timeout(struct lock_file *lk, const char *path,\n \t\treturn lock_file(lk, path, flags);\n \n \tif (!random_initialized) {\n-\t\tsrandom((unsigned int)getpid());\n+\t\tsrand((unsigned int)getpid());\n \t\trandom_initialized = 1;\n \t}\n \n@@ -218,7 +218,7 @@ static int lock_file_timeout(struct lock_file *lk, const char *path,\n \n \t\tbackoff_ms = multiplier * INITIAL_BACKOFF_MS;\n \t\t/* back off for between 0.75*backoff_ms and 1.25*backoff_ms */\n-\t\twait_us = (750 + random() % 500) * backoff_ms;\n+\t\twait_us = (750 + rand() % 500) * backoff_ms;\n \t\tsleep_microseconds(wait_us);\n \t\tremaining_us -= wait_us;\n \n-- \n2.3.2.245.gb5bf9d3\n"},{"id":"263060","messageId":"1bf3ed414ca35f378ac4934dee49a6fa595966ed.1433532968.git.j6t@kdbg.org","threadId":"39464","inReplyTo":"55700F10.8030806@kdbg.org","subject":"[PATCH 2/4] help.c: wrap wait-only poll() invocation in sleep_millisec()","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2015-06-05T19:45:05Z","receivedAt":"2015-06-05T19:45:05Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"We want to use the new function elsewhere in a moment.\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\n cache.h   | 1 +\n help.c    | 2 +-\n wrapper.c | 5 +++++\n 3 files changed, 7 insertions(+), 1 deletion(-)\n\ndiff --git a/cache.h b/cache.h\nindex 54f108a..328cdb7 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1680,5 +1680,6 @@ int stat_validity_check(struct stat_validity *sv, const char *path);\n void stat_validity_update(struct stat_validity *sv, int fd);\n \n int versioncmp(const char *s1, const char *s2);\n+void sleep_millisec(int millisec);\n \n #endif /* CACHE_H */\ndiff --git a/help.c b/help.c\nindex 2072a87..de1279b 100644\n--- a/help.c\n+++ b/help.c\n@@ -372,7 +372,7 @@ const char *help_unknown_cmd(const char *cmd)\n \t\tif (autocorrect > 0) {\n \t\t\tfprintf_ln(stderr, _(\"in %0.1f seconds automatically...\"),\n \t\t\t\t(float)autocorrect/10.0);\n-\t\t\tpoll(NULL, 0, autocorrect * 100);\n+\t\t\tsleep_millisec(autocorrect * 100);\n \t\t}\n \t\treturn assumed;\n \t}\ndiff --git a/wrapper.c b/wrapper.c\nindex c1a663f..ff49807 100644\n--- a/wrapper.c\n+++ b/wrapper.c\n@@ -595,3 +595,8 @@ int write_file(const char *path, int fatal, const char *fmt, ...)\n \t}\n \treturn 0;\n }\n+\n+void sleep_millisec(int millisec)\n+{\n+\tpoll(NULL, 0, millisec);\n+}\n-- \n2.3.2.245.gb5bf9d3\n"},{"id":"263063","messageId":"e47ba0d3c1ba83b50d2d241047863b2ba7b7341b.1433532968.git.j6t@kdbg.org","threadId":"39464","inReplyTo":"55700F10.8030806@kdbg.org","subject":"[PATCH 3/4] lockfile: convert retry timeout computations to millisecond","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2015-06-05T19:45:06Z","receivedAt":"2015-06-05T19:45:06Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"When the goal is to wait for some random amount of time up to one\nsecond, it is not necessary to compute with microsecond precision.\nThis is a preparation to re-use sleep_millisec().\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\n lockfile.c | 21 ++++++++-------------\n 1 file changed, 8 insertions(+), 13 deletions(-)\n\ndiff --git a/lockfile.c b/lockfile.c\nindex 738f202..3f5b699 100644\n--- a/lockfile.c\n+++ b/lockfile.c\n@@ -184,7 +184,7 @@ static int lock_file_timeout(struct lock_file *lk, const char *path,\n {\n \tint n = 1;\n \tint multiplier = 1;\n-\tlong remaining_us = 0;\n+\tlong remaining_ms = 0;\n \tstatic int random_initialized = 0;\n \n \tif (timeout_ms == 0)\n@@ -195,16 +195,11 @@ static int lock_file_timeout(struct lock_file *lk, const char *path,\n \t\trandom_initialized = 1;\n \t}\n \n-\tif (timeout_ms > 0) {\n-\t\t/* avoid overflow */\n-\t\tif (timeout_ms <= LONG_MAX / 1000)\n-\t\t\tremaining_us = timeout_ms * 1000;\n-\t\telse\n-\t\t\tremaining_us = LONG_MAX;\n-\t}\n+\tif (timeout_ms > 0)\n+\t\tremaining_ms = timeout_ms;\n \n \twhile (1) {\n-\t\tlong backoff_ms, wait_us;\n+\t\tlong backoff_ms, wait_ms;\n \t\tint fd;\n \n \t\tfd = lock_file(lk, path, flags);\n@@ -213,14 +208,14 @@ static int lock_file_timeout(struct lock_file *lk, const char *path,\n \t\t\treturn fd; /* success */\n \t\telse if (errno != EEXIST)\n \t\t\treturn -1; /* failure other than lock held */\n-\t\telse if (timeout_ms > 0 && remaining_us <= 0)\n+\t\telse if (timeout_ms > 0 && remaining_ms <= 0)\n \t\t\treturn -1; /* failure due to timeout */\n \n \t\tbackoff_ms = multiplier * INITIAL_BACKOFF_MS;\n \t\t/* back off for between 0.75*backoff_ms and 1.25*backoff_ms */\n-\t\twait_us = (750 + rand() % 500) * backoff_ms;\n-\t\tsleep_microseconds(wait_us);\n-\t\tremaining_us -= wait_us;\n+\t\twait_ms = (750 + rand() % 500) * backoff_ms / 1000;\n+\t\tsleep_microseconds(wait_ms*1000);\n+\t\tremaining_ms -= wait_ms;\n \n \t\t/* Recursion: (n+1)^2 = n^2 + 2n + 1 */\n \t\tmultiplier += 2*n + 1;\n-- \n2.3.2.245.gb5bf9d3\n"},{"id":"263062","messageId":"983f4b270c5bb8a8c436a5a12be826b16e67c861.1433532968.git.j6t@kdbg.org","threadId":"39464","inReplyTo":"55700F10.8030806@kdbg.org","subject":"[PATCH 4/4] lockfile: wait using sleep_millisec() instead of select()","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2015-06-05T19:45:07Z","receivedAt":"2015-06-05T19:45:07Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Use the new function sleep_millisec() to delay execution for a short\ntime. This avoids the invocation of select() with just a timeout, but\nno file descriptors. Such a use of select() is quit with EINVAL on\nWindows, leading to no delay at all.\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\n lockfile.c | 10 +---------\n 1 file changed, 1 insertion(+), 9 deletions(-)\n\ndiff --git a/lockfile.c b/lockfile.c\nindex 3f5b699..fb78bda 100644\n--- a/lockfile.c\n+++ b/lockfile.c\n@@ -157,14 +157,6 @@ static int lock_file(struct lock_file *lk, const char *path, int flags)\n \treturn lk->fd;\n }\n \n-static int sleep_microseconds(long us)\n-{\n-\tstruct timeval tv;\n-\ttv.tv_sec = 0;\n-\ttv.tv_usec = us;\n-\treturn select(0, NULL, NULL, NULL, &tv);\n-}\n-\n /*\n  * Constants defining the gaps between attempts to lock a file. The\n  * first backoff period is approximately INITIAL_BACKOFF_MS\n@@ -214,7 +206,7 @@ static int lock_file_timeout(struct lock_file *lk, const char *path,\n \t\tbackoff_ms = multiplier * INITIAL_BACKOFF_MS;\n \t\t/* back off for between 0.75*backoff_ms and 1.25*backoff_ms */\n \t\twait_ms = (750 + rand() % 500) * backoff_ms / 1000;\n-\t\tsleep_microseconds(wait_ms*1000);\n+\t\tsleep_millisec(wait_ms);\n \t\tremaining_ms -= wait_ms;\n \n \t\t/* Recursion: (n+1)^2 = n^2 + 2n + 1 */\n-- \n2.3.2.245.gb5bf9d3\n"},{"id":"263064","messageId":"xmqq4mmmrkrq.fsf@gitster.dls.corp.google.com","threadId":"39464","inReplyTo":"cover.1433532967.git.j6t@kdbg.org","subject":"Re: [PATCH 0/4] Fix file locking with retry and timeout on Windows","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-06-05T19:57:13Z","receivedAt":"2015-06-05T19:57:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j6t@kdbg.org> writes:\n\n> The remaining 3 patches replace the select() invocation that waits\n> for a short time period by the version with poll() that we already\n> use in help.c. This is necessary because a select() call where all\n> three sets of file descriptors are empty is not supported on Windows.\n\nThanks.\n\nThe use of both select() and poll() in our code has been bugging me\nfor a long time (but wasn't irritating enough to make me do anything\nabout it).\n\n>\n> Johannes Sixt (4):\n>   lockfile: replace random() by rand()\n>   help.c: wrap wait-only poll() invocation in sleep_millisec()\n>   lockfile: convert retry timeout computations to millisecond\n>   lockfile: wait using sleep_millisec() instead of select()\n>\n>  cache.h    |  1 +\n>  help.c     |  2 +-\n>  lockfile.c | 31 +++++++++----------------------\n>  wrapper.c  |  5 +++++\n>  4 files changed, 16 insertions(+), 23 deletions(-)\n"},{"id":"263068","messageId":"5572032F.1020606@alum.mit.edu","threadId":"39464","inReplyTo":"cover.1433532967.git.j6t@kdbg.org","subject":"Re: [PATCH 0/4] Fix file locking with retry and timeout on Windows","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2015-06-05T20:14:39Z","receivedAt":"2015-06-05T20:14:39Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 06/05/2015 09:45 PM, Johannes Sixt wrote:\n> The first patch is the same that I posted earlier. It fixes a build\n> failure on Windows on master due to missing random/srandom.\n> \n> The remaining 3 patches replace the select() invocation that waits\n> for a short time period by the version with poll() that we already\n> use in help.c. This is necessary because a select() call where all\n> three sets of file descriptors are empty is not supported on Windows.\n> \n> Johannes Sixt (4):\n>   lockfile: replace random() by rand()\n>   help.c: wrap wait-only poll() invocation in sleep_millisec()\n>   lockfile: convert retry timeout computations to millisecond\n>   lockfile: wait using sleep_millisec() instead of select()\n> \n>  cache.h    |  1 +\n>  help.c     |  2 +-\n>  lockfile.c | 31 +++++++++----------------------\n>  wrapper.c  |  5 +++++\n>  4 files changed, 16 insertions(+), 23 deletions(-)\n\nThe whole series looks good to me. Johannes, thanks for taking care of this.\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\n"}]}