<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/compat/fsmonitor, branch jch</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=jch</id>
<link rel='self' href='https://git.shady.money/git/atom?h=jch'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2024-12-06T11:20:04Z</updated>
<entry>
<title>global: trivial conversions to fix `-Wsign-compare` warnings</title>
<updated>2024-12-06T11:20:04Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-12-06T10:27:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=80c9e70ebe871f0826bc101142c66ff783405100'/>
<id>urn:sha1:80c9e70ebe871f0826bc101142c66ff783405100</id>
<content type='text'>
We have a bunch of loops which iterate up to an unsigned boundary using
a signed index, which generates warnigs because we compare a signed and
unsigned value in the loop condition. Address these sites for trivial
cases and enable `-Wsign-compare` warnings for these code units.

This patch only adapts those code units where we can drop the
`DISABLE_SIGN_COMPARE_WARNINGS` macro in the same step.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>global: mark code units that generate warnings with `-Wsign-compare`</title>
<updated>2024-12-06T11:20:02Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-12-06T10:27:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=41f43b8243f42b9df2e98be8460646d4c0100ad3'/>
<id>urn:sha1:41f43b8243f42b9df2e98be8460646d4c0100ad3</id>
<content type='text'>
Mark code units that generate warnings with `-Wsign-compare`. This
allows for a structured approach to get rid of all such warnings over
time in a way that can be easily measured.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'ak/typofixes'</title>
<updated>2024-10-25T18:02:04Z</updated>
<author>
<name>Taylor Blau</name>
<email>me@ttaylorr.com</email>
</author>
<published>2024-10-25T18:02:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4d334e5205f547be7913901d0cf529477e993f26'/>
<id>urn:sha1:4d334e5205f547be7913901d0cf529477e993f26</id>
<content type='text'>
Typofixes.

* ak/typofixes:
  t: fix typos
  t/helper: fix a typo
  t/perf: fix typos
  t/unit-tests: fix typos
  contrib: fix typos
  compat: fix typos
</content>
</entry>
<entry>
<title>Merge branch 'jk/fsmonitor-event-listener-race-fix'</title>
<updated>2024-10-15T20:56:43Z</updated>
<author>
<name>Taylor Blau</name>
<email>me@ttaylorr.com</email>
</author>
<published>2024-10-15T20:56:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b43e23fa02427067ceb605a5dd5ea602de4c6ac5'/>
<id>urn:sha1:b43e23fa02427067ceb605a5dd5ea602de4c6ac5</id>
<content type='text'>
On macOS, fsmonitor can fall into a race condition that results in
a client waiting forever to be notified for an event that have
already happened.  This problem has been corrected.

* jk/fsmonitor-event-listener-race-fix:
  fsmonitor: initialize fs event listener before accepting clients
  simple-ipc: split async server initialization and running
</content>
</entry>
<entry>
<title>compat: fix typos</title>
<updated>2024-10-10T20:31:12Z</updated>
<author>
<name>Andrew Kreimer</name>
<email>algonell@gmail.com</email>
</author>
<published>2024-10-10T15:11:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=54ee29cfd521b0e043dcc1857e4a7c8d993b5e59'/>
<id>urn:sha1:54ee29cfd521b0e043dcc1857e4a7c8d993b5e59</id>
<content type='text'>
Fix typos and grammar.

Reported-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Andrew Kreimer &lt;algonell@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>fsmonitor: initialize fs event listener before accepting clients</title>
<updated>2024-10-08T19:03:56Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2024-10-08T08:36:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=51907f8feeae9ae4af1722e973f44ff10aa168dc'/>
<id>urn:sha1:51907f8feeae9ae4af1722e973f44ff10aa168dc</id>
<content type='text'>
There's a racy hang in fsmonitor on macOS that we sometimes see in CI.
When we serve a client, what's supposed to happen is:

  1. The client thread calls with_lock__wait_for_cookie() in which we
     create a cookie file and then wait for a pthread_cond event

  2. The filesystem event listener sees the cookie file creation, does
     some internal book-keeping, and then triggers the pthread_cond.

But there's a problem: we start the listener that accepts client threads
before we start the fs event thread. So it's possible for us to accept a
client which creates the cookie file and starts waiting before the fs
event thread is initialized, and we miss those filesystem events
entirely. That leaves the client thread hanging forever.

In CI, the symptom is that t9210 (which is testing scalar, which always
enables fsmonitor under the hood) may hang forever in "scalar clone". It
is waiting on "git fetch" which is waiting on the fsmonitor daemon.

