From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-9.4 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 090751F744 for ; Sun, 26 Jun 2016 04:15:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751989AbcFZEO4 (ORCPT ); Sun, 26 Jun 2016 00:14:56 -0400 Received: from sub3.mail.dreamhost.com ([69.163.253.7]:38958 "EHLO homiemail-a17.g.dreamhost.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751888AbcFZEOq (ORCPT ); Sun, 26 Jun 2016 00:14:46 -0400 Received: from homiemail-a17.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a17.g.dreamhost.com (Postfix) with ESMTP id A2A292B206A; Sat, 25 Jun 2016 21:14:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=novalis.org; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=novalis.org; bh=8ssHZoQ+sfUBnFDUfNrD248fVnc=; b=llsphbCeDeIk1CuM4eNj7hT79lON n1Lt7/E8FRw6bNssSHyCYSxmuOKWnfrfE8WPsMdDTCd543L/88mGObHDD619s282 +EnlgFKZgmEvYbSKUaJ1+aJfDGsI+KQsTkut556X24yTJL6hM8YM7I7BS2f7OS2Q 9BK5pYlpW00z+G4= Received: from frank.cable.rcn.com (207-38-164-98.c3-0.43d-ubr2.qens-43d.ny.cable.rcn.com [207.38.164.98]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: novalis@novalis.org) by homiemail-a17.g.dreamhost.com (Postfix) with ESMTPSA id 137282B205C; Sat, 25 Jun 2016 21:14:44 -0700 (PDT) From: David Turner To: git@vger.kernel.org, pclouds@gmail.com, kamggg@gmail.com Cc: David Turner , Junio C Hamano Subject: [PATCH v13 16/20] index-helper: don't run if already running Date: Sun, 26 Jun 2016 00:14:20 -0400 Message-Id: <1466914464-10358-16-git-send-email-novalis@novalis.org> X-Mailer: git-send-email 2.8.0.rc4.20.g1d4f562 In-Reply-To: <1466914464-10358-1-git-send-email-novalis@novalis.org> References: <1466914464-10358-1-git-send-email-novalis@novalis.org> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: David Turner Signed-off-by: David Turner Signed-off-by: Junio C Hamano --- index-helper.c | 7 +++++++ t/t7900-index-helper.sh | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/index-helper.c b/index-helper.c index f7a002b..9cfcb9e 100644 --- a/index-helper.c +++ b/index-helper.c @@ -446,6 +446,13 @@ int main(int argc, char **argv) return 0; } + /* check that no other copy is running */ + fd = unix_stream_connect(git_path("index-helper.sock")); + if (fd >= 0) + die(_("Already running")); + if (errno != ECONNREFUSED && errno != ENOENT) + die_errno(_("Unexpected error checking socket")); + atexit(cleanup); sigchain_push_common(cleanup_on_signal); diff --git a/t/t7900-index-helper.sh b/t/t7900-index-helper.sh index e71b5af..7159971 100755 --- a/t/t7900-index-helper.sh +++ b/t/t7900-index-helper.sh @@ -29,4 +29,13 @@ test_expect_success 'index-helper creates usable path file and can be killed' ' test_path_is_missing .git/index-helper.sock ' +test_expect_success 'index-helper will not start if already running' ' + test_when_finished "git index-helper --kill" && + git index-helper --detach && + test -S .git/index-helper.sock && + test_must_fail git index-helper 2>err && + test -S .git/index-helper.sock && + grep "Already running" err +' + test_done -- 1.9.1