From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeff King Subject: Re: [PATCH 1/2] daemon: add tests Date: Wed, 4 Jan 2012 21:51:54 -0500 Message-ID: <20120105025154.GA7326@sigill.intra.peff.net> References: <7v8vlovavj.fsf@alter.siamese.dyndns.org> <1325692539-26748-1-git-send-email-drizzd@aon.at> <7vy5tnpcuw.fsf@alter.siamese.dyndns.org> <20120104204017.GC27567@ecki.lan> <7vaa63p11t.fsf@alter.siamese.dyndns.org> <20120104222649.GA14727@sigill.intra.peff.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Cc: Junio C Hamano , Clemens Buchacher , git@vger.kernel.org, Jonathan Nieder , Erik Faye-Lund , Ilari Liusvaara , =?utf-8?B?Tmd1eeG7hW4gVGjDoWkgTmfhu41j?= Duy To: Jakub Narebski X-From: git-owner@vger.kernel.org Thu Jan 05 03:52:03 2012 Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RidQv-0006aT-Cu for gcvg-git-2@lo.gmane.org; Thu, 05 Jan 2012 03:52:01 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756477Ab2AECv5 (ORCPT ); Wed, 4 Jan 2012 21:51:57 -0500 Received: from 99-108-226-0.lightspeed.iplsin.sbcglobal.net ([99.108.226.0]:58008 "EHLO peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755492Ab2AECv4 (ORCPT ); Wed, 4 Jan 2012 21:51:56 -0500 Received: (qmail 22302 invoked by uid 107); 5 Jan 2012 02:58:47 -0000 Received: from sigill.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.7) (smtp-auth username relayok, mechanism cram-md5) by peff.net (qpsmtpd/0.84) with ESMTPA; Wed, 04 Jan 2012 21:58:47 -0500 Received: by sigill.intra.peff.net (sSMTP sendmail emulation); Wed, 04 Jan 2012 21:51:54 -0500 Content-Disposition: inline In-Reply-To: Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: On Wed, Jan 04, 2012 at 06:24:16PM -0800, Jakub Narebski wrote: > Jeff King writes: > > > 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