From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Subject: [PATCH 13/24] read-cache.c: split racy stat test to a separate function Date: Tue, 20 Jan 2015 20:03:22 +0700 Message-ID: <1421759013-8494-14-git-send-email-pclouds@gmail.com> References: <1421759013-8494-1-git-send-email-pclouds@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= , Junio C Hamano To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Tue Jan 20 14:05:15 2015 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YDYUX-0003lR-6s for gcvg-git-2@plane.gmane.org; Tue, 20 Jan 2015 14:05:09 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755115AbbATNFB convert rfc822-to-quoted-printable (ORCPT ); Tue, 20 Jan 2015 08:05:01 -0500 Received: from mail-pa0-f50.google.com ([209.85.220.50]:50704 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755110AbbATNFA (ORCPT ); Tue, 20 Jan 2015 08:05:00 -0500 Received: by mail-pa0-f50.google.com with SMTP id bj1so45555895pad.9 for ; Tue, 20 Jan 2015 05:05:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=SLBO0tTsONBNSisOav7clrJJr1YqfwlkoH/7UuFV2hY=; b=ICOcIcL4ZCjfTLI1UCMUVPN2UtzkNwh/qskCP+Gmsi9YQEPUoy9e/Gn1QrCqEcKwwg ZpUBh9kyapLLcj8mJQIhrrDof2Cf1jgMF44C9oXwftP31KpYotmvV4w115kEdhjSazm2 lKW/7wJpbK5YwLawSajQRkchTgtS6JbTw9T89y02Ejsgdd0uJSpelkZ2VhvBLv/H1xy0 h2im8LWhbn0qoYDubJtbosiDF1RcqJLOHtbyQ6CTJSLqD0Vu6J/uz62O1xtdav/PRnxN K8qoD9UIeghwHbmUb382ejJIwK3bZLAMdPO6KcgziT3mrroAC+tnZ8KwdK95Se4Tx1Io vwCg== X-Received: by 10.70.32.195 with SMTP id l3mr29310230pdi.41.1421759100173; Tue, 20 Jan 2015 05:05:00 -0800 (PST) Received: from lanh ([115.73.212.1]) by mx.google.com with ESMTPSA id fu17sm100019pdb.5.2015.01.20.05.04.56 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Jan 2015 05:04:59 -0800 (PST) Received: by lanh (sSMTP sendmail emulation); Tue, 20 Jan 2015 20:05:10 +0700 X-Mailer: git-send-email 2.2.0.84.ge9c7a8a In-Reply-To: <1421759013-8494-1-git-send-email-pclouds@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Signed-off-by: Nguy=E1=BB=85n Th=C3=A1i Ng=E1=BB=8Dc Duy Signed-off-by: Junio C Hamano --- read-cache.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/read-cache.c b/read-cache.c index d643a3f..f12a185 100644 --- a/read-cache.c +++ b/read-cache.c @@ -270,20 +270,26 @@ static int ce_match_stat_basic(const struct cache= _entry *ce, struct stat *st) return changed; } =20 -static int is_racy_timestamp(const struct index_state *istate, - const struct cache_entry *ce) +static int is_racy_stat(const struct index_state *istate, + const struct stat_data *sd) { - return (!S_ISGITLINK(ce->ce_mode) && - istate->timestamp.sec && + return (istate->timestamp.sec && #ifdef USE_NSEC /* nanosecond timestamped files can also be racy! */ - (istate->timestamp.sec < ce->ce_stat_data.sd_mtime.sec || - (istate->timestamp.sec =3D=3D ce->ce_stat_data.sd_mtime.sec && - istate->timestamp.nsec <=3D ce->ce_stat_data.sd_mtime.nsec)) + (istate->timestamp.sec < sd->sd_mtime.sec || + (istate->timestamp.sec =3D=3D sd->sd_mtime.sec && + istate->timestamp.nsec <=3D sd->sd_mtime.nsec)) #else - istate->timestamp.sec <=3D ce->ce_stat_data.sd_mtime.sec + istate->timestamp.sec <=3D sd->sd_mtime.sec #endif - ); + ); +} + +static int is_racy_timestamp(const struct index_state *istate, + const struct cache_entry *ce) +{ + return (!S_ISGITLINK(ce->ce_mode) && + is_racy_stat(istate, &ce->ce_stat_data)); } =20 int ie_match_stat(const struct index_state *istate, --=20 2.2.0.84.ge9c7a8a