[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] 01/03: optimize setting upload length if available
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] 01/03: optimize setting upload length if available |
Date: |
Thu, 17 May 2018 00:09:12 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
commit 215e607f63847c77bd26d4c97eae8c7d6ca7f4a0
Author: Christian Grothoff <address@hidden>
AuthorDate: Wed May 16 21:35:37 2018 +0200
optimize setting upload length if available
---
src/gns/gnunet-gns-benchmark.c | 2 +-
src/gns/gnunet-gns-proxy.c | 34 ++++++++++++++++++++++++++++++++++
src/gns/gnunet-service-gns.c | 19 ++++++++++---------
3 files changed, 45 insertions(+), 10 deletions(-)
diff --git a/src/gns/gnunet-gns-benchmark.c b/src/gns/gnunet-gns-benchmark.c
index afa540c85..d5afae9f6 100644
--- a/src/gns/gnunet-gns-benchmark.c
+++ b/src/gns/gnunet-gns-benchmark.c
@@ -492,7 +492,7 @@ process_stdin (void *cls)
delta = GNUNET_TIME_absolute_get_duration (last);
last = GNUNET_TIME_absolute_get ();
fprintf (stderr,
- "Read 10000 domain names in %s\n",
+ "Read 100000 domain names in %s\n",
GNUNET_STRINGS_relative_time_to_string (delta,
GNUNET_YES));
}
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c
index 08663a57e..02ebcf0f1 100644
--- a/src/gns/gnunet-gns-proxy.c
+++ b/src/gns/gnunet-gns-proxy.c
@@ -1801,6 +1801,23 @@ create_response (void *cls,
curl_easy_setopt (s5r->curl, CURLOPT_WRITEDATA, s5r);
curl_easy_setopt (s5r->curl, CURLOPT_READFUNCTION, &curl_upload_cb);
curl_easy_setopt (s5r->curl, CURLOPT_READDATA, s5r);
+ {
+ const char *us;
+ long upload_size;
+
+ us = MHD_lookup_connection_value (con,
+ MHD_HEADER_KIND,
+ MHD_HTTP_HEADER_CONTENT_LENGTH);
+ if ( (1 == sscanf (us,
+ "%ld",
+ &upload_size)) &&
+ (upload_size >= 0) )
+ {
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_INFILESIZE,
+ upload_size);
+ }
+ }
}
else if (0 == strcasecmp (meth, MHD_HTTP_METHOD_POST))
{
@@ -1810,6 +1827,23 @@ create_response (void *cls,
curl_easy_setopt (s5r->curl, CURLOPT_WRITEDATA, s5r);
curl_easy_setopt (s5r->curl, CURLOPT_READFUNCTION, &curl_upload_cb);
curl_easy_setopt (s5r->curl, CURLOPT_READDATA, s5r);
+ {
+ const char *us;
+ long upload_size;
+
+ us = MHD_lookup_connection_value (con,
+ MHD_HEADER_KIND,
+ MHD_HTTP_HEADER_CONTENT_LENGTH);
+ if ( (1 == sscanf (us,
+ "%ld",
+ &upload_size)) &&
+ (upload_size >= 0) )
+ {
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_INFILESIZE,
+ upload_size);
+ }
+ }
}
else if (0 == strcasecmp (meth, MHD_HTTP_METHOD_HEAD))
{
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index c376ddfcc..cffae824d 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -296,7 +296,6 @@ client_disconnect_cb (void *cls,
clh);
GNUNET_free (clh);
}
-
GNUNET_free (gc);
}
@@ -340,26 +339,29 @@ send_lookup_response (void* cls,
const struct GNUNET_GNSRECORD_Data *rd)
{
struct ClientLookupHandle *clh = cls;
- struct GNUNET_MQ_Envelope *env;
+ struct GnsClient *gc = clh->gc;
+ struct GNUNET_MQ_Envelope *env;
struct LookupResultMessage *rmsg;
size_t len;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending LOOKUP_RESULT message with %u results\n",
(unsigned int) rd_count);
-
- len = GNUNET_GNSRECORD_records_get_size (rd_count, rd);
+ len = GNUNET_GNSRECORD_records_get_size (rd_count,
+ rd);
env = GNUNET_MQ_msg_extra (rmsg,
len,
GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT);
rmsg->id = clh->request_id;
rmsg->rd_count = htonl (rd_count);
- GNUNET_GNSRECORD_records_serialize (rd_count, rd, len,
+ GNUNET_GNSRECORD_records_serialize (rd_count,
+ rd,
+ len,
(char*) &rmsg[1]);
- GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(clh->gc->client),
+ GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (gc->client),
env);
- GNUNET_CONTAINER_DLL_remove (clh->gc->clh_head,
- clh->gc->clh_tail,
+ GNUNET_CONTAINER_DLL_remove (gc->clh_head,
+ gc->clh_tail,
clh);
GNUNET_free (clh);
GNUNET_STATISTICS_update (statistics,
@@ -428,7 +430,6 @@ handle_lookup (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received LOOKUP `%s' message\n",
name);
-
clh = GNUNET_new (struct ClientLookupHandle);
GNUNET_CONTAINER_DLL_insert (gc->clh_head,
gc->clh_tail,
--
To stop receiving notification emails like this one, please contact
address@hidden