]> granicus.if.org Git - curl/commitdiff
Introcuding a new timestamp for curl_easy_getinfo():
authorDaniel Stenberg <daniel@haxx.se>
Thu, 3 Jul 2008 06:56:03 +0000 (06:56 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 3 Jul 2008 06:56:03 +0000 (06:56 +0000)
CURLINFO_APPCONNECT_TIME. This is set with the "application layer"
handshake/connection is completed (typically SSL, TLS or SSH). By using this
you can figure out the application layer's own connect time. You can extract
the time stamp using curl's -w option and the new variable named
'time_appconnect'. This feature was sponsored by Lenny Rachitsky at NeuStar.

13 files changed:
CHANGES
RELEASE-NOTES
docs/curl.1
docs/libcurl/curl_easy_getinfo.3
include/curl/curl.h
lib/getinfo.c
lib/progress.c
lib/progress.h
lib/ssh.c
lib/sslgen.c
lib/url.c
lib/urldata.h
src/writeout.c

diff --git a/CHANGES b/CHANGES
index ed1213cb55f76b420c86425ec44f83e2eb52da17..b28bae1ef8db65fcf515df7c34609e9dc51d9c41 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,14 @@
 
                                   Changelog
 
+Daniel Stenberg (3 Jul 2008)
+- Introcuding a new timestamp for curl_easy_getinfo():
+  CURLINFO_APPCONNECT_TIME. This is set with the "application layer"
+  handshake/connection is completed. Which typically is SSL, TLS or SSH and by
+  using this you can figure out the application layer's own connect time. You
+  can extract the time stamp using curl's -w option and the new variable named
+  'time_appconnect'. This feature was sponsored by Lenny Rachitsky at NeuStar.
+
 Daniel Fandrich (2 Jul 2008)
 - Support Open Watcom C on Linux (as well as Windows).
 
index 7c94905428df6a72c87f76db06146cf6dff43974..0b87536fe4d8ae40c7230d0a4537d1afebc17a5d 100644 (file)
@@ -16,6 +16,7 @@ This release includes the following changes:
  o curl's option parser for boolean options reworked
  o Added --remote-name-all
  o Now builds for the INTEGRITY operating system
+ o Added CURLINFO_APPCONNECT_TIME
 
 This release includes the following bugfixes:
 
index 15a338666759654a50918b299f1a0981c635cc2a..129939cd067175ba37fe372a72fb2cd59ba5f4c4 100644 (file)
@@ -1241,8 +1241,12 @@ The time, in seconds, it took from the start until the name resolving was
 completed.
 .TP
 .B time_connect
-The time, in seconds, it took from the start until the connect to the remote
-host (or proxy) was completed.
+The time, in seconds, it took from the start until the TCP connect to the
+remote host (or proxy) was completed.
+.TP
+.B time_appconnect
+The time, in seconds, it took from the start until the SSL/SSH/etc
+connect/handshake to the remote host was completed. (Added in 7.19.0)
 .TP
 .B time_pretransfer
 The time, in seconds, it took from the start until the file transfer is just
index fc45b01aeafddf76d59d2a02f0fba1769a8e7ebe..b8fdf466e5023711d9f6dc002b5f0611d9ae2eaf 100644 (file)
@@ -71,6 +71,12 @@ start until the name resolving was completed.
 .IP CURLINFO_CONNECT_TIME
 Pass a pointer to a double to receive the time, in seconds, it took from the
 start until the connect to the remote host (or proxy) was completed.
+.IP CURLINFO_APPCONNECT_TIME
+Pass a pointer to a double to receive the time, in seconds, it took from the
+start until the SSL/SSH connect/handshake to the remote host was completed.
+This time is most often very near to the PRETRANSFER time, except for cases
+such as HTTP pippelining where the pretransfer time can be delayed due to
+waits in line for the pipeline and more. (Added in 7.19.0)
 .IP CURLINFO_PRETRANSFER_TIME
 Pass a pointer to a double to receive the time, in seconds, it took from the
 start until the file transfer is just about to begin. This includes all
@@ -190,29 +196,33 @@ An overview of the six time values available from curl_easy_getinfo()
 
 curl_easy_perform()
     |
-    |--NT
-    |--|--CT
-    |--|--|--PT
-    |--|--|--|--ST
-    |--|--|--|--|--TT
-    |--|--|--|--|--RT
+    |--NAMELOOKUP
+    |--|--CONNECT
+    |--|--|--APPCONNECT
+    |--|--|--|--PRETRANSFER
+    |--|--|--|--|--STARTTRANSFER
+    |--|--|--|--|--|--TOTAL
+    |--|--|--|--|--|--REDIRECT
 .FI
-.IP NT
+.IP NAMELOOKUP
 \fICURLINFO_NAMELOOKUP_TIME\fP. The time it took from the start until the name
 resolving was completed.
-.IP CT
+.IP CONNECT
 \fICURLINFO_CONNECT_TIME\fP. The time it took from the start until the connect
 to the remote host (or proxy) was completed.
-.IP PT
+.IP APPCONNECT
+\fICURLINFO_APPCONNECT_TIME\fP. The time it took from the start until the SSL
+connect/handshake with the remote host was completed. (Added in in 7.19.0)
+.IP PRETRANSFER
 \fICURLINFO_PRETRANSFER_TIME\fP. The time it took from the start until the
 file transfer is just about to begin. This includes all pre-transfer commands
 and negotiations that are specific to the particular protocol(s) involved.
-.IP ST
+.IP STARTTRANSFER
 \fICURLINFO_STARTTRANSFER_TIME\fP. The time it took from the start until the
 first byte is just about to be transferred.
-.IP TT
+.IP TOTAL
 \fICURLINFO_TOTAL_TIME\fP. Total time of the previous request.
-.IP RT
+.IP REDIRECT
 \fICURLINFO_REDIRECT_TIME\fP. The time it took for all redirection steps
 include name lookup, connect, pretransfer and transfer before final
 transaction was started. So, this is zero if no redirection took place.
index 8182e9c2893e79c720d12d2b5a31a730a4fedaf0..af3a0d8a90b3b46e5dbfc40cdf3156b0602f7ba2 100644 (file)
@@ -1608,9 +1608,10 @@ typedef enum {
   CURLINFO_FTP_ENTRY_PATH   = CURLINFO_STRING + 30,
   CURLINFO_REDIRECT_URL     = CURLINFO_STRING + 31,
   CURLINFO_PRIMARY_IP       = CURLINFO_STRING + 32,
+  CURLINFO_APPCONNECT_TIME  = CURLINFO_DOUBLE + 33,
   /* Fill in new entries below here! */
 
-  CURLINFO_LASTONE          = 32
+  CURLINFO_LASTONE          = 33
 } CURLINFO;
 
 /* CURLINFO_RESPONSE_CODE is the new name for the option previously known as
index bef2ebac44289c38f4e67f6514f7596f742caedb..2b7b08aee4eb0444146c10cfb1dc7c8f04b6fe65 100644 (file)
@@ -137,6 +137,9 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
   case CURLINFO_CONNECT_TIME:
     *param_doublep = data->progress.t_connect;
     break;
+  case CURLINFO_APPCONNECT_TIME:
+    *param_doublep = data->progress.t_appconnect;
+    break;
   case CURLINFO_PRETRANSFER_TIME:
     *param_doublep =  data->progress.t_pretransfer;
     break;
index f473e82273d6861d2efc7407869ab563f11dd29d..2956d1a996b073a3b8970c4cdfcb32b763d64b3e 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -172,6 +172,10 @@ void Curl_pgrsTime(struct SessionHandle *data, timerid timer)
     data->progress.t_connect =
       Curl_tvdiff_secs(Curl_tvnow(), data->progress.t_startsingle);
     break;
+  case TIMER_APPCONNECT:
+    data->progress.t_appconnect =
+      Curl_tvdiff_secs(Curl_tvnow(), data->progress.t_startsingle);
+    break;
   case TIMER_PRETRANSFER:
     data->progress.t_pretransfer =
       Curl_tvdiff_secs(Curl_tvnow(), data->progress.t_startsingle);
index ad9d6623ec25021c04976840398050ee8d6a4db5..15a45cc2420f8d8996461ba33c127c062d3b630b 100644 (file)
@@ -7,7 +7,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -30,6 +30,7 @@ typedef enum {
   TIMER_NONE,
   TIMER_NAMELOOKUP,
   TIMER_CONNECT,
+  TIMER_APPCONNECT,
   TIMER_PRETRANSFER,
   TIMER_STARTTRANSFER,
   TIMER_POSTRANSFER,
index f54353c037c26a28e350dbb3d1d30376ed91f3ce..6f2392d6d6bac20bbed41ab70b401e449275322a 100644 (file)
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -715,6 +715,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn)
      */
     infof(data, "Authentication complete\n");
 
+    Curl_pgrsTime(conn->data, TIMER_APPCONNECT); /* SSH is connected */
+
     conn->sockfd = sock;
     conn->writesockfd = CURL_SOCKET_BAD;
 
index a6824090dacc412bf18a94b1a25c376b0a448ce3..0001cd8d31a2a312c0a37c1d84e2894d1b9d72d5 100644 (file)
@@ -60,6 +60,7 @@
 #include "strequal.h"
 #include "url.h"
 #include "memory.h"
+#include "progress.h"
 /* The last #include file should be: */
 #include "memdebug.h"
 
@@ -178,11 +179,17 @@ void Curl_ssl_cleanup(void)
 CURLcode
 Curl_ssl_connect(struct connectdata *conn, int sockindex)
 {
+  CURLcode res;
   /* mark this is being ssl-enabled from here on. */
   conn->ssl[sockindex].use = TRUE;
   conn->ssl[sockindex].state = ssl_connection_negotiating;
 
-  return curlssl_connect(conn, sockindex);
+  res = curlssl_connect(conn, sockindex);
+
+  if(!res)
+    Curl_pgrsTime(conn->data, TIMER_APPCONNECT); /* SSL is connected */
+
+  return res;
 }
 
 CURLcode
@@ -192,7 +199,7 @@ Curl_ssl_connect_nonblocking(struct connectdata *conn, int sockindex,
 #ifdef curlssl_connect_nonblocking
   /* mark this is being ssl requested from here on. */
   conn->ssl[sockindex].use = TRUE;
-  return Curl_ossl_connect_nonblocking(conn, sockindex, done);
+  return curlssl_connect_nonblocking(conn, sockindex, done);
 #else
   *done = TRUE; /* fallback to BLOCKING */
   conn->ssl[sockindex].use = TRUE;
index f200e2b1e0884568dbb62c4e70975a12f99019c3..4238256cb0bf1be42a6df8b351044edcbe367b86 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -4328,6 +4328,7 @@ static CURLcode setup_conn(struct connectdata *conn,
     }
     else {
       Curl_pgrsTime(data, TIMER_CONNECT); /* we're connected already */
+      Curl_pgrsTime(data, TIMER_APPCONNECT); /* we're connected already */
       conn->bits.tcpconnect = TRUE;
       *protocol_done = TRUE;
       if(data->set.verbose)
index 2e0f69204548e953169118ee7ae69a2f38bf569b..6eb6539d52fa6f23b0e081bb698c782071f1de3c 100644 (file)
@@ -1067,6 +1067,7 @@ struct Progress {
 
   double t_nslookup;
   double t_connect;
+  double t_appconnect;
   double t_pretransfer;
   double t_starttransfer;
   double t_redirect;
index 2a0e37af2774fab65e220693d2e5de301b334a6a..1e77d062cff1a60a3e6d93efe71e47a68c0cacef 100644 (file)
@@ -45,6 +45,7 @@ typedef enum {
   VAR_TOTAL_TIME,
   VAR_NAMELOOKUP_TIME,
   VAR_CONNECT_TIME,
+  VAR_APPCONNECT_TIME,
   VAR_PRETRANSFER_TIME,
   VAR_STARTTRANSFER_TIME,
   VAR_SIZE_DOWNLOAD,
@@ -79,6 +80,7 @@ static const struct variable replacements[]={
   {"time_total", VAR_TOTAL_TIME},
   {"time_namelookup", VAR_NAMELOOKUP_TIME},
   {"time_connect", VAR_CONNECT_TIME},
+  {"time_appconnect", VAR_APPCONNECT_TIME},
   {"time_pretransfer", VAR_PRETRANSFER_TIME},
   {"time_starttransfer", VAR_STARTTRANSFER_TIME},
   {"size_header", VAR_HEADER_SIZE},
@@ -183,14 +185,22 @@ void ourWriteOut(CURL *curl, const char *writeinfo)
                    curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &doubleinfo))
                   fprintf(stream, "%.3f", doubleinfo);
                 break;
+              case VAR_APPCONNECT_TIME:
+                if(CURLE_OK ==
+                   curl_easy_getinfo(curl, CURLINFO_APPCONNECT_TIME,
+                                     &doubleinfo))
+                  fprintf(stream, "%.3f", doubleinfo);
+                break;
               case VAR_PRETRANSFER_TIME:
                 if(CURLE_OK ==
-                   curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME, &doubleinfo))
+                   curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME,
+                                     &doubleinfo))
                   fprintf(stream, "%.3f", doubleinfo);
                 break;
               case VAR_STARTTRANSFER_TIME:
                 if(CURLE_OK ==
-                   curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME, &doubleinfo))
+                   curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME,
+                                     &doubleinfo))
                   fprintf(stream, "%.3f", doubleinfo);
                 break;
               case VAR_SIZE_UPLOAD: