This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 1/5] Add internal <file_change_detection.h> header file
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: Florian Weimer <fw at deneb dot enyo dot de>
- Cc: libc-alpha at sourceware dot org
- Date: Mon, 10 Feb 2020 17:57:47 -0300
- Subject: Re: [PATCH 1/5] Add internal <file_change_detection.h> header file
- References: <cover.1579631655.git.fweimer@redhat.com> <691b5b8d18c29b5c31de804b8393a1b9718e1a1d.1579631655.git.fweimer@redhat.com> <cb0bc5a9-a0bd-7583-00b5-1151c31a34fe@linaro.org> <87v9oez03z.fsf@mid.deneb.enyo.de>
On 10/02/2020 16:57, Florian Weimer wrote:
>
>>> + /* Wait for a file change. Depending on file system time stamp
>>> + resolution, this subtest blocks for a while. */
>>> + for (int use_stdio = 0; use_stdio < 2; ++use_stdio)
>>> + {
>>> + struct file_change_detection initial;
>>> + TEST_VERIFY (file_change_detection_for_path (&initial, path_file1));
>>> + while (true)
>>> + {
>>> + support_write_file_string (path_file1, "line\n");
>>> + struct file_change_detection current;
>>> + if (use_stdio)
>>> + TEST_VERIFY (file_change_detection_for_fp (¤t, fp_file1));
>>> + else
>>> + TEST_VERIFY (file_change_detection_for_path (¤t, path_file1));
>>> + if (!file_is_unchanged (&initial, ¤t))
>>> + break;
>>> + /* Wait for a bit to reduce system load. */
>>> + usleep (100 * 1000);
>>> + }
>>> + }
>>
>> Ok, although the usleep seems excessive large (the testing will most likely
>> timeout prior usleep return).
>
> Hmm, I thought that this would wait 100 milliseconds? So the loop
> should exit in a second or two with low-resolution timestamps in the
> file system.
>
Right, it should be ok then.