gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] branch master updated: log HTTP request status, URL and duratio


From: gnunet
Subject: [gnunet] branch master updated: log HTTP request status, URL and duration for every HTTP request we make at INFO-level
Date: Sun, 23 Apr 2023 14:09:05 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 6d676cbe0 log HTTP request status, URL and duration for every HTTP 
request we make at INFO-level
6d676cbe0 is described below

commit 6d676cbe03368223204e01053cf392fa107922be
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Apr 23 14:09:01 2023 +0200

    log HTTP request status, URL and duration for every HTTP request we make at 
INFO-level
---
 src/curl/curl.c   | 24 ++++++++++++++++++++++++
 src/pq/pq_event.c |  2 +-
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/curl/curl.c b/src/curl/curl.c
index b21153980..68c99dd75 100644
--- a/src/curl/curl.c
+++ b/src/curl/curl.c
@@ -125,6 +125,11 @@ struct GNUNET_CURL_Job
    * after the job has finished.
    */
   struct curl_slist *job_headers;
+
+  /**
+   * When did we start the job?
+   */
+  struct GNUNET_TIME_Absolute start_time;
 };
 
 
@@ -415,6 +420,7 @@ setup_job (CURL *eh,
     return NULL;
   }
   job = GNUNET_new (struct GNUNET_CURL_Job);
+  job->start_time = GNUNET_TIME_absolute_get ();
   job->job_headers = all_headers;
 
   if ( (CURLE_OK !=
@@ -743,6 +749,7 @@ GNUNET_CURL_perform2 (struct GNUNET_CURL_Context *ctx,
                                                &n_completed)))
   {
     struct GNUNET_CURL_Job *job;
+    struct GNUNET_TIME_Relative duration;
     long response_code;
     void *response;
 
@@ -754,6 +761,7 @@ GNUNET_CURL_perform2 (struct GNUNET_CURL_Context *ctx,
                                       (char **) &job));
     GNUNET_assert (job->ctx == ctx);
     response_code = 0;
+    duration = GNUNET_TIME_absolute_get_duration (job->start_time);
     if (NULL != job->jcc_raw)
     {
       /* RAW mode, no parsing */
@@ -777,6 +785,22 @@ GNUNET_CURL_perform2 (struct GNUNET_CURL_Context *ctx,
                 response);
       rc (response);
     }
+    {
+      char *url = NULL;
+
+      if (CURLE_UNKNOWN_OPTION ==
+          curl_easy_getinfo (job->easy_handle,
+                             CURLINFO_EFFECTIVE_URL,
+                             &url))
+        url = "<unknown>";
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                  "HTTP request for `%s' finished with %u after %s\n",
+                  url,
+                  (unsigned int) response_code,
+                  GNUNET_TIME_relative2s (duration,
+                                          true));
+      /* Note: we MUST NOT free 'url' here */
+    }
     GNUNET_CURL_job_cancel (job);
   }
 }
diff --git a/src/pq/pq_event.c b/src/pq/pq_event.c
index 3e708fc04..16bd898fb 100644
--- a/src/pq/pq_event.c
+++ b/src/pq/pq_event.c
@@ -170,7 +170,7 @@ struct NotifyContext
  * @param value a `struct GNUNET_DB_EventHandler`
  * @return #GNUNET_OK continue to iterate
  */
-static int
+static enum GNUNET_GenericReturnValue
 do_notify (void *cls,
            const struct GNUNET_ShortHashCode *sh,
            void *value)

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]