The race happens more frequently under load, but you can trigger it
predictably with a sleep like this, which delays the start of the fs
event thread:

  --- a/compat/fsmonitor/fsm-listen-darwin.c
  +++ b/compat/fsmonitor/fsm-listen-darwin.c
  @@ -510,6 +510,7 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state)
          FSEventStreamSetDispatchQueue(data-&gt;stream, data-&gt;dq);
          data-&gt;stream_scheduled = 1;

  +       sleep(1);
          if (!FSEventStreamStart(data-&gt;stream)) {
                  error(_("Failed to start the FSEventStream"));
                  goto force_error_stop_without_loop;

One solution might be to reverse the order of initialization: start the
fs event thread before we start the thread listening for clients. But
the fsmonitor code explicitly does it in the opposite direction. The fs
event thread wants to refer to the ipc_server_data struct, so we need it
to be initialized first.

A further complication is that we need a signal from the fs event thread
that it is actually ready and listening. And those details happen within
backend-specific fsmonitor code, whereas the initialization is in the
shared code.

So instead, let's use the ipc_server init/start split added in the
previous commit. The generic fsmonitor code will init the ipc_server but
_not_ start it, leaving that to the backend specific code, which now
needs to call ipc_server_start_async() at the right time.

For macOS, that is right after we start the FSEventStream that you can
see in the diff above.

It's not clear to me if Windows suffers from the same problem (and we
simply don't trigger it in CI), or if it is immune. Regardless, the
obvious place to start accepting clients there is right after we've
established the ReadDirectoryChanges watch.

This makes the hangs go away in our macOS CI environment, even when
compiled with the sleep() above.

Helped-by: Koji Nakamaru &lt;koji.nakamaru@gree.net&gt;
Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Acked-by: Koji Nakamaru &lt;koji.nakamaru@gree.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>global: prepare for hiding away repo-less config functions</title>
<updated>2024-08-13T17:01:05Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-08-13T09:14:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=219de841d9436d759fa52ea60625b60cda8476fd'/>
<id>urn:sha1:219de841d9436d759fa52ea60625b60cda8476fd</id>
<content type='text'>
We're about to hide config functions that implicitly depend on
`the_repository` behind the `USE_THE_REPOSITORY_VARIABLE` macro. This
will uncover a bunch of dependents that transitively relied on the
global variable, but didn't define the macro yet.

Adapt them such that we define the macro to prepare for this change.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>compat/fsmonitor: fix socket path in networked SHA256 repos</title>
<updated>2024-06-14T17:26:34Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-06-14T06:50:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2a0e11479f2e272236d56c38b5261944ef16fbbc'/>
<id>urn:sha1:2a0e11479f2e272236d56c38b5261944ef16fbbc</id>
<content type='text'>
The IPC socket used by the fsmonitor on Darwin is usually contained in
the Git repository itself. When the repository is hosted on a networked
filesystem though, we instead create the socket path in the user's home
directory or the socket directory. In that case, we derive the path by
hashing the repository path.

But while we always use SHA1 to hash the repository path, we then end up
using `hash_to_hex()` to append the computed hash to the socket path.
This is wrong because `hash_to_hex()` uses the hash algorithm configured
in `the_repository`, which may not be SHA1. The consequence is that we
may append uninitialized bytes to the path when operating in a SHA256
repository.

Fix this bug by using `hash_to_hex_algop()` with SHA1.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>fsmonitor--daemon.h: remove unnecessary includes</title>
<updated>2023-12-26T20:04:32Z</updated>
<author>
<name>Elijah Newren</name>
<email>newren@gmail.com</email>
</author>
<published>2023-12-23T17:14:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=31d20faa90c30aa90abc2227cbf65b67f81e98e2'/>
<id>urn:sha1:31d20faa90c30aa90abc2227cbf65b67f81e98e2</id>
<content type='text'>
The unnecessary include in the header transitively pulled in some
other headers actually needed by source files, though.  Have those
source files explicitly include the headers they need.

Signed-off-by: Elijah Newren &lt;newren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>fsmonitor/darwin: mark unused parameters in system callback</title>
<updated>2023-09-18T22:56:15Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2023-09-18T22:32:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=997eb910a644491b8793ae0459ee2c5d89f239f8'/>
<id>urn:sha1:997eb910a644491b8793ae0459ee2c5d89f239f8</id>
<content type='text'>
We pass fsevent_callback() to the system FSEventStreamCreate() function
as a callback. So we must match the expected function signature, even
though we don't care about all of the parameters. Mark the unused ones
to satisfy -Wunused-parameter.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
