Thread (14 messages) flat view 14 messages, 4 authors, 2016-06-15

Re: [PATCH 1/2] daemon: add tests

From: Jeff King <hidden>
Date: 2016-06-15 22:52:43

Possibly related (same subject, not in this thread)

On Wed, Jan 04, 2012 at 06:24:16PM -0800, Jakub Narebski wrote:
Jeff King [off-list ref] writes:
quoted
As a side note, it looks like we just start the daemon with "git daemon
&". Doesn't that create a race condition with the tests which
immediately try to access it (i.e., the first test may run before the
daemon actually opens the socket)?
Hmmm... perhaps the trick that git-instaweb does for "plackup" web
server would be of use here, waiting for socket to be ready?
It looks like it busy loops, which is kind of ugly.

The credential-cache helper has a similar problem. It wants to kick off
a daemon if one is not already running, and then connect to it. So the
daemon does:

  printf("ok\n");
  fclose(stdout);

when it has set up the socket, and the client does:

  r = read_in_full(daemon.out, buf, sizeof(buf));
  if (r < 0)
          die_errno("unable to read result code from cache daemon");
  if (r != 3 || memcmp(buf, "ok\n", 3))
          die("cache daemon did not start: %.*s", r, buf);
  /* now we can connect over the socket */

We could probably add a "--notify-when-ready" option to git-daemon to
do something similar.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help