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: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from mail-qk0-x23b.google.com (mail-qk0-x23b.google.com [IPv6:2607:f8b0:400d:c09::23b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 5E65F203F3 for ; Tue, 25 Jul 2017 02:43:35 +0000 (UTC) Received: by mail-qk0-x23b.google.com with SMTP id d145sf5517828qkc.3 for ; Mon, 24 Jul 2017 19:43:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:date:from:to:cc:message-id:in-reply-to:references:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:list-subscribe :list-unsubscribe; bh=GhcK5eQF18H9V2Hhd5MFeXPPXUx3TXiPT7ZkwkgnutM=; b=sOrHAFNnYQtav231o+axPvm6yHNveB8CoaxDYR/+0/+yLE+QVxFxMsCMleZc3AQwKV 2dFBT4L8l4trrLmWudA7s/hRFB3Xp0hM7FoV590VRHs3D1fLUM4nCSK25nCHgsbkVJJw dmDbFbOzGMNCeiphm+AsvkhEMHh2c7ykSJ9NNYav256YEdybjD8W7IkXPqz42wFpoa+0 8JHXsue1RP6du1PK/z0hgvRGSfxMfo000X9Flgw+Ukjgf7zMNNnb3RFvKAVODRA9Ioaw z2zuJApchsLVWv07uz0X1pfe85ck6D2gawXSl7zzvx6/nCWVWiov4V0uuh79DVwYb8gh J/6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:date:from:to:cc:message-id:in-reply-to :references:subject:mime-version:x-original-sender:reply-to :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=GhcK5eQF18H9V2Hhd5MFeXPPXUx3TXiPT7ZkwkgnutM=; b=ZKIVj1rJS0jNsrETRlpv1BwqmeJaS/foY/LGS7XQh1lAnc2sD3AGW6kBi5Kjhf/7HK Mwiy1O5kn7JbJ1cgOoAs0T9TzgFQQyiLmadoYMqkie8uqKu3+fciajOKUFE4qw8bkLGD 5BLIJC4HxkZGah/KEzDrYO21oZRiRVyAO3Ogc8F1boPfK9aDRaSVeflKvPEI6H+HdupS jRm+C+NOkXlJtWhpYXYl1X/K7d5pGOozyyl4lwG/A4iWtQfevnhUoQZuqgPrpFYK2Zzr 4u/C+j9+TyRyPxFWLtP2BEHmWG6lMRuap0WGfa2tsiQmZy6BTf1h6dc31ApmYyLbVEGQ p09Q== Sender: rack-devel@googlegroups.com X-Gm-Message-State: AIVw110wtl1azGS03Af3ekGZsZgyXiiz9uZTvpaSPBXcmaqvh1vo9B5A iN5lh51hm4wSKQ== X-Received: by 10.36.1.208 with SMTP id 199mr244485itk.6.1500950614597; Mon, 24 Jul 2017 19:43:34 -0700 (PDT) X-BeenThere: rack-devel@googlegroups.com Received: by 10.107.155.9 with SMTP id d9ls13482872ioe.40.gmail; Mon, 24 Jul 2017 19:43:34 -0700 (PDT) X-Received: by 10.36.22.195 with SMTP id a186mr6519404ita.41.1500950614325; Mon, 24 Jul 2017 19:43:34 -0700 (PDT) Received: by 10.202.245.4 with SMTP id t4msoih; Mon, 24 Jul 2017 17:23:51 -0700 (PDT) X-Received: by 10.31.85.71 with SMTP id j68mr75252vkb.27.1500942231346; Mon, 24 Jul 2017 17:23:51 -0700 (PDT) Date: Mon, 24 Jul 2017 17:23:50 -0700 (PDT) From: =?UTF-8?Q?Rafael_Mendon=C3=A7a_Fran=C3=A7a?= To: Rack Development Cc: e@80x24.org Message-Id: <69bfc3c5-271b-41f6-bd35-fe91a66613a8@googlegroups.com> In-Reply-To: <20170629023056.GA22961@untitled> References: <20170629023056.GA22961@untitled> Subject: Re: [PATCH] common_logger: rely on monotonic clock MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_3862_2033493133.1500942231041" X-Original-Sender: rafaelmfranca@gmail.com Reply-To: rack-devel@googlegroups.com Precedence: list Mailing-list: list rack-devel@googlegroups.com; contact rack-devel+owners@googlegroups.com List-ID: X-Google-Group-Id: 486215384060 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , ------=_Part_3862_2033493133.1500942231041 Content-Type: multipart/alternative; boundary="----=_Part_3863_1410753028.1500942231041" ------=_Part_3863_1410753028.1500942231041 Content-Type: text/plain; charset="UTF-8" Thank you Eric. Sorry for the delay. This patch was applied on master commit 3665c2437ab681148eac783e91ffb51180bcdf44. On Wednesday, June 28, 2017 at 10:30:58 PM UTC-4, Eric Wong wrote: > > As with commit 2474e3a779a8d2b6 for Rack::Runtime, > Time.now is inaccurate if system time changes, so do not > rely on it if a monotonic clock is available. > --- > The following changes since commit > 0362a54dba92626582d42f3343c209b7cdb7e713: > > Partially reverting 8a7a142d (2017-06-28 13:20:52 -0700) > > are available in the git repository at: > > git://80x24.org/rack logger-time > > for you to fetch changes up to 743f29d845b627b6083eaf6380ec6442f7427de7: > > common_logger: rely on monotonic clock (2017-06-29 02:25:00 +0000) > > ---------------------------------------------------------------- > Eric Wong (1): > common_logger: rely on monotonic clock > > lib/rack/common_logger.rb | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/lib/rack/common_logger.rb b/lib/rack/common_logger.rb > index ae41043..7855f0c 100644 > --- a/lib/rack/common_logger.rb > +++ b/lib/rack/common_logger.rb > @@ -29,7 +29,7 @@ module Rack > end > > def call(env) > - began_at = Time.now > + began_at = Utils.clock_time > status, header, body = @app.call(env) > header = Utils::HeaderHash.new(header) > body = BodyProxy.new(body) { log(env, status, header, began_at) } > @@ -39,20 +39,19 @@ module Rack > private > > def log(env, status, header, began_at) > - now = Time.now > length = extract_content_length(header) > > msg = FORMAT % [ > env['HTTP_X_FORWARDED_FOR'] || env["REMOTE_ADDR"] || "-", > env["REMOTE_USER"] || "-", > - now.strftime("%d/%b/%Y:%H:%M:%S %z"), > + Time.now.strftime("%d/%b/%Y:%H:%M:%S %z"), > env[REQUEST_METHOD], > env[PATH_INFO], > env[QUERY_STRING].empty? ? "" : "?#{env[QUERY_STRING]}", > env[HTTP_VERSION], > status.to_s[0..3], > length, > - now - began_at ] > + Utils.clock_time - began_at ] > > logger = @logger || env[RACK_ERRORS] > # Standard library logger doesn't support write but it supports << > which actually > -- > EW > -- --- You received this message because you are subscribed to the Google Groups "Rack Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to rack-devel+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/d/optout. ------=_Part_3863_1410753028.1500942231041 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thank you Eric. Sorry for the delay.

Th= is patch was applied on master commit=C2=A03665c2437ab681148eac783e91ffb5= 1180bcdf44.

On Wednesday, June 28, 2017 at 10:30:58 PM UTC-4,= Eric Wong wrote:
As with commi= t 2474e3a779a8d2b6 for Rack::Runtime,
Time.now is inaccurate if system time changes, so do not
rely on it if a monotonic clock is available.
---
=C2=A0 The following changes since commit 0362a54dba92626582d42f3343c20= 9b7cdb7e713:

=C2=A0 =C2=A0 Partially reverting 8a7a142d (2017-06-28 13:20:52 -0700)

=C2=A0 are available in the git repository at:

=C2=A0 =C2=A0 git://80x24.org/rack logger-time

=C2=A0 for you to fetch changes up to 743f29d845b627b6083eaf6380ec6442f7427de7:

=C2=A0 =C2=A0 common_logger: rely on monotonic clock (2017-06-29 02:25:= 00 +0000)

=C2=A0 -----------------------------------------------------------= -----
=C2=A0 Eric Wong (1):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 common_logger: rely on monotonic clock

=C2=A0 =C2=A0lib/rack/common_logger.rb | 7 +++----
=C2=A0 =C2=A01 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/lib/rack/common_logger.rb b/lib/rack/common_logger.rb
index ae41043..7855f0c 100644
--- a/lib/rack/common_logger.rb
+++ b/lib/rack/common_logger.rb
@@ -29,7 +29,7 @@ module Rack
=C2=A0 =C2=A0 =C2=A0end
=C2=A0
=C2=A0 =C2=A0 =C2=A0def call(env)
- =C2=A0 =C2=A0 =C2=A0began_at =3D Time.now
+ =C2=A0 =C2=A0 =C2=A0began_at =3D Utils.clock_time
=C2=A0 =C2=A0 =C2=A0 =C2=A0status, header, body =3D @app.call(env)
=C2=A0 =C2=A0 =C2=A0 =C2=A0header =3D Utils::HeaderHash.new(header)
=C2=A0 =C2=A0 =C2=A0 =C2=A0body =3D BodyProxy.new(body) { log(env, stat= us, header, began_at) }
@@ -39,20 +39,19 @@ module Rack
=C2=A0 =C2=A0 =C2=A0private
=C2=A0
=C2=A0 =C2=A0 =C2=A0def log(env, status, header, began_at)
- =C2=A0 =C2=A0 =C2=A0now =3D Time.now
=C2=A0 =C2=A0 =C2=A0 =C2=A0length =3D extract_content_length(header)
=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0msg =3D FORMAT % [
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0env['HTTP_X_FORWARDED_FOR'] |= | env["REMOTE_ADDR"] || "-",
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0env["REMOTE_USER"] || "= ;-",
- =C2=A0 =C2=A0 =C2=A0 =C2=A0now.strftime("%d/%b/%Y:%H:%M:%S = %z"),
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0Time.now.strftime("%d/%b/%Y:%H:%= M:%S %z"),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0env[REQUEST_METHOD],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0env[PATH_INFO],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0env[QUERY_STRING].empty? ? "&quo= t; : "?#{env[QUERY_STRING]}",
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0env[HTTP_VERSION],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0status.to_s[0..3],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0length,
- =C2=A0 =C2=A0 =C2=A0 =C2=A0now - began_at ]
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0Utils.clock_time - began_at ]
=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0logger =3D @logger || env[RACK_ERRORS]
=C2=A0 =C2=A0 =C2=A0 =C2=A0# Standard library logger doesn't suppor= t write but it supports << which actually
--=20
EW

--

---
You received this message because you are subscribed to the Google Groups &= quot;Rack Development" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to rack-dev= el+unsubscribe@googlegroups.com.
For more options, visit http= s://groups.google.com/d/optout.
------=_Part_3863_1410753028.1500942231041-- ------=_Part_3862_2033493133.1500942231041--