diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-05-01 10:17:14 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-05-01 10:17:14 +0200 |
commit | 3b16879d89a65d3f3b386be76d15954d5423d532 (patch) | |
tree | 9748e43809d0a4edcf3454984bb6fa3b165e7311 | |
parent | 544a4efee5239f4a8eb6b911bb7a6c78686d5c09 (diff) | |
parent | 87f924153ec9a8a14be030d634c57438db550cbf (diff) | |
download | gnunet-3b16879d89a65d3f3b386be76d15954d5423d532.tar.gz gnunet-3b16879d89a65d3f3b386be76d15954d5423d532.zip |
merge
25 files changed, 519 insertions, 445 deletions
diff --git a/doc/documentation/chapters/installation.texi b/doc/documentation/chapters/installation.texi index eeb14473b..3a76fb162 100644 --- a/doc/documentation/chapters/installation.texi +++ b/doc/documentation/chapters/installation.texi | |||
@@ -294,7 +294,7 @@ If you want to be able to enable DEBUG-level log messages, add | |||
294 | @command{./configure} command. | 294 | @command{./configure} command. |
295 | @code{DEBUG}-level log messages are in English only and | 295 | @code{DEBUG}-level log messages are in English only and |
296 | should only be useful for developers (or for filing | 296 | should only be useful for developers (or for filing |
297 | really detailed bug reports). | 297 | really detailed bug reports). |
298 | 298 | ||
299 | Finally, you probably want to compile @command{gnunet-gtk}, which | 299 | Finally, you probably want to compile @command{gnunet-gtk}, which |
300 | includes @command{gnunet-setup} (a graphical tool for | 300 | includes @command{gnunet-setup} (a graphical tool for |
@@ -389,10 +389,9 @@ For those services, systems with more than one user may require each user | |||
389 | to specify a different port number in their personal configuration file. | 389 | to specify a different port number in their personal configuration file. |
390 | 390 | ||
391 | Finally, the user should perform the basic initial setup for the GNU Name | 391 | Finally, the user should perform the basic initial setup for the GNU Name |
392 | System (GNS). This is done by running two commands: | 392 | System (GNS) certificate authority. This is done by running: |
393 | 393 | ||
394 | @example | 394 | @example |
395 | $ gnunet-gns-import.sh | ||
396 | $ gnunet-gns-proxy-setup-ca | 395 | $ gnunet-gns-proxy-setup-ca |
397 | @end example | 396 | @end example |
398 | 397 | ||
@@ -420,7 +419,7 @@ hosts: files gns [NOTFOUND=return] mdns4_minimal \ | |||
420 | 419 | ||
421 | @c FIXME: Document new behavior. | 420 | @c FIXME: Document new behavior. |
422 | You might want to make sure that @file{/lib/libnss_gns.so.2} exists on | 421 | You might want to make sure that @file{/lib/libnss_gns.so.2} exists on |
423 | your system, it should have been created during the installation. | 422 | your system, it should have been created during the installation. |
424 | 423 | ||
425 | @node Build instructions for Ubuntu 12.04 using Git | 424 | @node Build instructions for Ubuntu 12.04 using Git |
426 | @section Build instructions for Ubuntu 12.04 using Git | 425 | @section Build instructions for Ubuntu 12.04 using Git |
@@ -802,7 +801,7 @@ $ gpg --keyserver pgp.mit.edu --recv-keys A88C8ADD129828D7EAC02E52E22F9BBFEE3485 | |||
802 | @end example | 801 | @end example |
803 | 802 | ||
804 | @noindent | 803 | @noindent |
805 | and rerun the gpg --verify command. | 804 | and rerun the gpg --verify command. |
806 | 805 | ||
807 | @example | 806 | @example |
808 | $ tar xvf gnurl-7.57.0.tar.xz | 807 | $ tar xvf gnurl-7.57.0.tar.xz |
@@ -1418,7 +1417,7 @@ as a normal user. | |||
1418 | We begin by installing a few Debian packages from stable: | 1417 | We begin by installing a few Debian packages from stable: |
1419 | 1418 | ||
1420 | @example | 1419 | @example |
1421 | # apt-get install gcc make python-zbar libltdl-dev libsqlite3-dev \ | 1420 | # apt-get install gcc make python-zbar libltdl-dev libsqlite3-dev \ |
1422 | libunistring-dev libopus-dev libpulse-dev openssl libglpk-dev texlive \ | 1421 | libunistring-dev libopus-dev libpulse-dev openssl libglpk-dev texlive \ |
1423 | libidn11-dev libmysqlclient-dev libpq-dev libarchive-dev libbz2-dev \ | 1422 | libidn11-dev libmysqlclient-dev libpq-dev libarchive-dev libbz2-dev \ |
1424 | libflac-dev libgif-dev libglib2.0-dev libgtk-3-dev libmpeg2-4-dev \ | 1423 | libflac-dev libgif-dev libglib2.0-dev libgtk-3-dev libmpeg2-4-dev \ |
@@ -1633,7 +1632,7 @@ have to compile it from source: | |||
1633 | @item Unzip the downloaded source tarball using your favourite | 1632 | @item Unzip the downloaded source tarball using your favourite |
1634 | unzipper application In the MSYS shell | 1633 | unzipper application In the MSYS shell |
1635 | 1634 | ||
1636 | @item change to the respective directory | 1635 | @item change to the respective directory |
1637 | 1636 | ||
1638 | @item Configure glpk for "i686-pc-mingw32": | 1637 | @item Configure glpk for "i686-pc-mingw32": |
1639 | 1638 | ||
@@ -1781,7 +1780,7 @@ $ make install | |||
1781 | This document is a @b{DEPRECATED} installation guide for GNUnet on | 1780 | This document is a @b{DEPRECATED} installation guide for GNUnet on |
1782 | Windows. | 1781 | Windows. |
1783 | It will not work for recent GNUnet versions, but maybe it will be of | 1782 | It will not work for recent GNUnet versions, but maybe it will be of |
1784 | some use if problems arise. | 1783 | some use if problems arise. |
1785 | 1784 | ||
1786 | The Windows build uses a UNIX emulator for Windows, | 1785 | The Windows build uses a UNIX emulator for Windows, |
1787 | @uref{http://www.mingw.org/, MinGW}, to build the executable modules. | 1786 | @uref{http://www.mingw.org/, MinGW}, to build the executable modules. |
@@ -1799,7 +1798,7 @@ We regret any inconvenience, and if you have problems, please report them. | |||
1799 | * Installer:: | 1798 | * Installer:: |
1800 | * Source:: | 1799 | * Source:: |
1801 | @end menu | 1800 | @end menu |
1802 | 1801 | ||
1803 | @node Hardware and OS requirements | 1802 | @node Hardware and OS requirements |
1804 | @subsubsection Hardware and OS requirements | 1803 | @subsubsection Hardware and OS requirements |
1805 | 1804 | ||
@@ -1878,7 +1877,7 @@ This batch file opens a shell which is used to invoke the build | |||
1878 | processes. | 1877 | processes. |
1879 | MinGW's standard shell (@command{msys.bat}) is not suitable | 1878 | MinGW's standard shell (@command{msys.bat}) is not suitable |
1880 | because it opens a separate console window. | 1879 | because it opens a separate console window. |
1881 | On Vista, @command{bash.bat} needs to be run as Administrator. | 1880 | On Vista, @command{bash.bat} needs to be run as Administrator. |
1882 | 1881 | ||
1883 | @item | 1882 | @item |
1884 | Start @command{bash.sh} and rename | 1883 | Start @command{bash.sh} and rename |
@@ -1948,7 +1947,7 @@ directory (@file{c:\mingw\mingw}). | |||
1948 | 1947 | ||
1949 | @item @strong{SQLite}@ | 1948 | @item @strong{SQLite}@ |
1950 | GNUnet uses the SQLite database to store data. | 1949 | GNUnet uses the SQLite database to store data. |
1951 | Get the prebuilt binary from here and unpack it to your MinGW directory. | 1950 | Get the prebuilt binary from here and unpack it to your MinGW directory. |
1952 | 1951 | ||
1953 | @item @strong{MySQL}@ | 1952 | @item @strong{MySQL}@ |
1954 | As an alternative to SQLite, GNUnet also supports MySQL. | 1953 | As an alternative to SQLite, GNUnet also supports MySQL. |
@@ -1984,7 +1983,7 @@ dlltool --input-def ../include/libmySQL.def \ | |||
1984 | --output-lib libmysqlclient.a -k | 1983 | --output-lib libmysqlclient.a -k |
1985 | @end example | 1984 | @end example |
1986 | 1985 | ||
1987 | @item Copy include\* to include\mysql\ | 1986 | @item Copy include\* to include\mysql\ |
1988 | 1987 | ||
1989 | @item Pass @code{--with-mysql=/c/mysql} to | 1988 | @item Pass @code{--with-mysql=/c/mysql} to |
1990 | @command{./configure} and copy @file{libmysql.dll} | 1989 | @command{./configure} and copy @file{libmysql.dll} |
@@ -2082,7 +2081,7 @@ debug information and are quite large. To compile release versions | |||
2082 | (small and fast) set the variable @code{CFLAGS}: | 2081 | (small and fast) set the variable @code{CFLAGS}: |
2083 | 2082 | ||
2084 | @example | 2083 | @example |
2085 | export CFLAGS='-O2 -march=pentium -fomit-frame-pointer' | 2084 | export CFLAGS='-O2 -march=pentium -fomit-frame-pointer' |
2086 | ./configure --prefix=$HOME --with-extractor=$HOME | 2085 | ./configure --prefix=$HOME --with-extractor=$HOME |
2087 | @end example | 2086 | @end example |
2088 | 2087 | ||
@@ -2097,7 +2096,7 @@ located in @file{contrib\win} in the GNUnet source tree. | |||
2097 | @subsubsection Source | 2096 | @subsubsection Source |
2098 | 2097 | ||
2099 | @c FIXME: URL | 2098 | @c FIXME: URL |
2100 | The sources of all dependencies are available here. | 2099 | The sources of all dependencies are available here. |
2101 | 2100 | ||
2102 | @c @node Portable GNUnet | 2101 | @c @node Portable GNUnet |
2103 | @c @section Portable GNUnet | 2102 | @c @section Portable GNUnet |
@@ -2372,7 +2371,7 @@ The hostlist client supports the following proxy types at the moment: | |||
2372 | @end itemize | 2371 | @end itemize |
2373 | 2372 | ||
2374 | In addition authentication at the proxy with username and password can be | 2373 | In addition authentication at the proxy with username and password can be |
2375 | configured. | 2374 | configured. |
2376 | 2375 | ||
2377 | To configure proxy support for the hostlist client in the | 2376 | To configure proxy support for the hostlist client in the |
2378 | @command{gnunet-setup} tool, select the "hostlist" tab and select | 2377 | @command{gnunet-setup} tool, select the "hostlist" tab and select |
@@ -2521,7 +2520,7 @@ inconsistencies. Some of the other databases do not support repair. | |||
2521 | @item Access mysql as root: | 2520 | @item Access mysql as root: |
2522 | 2521 | ||
2523 | @example | 2522 | @example |
2524 | $ mysql -u root -p | 2523 | $ mysql -u root -p |
2525 | @end example | 2524 | @end example |
2526 | 2525 | ||
2527 | @noindent | 2526 | @noindent |
@@ -3324,19 +3323,6 @@ steps. | |||
3324 | First of all, GNS needs to be integrated with the operating system. Most | 3323 | First of all, GNS needs to be integrated with the operating system. Most |
3325 | of this section is about the operating system level integration. | 3324 | of this section is about the operating system level integration. |
3326 | 3325 | ||
3327 | Additionally, each individual user who wants to use the system must also | ||
3328 | initialize their GNS zones. This can be done by running (after starting | ||
3329 | GNUnet) | ||
3330 | |||
3331 | @example | ||
3332 | $ gnunet-gns-import.sh | ||
3333 | @end example | ||
3334 | |||
3335 | @noindent | ||
3336 | after the local GNUnet peer has been started. Note that the namestore (in | ||
3337 | particular the namestore database backend) should not be reconfigured | ||
3338 | afterwards (as records are not automatically migrated between backends). | ||
3339 | |||
3340 | The remainder of this chapter will detail the various methods for | 3326 | The remainder of this chapter will detail the various methods for |
3341 | configuring the use of GNS with your operating system. | 3327 | configuring the use of GNS with your operating system. |
3342 | 3328 | ||
@@ -3528,7 +3514,7 @@ gnurl --version | |||
3528 | curl 7.56.0 (x86_64-unknown-linux-gnu) libcurl/7.56.0 \ | 3514 | curl 7.56.0 (x86_64-unknown-linux-gnu) libcurl/7.56.0 \ |
3529 | GnuTLS/3.5.13 zlib/1.2.11 libidn2/2.0.4 | 3515 | GnuTLS/3.5.13 zlib/1.2.11 libidn2/2.0.4 |
3530 | Release-Date: 2017-10-08 | 3516 | Release-Date: 2017-10-08 |
3531 | Protocols: http https | 3517 | Protocols: http https |
3532 | Features: AsynchDNS IDN IPv6 Largefile NTLM SSL libz \ | 3518 | Features: AsynchDNS IDN IPv6 Largefile NTLM SSL libz \ |
3533 | TLS-SRP UnixSockets HTTPS-proxy | 3519 | TLS-SRP UnixSockets HTTPS-proxy |
3534 | @end example | 3520 | @end example |
@@ -4125,4 +4111,3 @@ Furthermore, 'make install' will silently fail to set the DNS binaries to | |||
4125 | be owned by group "gnunetdns" unless that group already exists (!). | 4111 | be owned by group "gnunetdns" unless that group already exists (!). |
4126 | An alternative name for the "gnunetdns" group can be specified using the | 4112 | An alternative name for the "gnunetdns" group can be specified using the |
4127 | @code{--with-gnunetdns=GRPNAME} configure option. | 4113 | @code{--with-gnunetdns=GRPNAME} configure option. |
4128 | |||
diff --git a/doc/man/gnunet-namestore-fcfsd.1 b/doc/man/gnunet-namestore-fcfsd.1 index 3160910d4..8039e796f 100644 --- a/doc/man/gnunet-namestore-fcfsd.1 +++ b/doc/man/gnunet-namestore-fcfsd.1 | |||
@@ -13,7 +13,7 @@ Most users will not want to run an FCFS\-zone and thus will not need this progra | |||
13 | 13 | ||
14 | \fBgnunet\-gns-fcfsd\fP runs a web server where users can register names to be mapped to their GNS zone. Names are made available on a First Come First Served basis (hence fcfs). Registered names do not expire. The HTTP server is run on the port that is specified in the configuration file in section "[fcfsd]" under the name "HTTPPORT". The key of the zone in which the names are registered must be specified under the name "ZONEKEY" in the same section. It is possible to manage gnunet\-gns\-fcfsd using gnunet\-(service\-arm) by starting the daemon using "gnunet\-arm \-i fcfsd" or by setting "FORCESTART=YES" in the "fcfds" section of your configuration. | 14 | \fBgnunet\-gns-fcfsd\fP runs a web server where users can register names to be mapped to their GNS zone. Names are made available on a First Come First Served basis (hence fcfs). Registered names do not expire. The HTTP server is run on the port that is specified in the configuration file in section "[fcfsd]" under the name "HTTPPORT". The key of the zone in which the names are registered must be specified under the name "ZONEKEY" in the same section. It is possible to manage gnunet\-gns\-fcfsd using gnunet\-(service\-arm) by starting the daemon using "gnunet\-arm \-i fcfsd" or by setting "FORCESTART=YES" in the "fcfds" section of your configuration. |
15 | 15 | ||
16 | An FCFS\-zone is run at http://gnunet.org/fcfs/. The respective zone key can be imported into an individual user's zone using "gnunet-gns-import.sh". GNS users are encouraged to register their zone with the gnunet.org FCFS authority. | 16 | An FCFS\-zone is run at http://gnunet.org/fcfs/. GNS users are encouraged to register their zone with the gnunet.org FCFS authority. |
17 | 17 | ||
18 | If you want to run your own FCFS registrar, you need to first create a pseudonym (using "gnunet\-identity \-C NAME"), and then assign it to be used for the "fcfsd" service using "gnunet\-identity \-e NAME \-s fcfsd". After that, you can start the FCFSD service (possibly using gnunet\-arm). | 18 | If you want to run your own FCFS registrar, you need to first create a pseudonym (using "gnunet\-identity \-C NAME"), and then assign it to be used for the "fcfsd" service using "gnunet\-identity \-e NAME \-s fcfsd". After that, you can start the FCFSD service (possibly using gnunet\-arm). |
19 | 19 | ||
diff --git a/src/dht/dht.h b/src/dht/dht.h index 4c994f93a..95ffa33ca 100644 --- a/src/dht/dht.h +++ b/src/dht/dht.h | |||
@@ -214,11 +214,6 @@ struct GNUNET_DHT_ClientPutMessage | |||
214 | uint32_t desired_replication_level GNUNET_PACKED; | 214 | uint32_t desired_replication_level GNUNET_PACKED; |
215 | 215 | ||
216 | /** | 216 | /** |
217 | * Unique ID for the PUT message. | ||
218 | */ | ||
219 | uint64_t unique_id GNUNET_PACKED; | ||
220 | |||
221 | /** | ||
222 | * How long should this data persist? | 217 | * How long should this data persist? |
223 | */ | 218 | */ |
224 | struct GNUNET_TIME_AbsoluteNBO expiration; | 219 | struct GNUNET_TIME_AbsoluteNBO expiration; |
@@ -234,30 +229,6 @@ struct GNUNET_DHT_ClientPutMessage | |||
234 | 229 | ||
235 | 230 | ||
236 | /** | 231 | /** |
237 | * Message to confirming receipt of PUT, sent from DHT service to clients. | ||
238 | */ | ||
239 | struct GNUNET_DHT_ClientPutConfirmationMessage | ||
240 | { | ||
241 | /** | ||
242 | * Type: #GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT_OK | ||
243 | */ | ||
244 | struct GNUNET_MessageHeader header; | ||
245 | |||
246 | /** | ||
247 | * Always zero. | ||
248 | */ | ||
249 | uint32_t reserved GNUNET_PACKED; | ||
250 | |||
251 | /** | ||
252 | * Unique ID from the PUT message that is being confirmed. | ||
253 | */ | ||
254 | uint64_t unique_id GNUNET_PACKED; | ||
255 | |||
256 | }; | ||
257 | |||
258 | |||
259 | |||
260 | /** | ||
261 | * Message to monitor put requests going through peer, DHT service -> clients. | 232 | * Message to monitor put requests going through peer, DHT service -> clients. |
262 | */ | 233 | */ |
263 | struct GNUNET_DHT_MonitorPutMessage | 234 | struct GNUNET_DHT_MonitorPutMessage |
diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c index 42ddc7b60..af0dafbf3 100644 --- a/src/dht/dht_api.c +++ b/src/dht/dht_api.c | |||
@@ -55,7 +55,7 @@ struct GNUNET_DHT_PutHandle | |||
55 | /** | 55 | /** |
56 | * Continuation to call when done. | 56 | * Continuation to call when done. |
57 | */ | 57 | */ |
58 | GNUNET_DHT_PutContinuation cont; | 58 | GNUNET_SCHEDULER_TaskCallback cont; |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * Main handle to this DHT api | 61 | * Main handle to this DHT api |
@@ -68,9 +68,9 @@ struct GNUNET_DHT_PutHandle | |||
68 | void *cont_cls; | 68 | void *cont_cls; |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * Unique ID for the PUT operation. | 71 | * Envelope from the PUT operation. |
72 | */ | 72 | */ |
73 | uint64_t unique_id; | 73 | struct GNUNET_MQ_Envelope *env; |
74 | 74 | ||
75 | }; | 75 | }; |
76 | 76 | ||
@@ -440,7 +440,7 @@ static void | |||
440 | do_disconnect (struct GNUNET_DHT_Handle *h) | 440 | do_disconnect (struct GNUNET_DHT_Handle *h) |
441 | { | 441 | { |
442 | struct GNUNET_DHT_PutHandle *ph; | 442 | struct GNUNET_DHT_PutHandle *ph; |
443 | GNUNET_DHT_PutContinuation cont; | 443 | GNUNET_SCHEDULER_TaskCallback cont; |
444 | void *cont_cls; | 444 | void *cont_cls; |
445 | 445 | ||
446 | if (NULL == h->mq) | 446 | if (NULL == h->mq) |
@@ -456,10 +456,10 @@ do_disconnect (struct GNUNET_DHT_Handle *h) | |||
456 | { | 456 | { |
457 | cont = ph->cont; | 457 | cont = ph->cont; |
458 | cont_cls = ph->cont_cls; | 458 | cont_cls = ph->cont_cls; |
459 | ph->env = NULL; | ||
459 | GNUNET_DHT_put_cancel (ph); | 460 | GNUNET_DHT_put_cancel (ph); |
460 | if (NULL != cont) | 461 | if (NULL != cont) |
461 | cont (cont_cls, | 462 | cont (cont_cls); |
462 | GNUNET_SYSERR); | ||
463 | } | 463 | } |
464 | GNUNET_assert (NULL == h->reconnect_task); | 464 | GNUNET_assert (NULL == h->reconnect_task); |
465 | h->reconnect_task | 465 | h->reconnect_task |
@@ -818,31 +818,23 @@ handle_client_result (void *cls, | |||
818 | 818 | ||
819 | 819 | ||
820 | /** | 820 | /** |
821 | * Process a put confirmation message from the service. | 821 | * Process a MQ PUT transmission notification. |
822 | * | 822 | * |
823 | * @param cls The DHT handle. | 823 | * @param cls The DHT handle. |
824 | * @param msg confirmation message from the service. | ||
825 | */ | 824 | */ |
826 | static void | 825 | static void |
827 | handle_put_confirmation (void *cls, | 826 | handle_put_cont (void *cls) |
828 | const struct GNUNET_DHT_ClientPutConfirmationMessage *msg) | ||
829 | { | 827 | { |
830 | struct GNUNET_DHT_Handle *handle = cls; | 828 | struct GNUNET_DHT_PutHandle *ph = cls; |
831 | struct GNUNET_DHT_PutHandle *ph; | 829 | GNUNET_SCHEDULER_TaskCallback cont; |
832 | GNUNET_DHT_PutContinuation cont; | ||
833 | void *cont_cls; | 830 | void *cont_cls; |
834 | 831 | ||
835 | for (ph = handle->put_head; NULL != ph; ph = ph->next) | ||
836 | if (ph->unique_id == msg->unique_id) | ||
837 | break; | ||
838 | if (NULL == ph) | ||
839 | return; | ||
840 | cont = ph->cont; | 832 | cont = ph->cont; |
841 | cont_cls = ph->cont_cls; | 833 | cont_cls = ph->cont_cls; |
834 | ph->env = NULL; | ||
842 | GNUNET_DHT_put_cancel (ph); | 835 | GNUNET_DHT_put_cancel (ph); |
843 | if (NULL != cont) | 836 | if (NULL != cont) |
844 | cont (cont_cls, | 837 | cont (cont_cls); |
845 | GNUNET_OK); | ||
846 | } | 838 | } |
847 | 839 | ||
848 | 840 | ||
@@ -872,10 +864,6 @@ try_connect (struct GNUNET_DHT_Handle *h) | |||
872 | GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT, | 864 | GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT, |
873 | struct GNUNET_DHT_ClientResultMessage, | 865 | struct GNUNET_DHT_ClientResultMessage, |
874 | h), | 866 | h), |
875 | GNUNET_MQ_hd_fixed_size (put_confirmation, | ||
876 | GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT_OK, | ||
877 | struct GNUNET_DHT_ClientPutConfirmationMessage, | ||
878 | h), | ||
879 | GNUNET_MQ_handler_end () | 867 | GNUNET_MQ_handler_end () |
880 | }; | 868 | }; |
881 | if (NULL != h->mq) | 869 | if (NULL != h->mq) |
@@ -941,8 +929,7 @@ GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *handle) | |||
941 | while (NULL != (ph = handle->put_head)) | 929 | while (NULL != (ph = handle->put_head)) |
942 | { | 930 | { |
943 | if (NULL != ph->cont) | 931 | if (NULL != ph->cont) |
944 | ph->cont (ph->cont_cls, | 932 | ph->cont (ph->cont_cls); |
945 | GNUNET_SYSERR); | ||
946 | GNUNET_DHT_put_cancel (ph); | 933 | GNUNET_DHT_put_cancel (ph); |
947 | } | 934 | } |
948 | if (NULL != handle->mq) | 935 | if (NULL != handle->mq) |
@@ -989,7 +976,7 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, | |||
989 | size_t size, | 976 | size_t size, |
990 | const void *data, | 977 | const void *data, |
991 | struct GNUNET_TIME_Absolute exp, | 978 | struct GNUNET_TIME_Absolute exp, |
992 | GNUNET_DHT_PutContinuation cont, | 979 | GNUNET_SCHEDULER_TaskCallback cont, |
993 | void *cont_cls) | 980 | void *cont_cls) |
994 | { | 981 | { |
995 | struct GNUNET_MQ_Envelope *env; | 982 | struct GNUNET_MQ_Envelope *env; |
@@ -1014,22 +1001,24 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, | |||
1014 | ph->dht_handle = handle; | 1001 | ph->dht_handle = handle; |
1015 | ph->cont = cont; | 1002 | ph->cont = cont; |
1016 | ph->cont_cls = cont_cls; | 1003 | ph->cont_cls = cont_cls; |
1017 | ph->unique_id = ++handle->uid_gen; | ||
1018 | GNUNET_CONTAINER_DLL_insert_tail (handle->put_head, | 1004 | GNUNET_CONTAINER_DLL_insert_tail (handle->put_head, |
1019 | handle->put_tail, | 1005 | handle->put_tail, |
1020 | ph); | 1006 | ph); |
1021 | env = GNUNET_MQ_msg_extra (put_msg, | 1007 | env = GNUNET_MQ_msg_extra (put_msg, |
1022 | size, | 1008 | size, |
1023 | GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT); | 1009 | GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT); |
1010 | GNUNET_MQ_notify_sent (env, | ||
1011 | &handle_put_cont, | ||
1012 | ph); | ||
1013 | ph->env = env; | ||
1024 | put_msg->type = htonl ((uint32_t) type); | 1014 | put_msg->type = htonl ((uint32_t) type); |
1025 | put_msg->options = htonl ((uint32_t) options); | 1015 | put_msg->options = htonl ((uint32_t) options); |
1026 | put_msg->desired_replication_level = htonl (desired_replication_level); | 1016 | put_msg->desired_replication_level = htonl (desired_replication_level); |
1027 | put_msg->unique_id = ph->unique_id; | ||
1028 | put_msg->expiration = GNUNET_TIME_absolute_hton (exp); | 1017 | put_msg->expiration = GNUNET_TIME_absolute_hton (exp); |
1029 | put_msg->key = *key; | 1018 | put_msg->key = *key; |
1030 | GNUNET_memcpy (&put_msg[1], | 1019 | GNUNET_memcpy (&put_msg[1], |
1031 | data, | 1020 | data, |
1032 | size); | 1021 | size); |
1033 | GNUNET_MQ_send (handle->mq, | 1022 | GNUNET_MQ_send (handle->mq, |
1034 | env); | 1023 | env); |
1035 | return ph; | 1024 | return ph; |
@@ -1052,6 +1041,10 @@ GNUNET_DHT_put_cancel (struct GNUNET_DHT_PutHandle *ph) | |||
1052 | { | 1041 | { |
1053 | struct GNUNET_DHT_Handle *handle = ph->dht_handle; | 1042 | struct GNUNET_DHT_Handle *handle = ph->dht_handle; |
1054 | 1043 | ||
1044 | if (NULL != ph->env) | ||
1045 | GNUNET_MQ_notify_sent (ph->env, | ||
1046 | NULL, | ||
1047 | NULL); | ||
1055 | GNUNET_CONTAINER_DLL_remove (handle->put_head, | 1048 | GNUNET_CONTAINER_DLL_remove (handle->put_head, |
1056 | handle->put_tail, | 1049 | handle->put_tail, |
1057 | ph); | 1050 | ph); |
diff --git a/src/dht/dht_test_lib.c b/src/dht/dht_test_lib.c index 4c1bd3057..52d5a3731 100644 --- a/src/dht/dht_test_lib.c +++ b/src/dht/dht_test_lib.c | |||
@@ -114,7 +114,6 @@ dht_connect_cb (void *cls, | |||
114 | const char *emsg) | 114 | const char *emsg) |
115 | { | 115 | { |
116 | struct GNUNET_DHT_TEST_Context *ctx = cls; | 116 | struct GNUNET_DHT_TEST_Context *ctx = cls; |
117 | unsigned int i; | ||
118 | 117 | ||
119 | if (NULL != emsg) | 118 | if (NULL != emsg) |
120 | { | 119 | { |
@@ -124,10 +123,10 @@ dht_connect_cb (void *cls, | |||
124 | GNUNET_SCHEDULER_shutdown (); | 123 | GNUNET_SCHEDULER_shutdown (); |
125 | return; | 124 | return; |
126 | } | 125 | } |
127 | for (i=0;i<ctx->num_peers;i++) | 126 | for (unsigned int i=0;i<ctx->num_peers;i++) |
128 | if (op == ctx->ops[i]) | 127 | if (op == ctx->ops[i]) |
129 | ctx->dhts[i] = ca_result; | 128 | ctx->dhts[i] = ca_result; |
130 | for (i=0;i<ctx->num_peers;i++) | 129 | for (unsigned int i=0;i<ctx->num_peers;i++) |
131 | if (NULL == ctx->dhts[i]) | 130 | if (NULL == ctx->dhts[i]) |
132 | return; /* still some DHT connections missing */ | 131 | return; /* still some DHT connections missing */ |
133 | /* all DHT connections ready! */ | 132 | /* all DHT connections ready! */ |
@@ -147,9 +146,7 @@ dht_connect_cb (void *cls, | |||
147 | void | 146 | void |
148 | GNUNET_DHT_TEST_cleanup (struct GNUNET_DHT_TEST_Context *ctx) | 147 | GNUNET_DHT_TEST_cleanup (struct GNUNET_DHT_TEST_Context *ctx) |
149 | { | 148 | { |
150 | unsigned int i; | 149 | for (unsigned int i=0;i<ctx->num_peers;i++) |
151 | |||
152 | for (i=0;i<ctx->num_peers;i++) | ||
153 | GNUNET_TESTBED_operation_done (ctx->ops[i]); | 150 | GNUNET_TESTBED_operation_done (ctx->ops[i]); |
154 | GNUNET_free (ctx->ops); | 151 | GNUNET_free (ctx->ops); |
155 | GNUNET_free (ctx->dhts); | 152 | GNUNET_free (ctx->dhts); |
@@ -160,18 +157,17 @@ GNUNET_DHT_TEST_cleanup (struct GNUNET_DHT_TEST_Context *ctx) | |||
160 | 157 | ||
161 | static void | 158 | static void |
162 | dht_test_run (void *cls, | 159 | dht_test_run (void *cls, |
163 | struct GNUNET_TESTBED_RunHandle *h, | 160 | struct GNUNET_TESTBED_RunHandle *h, |
164 | unsigned int num_peers, | 161 | unsigned int num_peers, |
165 | struct GNUNET_TESTBED_Peer **peers, | 162 | struct GNUNET_TESTBED_Peer **peers, |
166 | unsigned int links_succeeded, | 163 | unsigned int links_succeeded, |
167 | unsigned int links_failed) | 164 | unsigned int links_failed) |
168 | { | 165 | { |
169 | struct GNUNET_DHT_TEST_Context *ctx = cls; | 166 | struct GNUNET_DHT_TEST_Context *ctx = cls; |
170 | unsigned int i; | ||
171 | 167 | ||
172 | GNUNET_assert (num_peers == ctx->num_peers); | 168 | GNUNET_assert (num_peers == ctx->num_peers); |
173 | ctx->peers = peers; | 169 | ctx->peers = peers; |
174 | for (i=0;i<num_peers;i++) | 170 | for (unsigned int i=0;i<num_peers;i++) |
175 | ctx->ops[i] = GNUNET_TESTBED_service_connect (ctx, | 171 | ctx->ops[i] = GNUNET_TESTBED_service_connect (ctx, |
176 | peers[i], | 172 | peers[i], |
177 | "dht", | 173 | "dht", |
diff --git a/src/dht/gnunet-dht-put.c b/src/dht/gnunet-dht-put.c index f183fe588..db4d04681 100644 --- a/src/dht/gnunet-dht-put.c +++ b/src/dht/gnunet-dht-put.c | |||
@@ -103,34 +103,12 @@ shutdown_task (void *cls) | |||
103 | * Signature of the main function of a task. | 103 | * Signature of the main function of a task. |
104 | * | 104 | * |
105 | * @param cls closure | 105 | * @param cls closure |
106 | * @param success #GNUNET_OK if the PUT was transmitted, | ||
107 | * #GNUNET_NO on timeout, | ||
108 | * #GNUNET_SYSERR on disconnect from service | ||
109 | * after the PUT message was transmitted | ||
110 | * (so we don't know if it was received or not) | ||
111 | */ | 106 | */ |
112 | static void | 107 | static void |
113 | message_sent_cont (void *cls, int success) | 108 | message_sent_cont (void *cls) |
114 | { | 109 | { |
115 | if (verbose) | 110 | GNUNET_SCHEDULER_add_now (&shutdown_task, |
116 | { | 111 | NULL); |
117 | switch (success) | ||
118 | { | ||
119 | case GNUNET_OK: | ||
120 | FPRINTF (stderr, "%s `%s'!\n", _("PUT request sent with key"), GNUNET_h2s_full(&key)); | ||
121 | break; | ||
122 | case GNUNET_NO: | ||
123 | FPRINTF (stderr, "%s", _("Timeout sending PUT request!\n")); | ||
124 | break; | ||
125 | case GNUNET_SYSERR: | ||
126 | FPRINTF (stderr, "%s", _("PUT request not confirmed!\n")); | ||
127 | break; | ||
128 | default: | ||
129 | GNUNET_break (0); | ||
130 | break; | ||
131 | } | ||
132 | } | ||
133 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | ||
134 | } | 112 | } |
135 | 113 | ||
136 | 114 | ||
@@ -160,7 +138,8 @@ run (void *cls, | |||
160 | 138 | ||
161 | if (NULL == (dht_handle = GNUNET_DHT_connect (cfg, 1))) | 139 | if (NULL == (dht_handle = GNUNET_DHT_connect (cfg, 1))) |
162 | { | 140 | { |
163 | FPRINTF (stderr, _("Could not connect to %s service!\n"), "DHT"); | 141 | FPRINTF (stderr, |
142 | _("Could not connect to DHT service!\n")); | ||
164 | ret = 1; | 143 | ret = 1; |
165 | return; | 144 | return; |
166 | } | 145 | } |
@@ -203,55 +182,47 @@ main (int argc, char *const *argv) | |||
203 | { | 182 | { |
204 | 183 | ||
205 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 184 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
206 | |||
207 | GNUNET_GETOPT_option_string ('d', | 185 | GNUNET_GETOPT_option_string ('d', |
208 | "data", | 186 | "data", |
209 | "DATA", | 187 | "DATA", |
210 | gettext_noop ("the data to insert under the key"), | 188 | gettext_noop ("the data to insert under the key"), |
211 | &data), | 189 | &data), |
212 | |||
213 | GNUNET_GETOPT_option_relative_time ('e', | 190 | GNUNET_GETOPT_option_relative_time ('e', |
214 | "expiration", | 191 | "expiration", |
215 | "EXPIRATION", | 192 | "EXPIRATION", |
216 | gettext_noop ("how long to store this entry in the dht (in seconds)"), | 193 | gettext_noop ("how long to store this entry in the dht (in seconds)"), |
217 | &expiration), | 194 | &expiration), |
218 | |||
219 | GNUNET_GETOPT_option_string ('k', | 195 | GNUNET_GETOPT_option_string ('k', |
220 | "key", | 196 | "key", |
221 | "KEY", | 197 | "KEY", |
222 | gettext_noop ("the query key"), | 198 | gettext_noop ("the query key"), |
223 | &query_key), | 199 | &query_key), |
224 | |||
225 | GNUNET_GETOPT_option_flag ('x', | 200 | GNUNET_GETOPT_option_flag ('x', |
226 | "demultiplex", | 201 | "demultiplex", |
227 | gettext_noop ("use DHT's demultiplex everywhere option"), | 202 | gettext_noop ("use DHT's demultiplex everywhere option"), |
228 | &demultixplex_everywhere), | 203 | &demultixplex_everywhere), |
229 | |||
230 | GNUNET_GETOPT_option_uint ('r', | 204 | GNUNET_GETOPT_option_uint ('r', |
231 | "replication", | 205 | "replication", |
232 | "LEVEL", | 206 | "LEVEL", |
233 | gettext_noop ("how many replicas to create"), | 207 | gettext_noop ("how many replicas to create"), |
234 | &replication), | 208 | &replication), |
235 | |||
236 | GNUNET_GETOPT_option_flag ('R', | 209 | GNUNET_GETOPT_option_flag ('R', |
237 | "record", | 210 | "record", |
238 | gettext_noop ("use DHT's record route option"), | 211 | gettext_noop ("use DHT's record route option"), |
239 | &record_route), | 212 | &record_route), |
240 | |||
241 | GNUNET_GETOPT_option_uint ('t', | 213 | GNUNET_GETOPT_option_uint ('t', |
242 | "type", | 214 | "type", |
243 | "TYPE", | 215 | "TYPE", |
244 | gettext_noop ("the type to insert data as"), | 216 | gettext_noop ("the type to insert data as"), |
245 | &query_type), | 217 | &query_type), |
246 | |||
247 | GNUNET_GETOPT_option_verbose (&verbose), | 218 | GNUNET_GETOPT_option_verbose (&verbose), |
248 | |||
249 | GNUNET_GETOPT_OPTION_END | 219 | GNUNET_GETOPT_OPTION_END |
250 | }; | 220 | }; |
251 | 221 | ||
252 | 222 | ||
253 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, | 223 | if (GNUNET_OK != |
254 | &argc, &argv)) | 224 | GNUNET_STRINGS_get_utf8_args (argc, argv, |
225 | &argc, &argv)) | ||
255 | return 2; | 226 | return 2; |
256 | expiration = GNUNET_TIME_UNIT_HOURS; | 227 | expiration = GNUNET_TIME_UNIT_HOURS; |
257 | return (GNUNET_OK == | 228 | return (GNUNET_OK == |
diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c index cb155c484..503d7867b 100644 --- a/src/dht/gnunet-service-dht_clients.c +++ b/src/dht/gnunet-service-dht_clients.c | |||
@@ -477,8 +477,6 @@ handle_dht_local_put (void *cls, | |||
477 | struct ClientHandle *ch = cls; | 477 | struct ClientHandle *ch = cls; |
478 | struct GNUNET_CONTAINER_BloomFilter *peer_bf; | 478 | struct GNUNET_CONTAINER_BloomFilter *peer_bf; |
479 | uint16_t size; | 479 | uint16_t size; |
480 | struct GNUNET_MQ_Envelope *env; | ||
481 | struct GNUNET_DHT_ClientPutConfirmationMessage *conf; | ||
482 | 480 | ||
483 | size = ntohs (dht_msg->header.size); | 481 | size = ntohs (dht_msg->header.size); |
484 | GNUNET_STATISTICS_update (GDS_stats, | 482 | GNUNET_STATISTICS_update (GDS_stats, |
@@ -537,12 +535,6 @@ handle_dht_local_put (void *cls, | |||
537 | &dht_msg[1], | 535 | &dht_msg[1], |
538 | size - sizeof (struct GNUNET_DHT_ClientPutMessage)); | 536 | size - sizeof (struct GNUNET_DHT_ClientPutMessage)); |
539 | GNUNET_CONTAINER_bloomfilter_free (peer_bf); | 537 | GNUNET_CONTAINER_bloomfilter_free (peer_bf); |
540 | env = GNUNET_MQ_msg (conf, | ||
541 | GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT_OK); | ||
542 | conf->reserved = htonl (0); | ||
543 | conf->unique_id = dht_msg->unique_id; | ||
544 | GNUNET_MQ_send (ch->mq, | ||
545 | env); | ||
546 | GNUNET_SERVICE_client_continue (ch->client); | 538 | GNUNET_SERVICE_client_continue (ch->client); |
547 | } | 539 | } |
548 | 540 | ||
diff --git a/src/dht/test_dht_api.c b/src/dht/test_dht_api.c index 8f4e0ed31..62d121306 100644 --- a/src/dht/test_dht_api.c +++ b/src/dht/test_dht_api.c | |||
@@ -105,11 +105,9 @@ test_get_iterator (void *cls, | |||
105 | * Signature of the main function of a task. | 105 | * Signature of the main function of a task. |
106 | * | 106 | * |
107 | * @param cls closure | 107 | * @param cls closure |
108 | * @param success result of PUT | ||
109 | */ | 108 | */ |
110 | static void | 109 | static void |
111 | test_get (void *cls, | 110 | test_get (void *cls) |
112 | int success) | ||
113 | { | 111 | { |
114 | struct GNUNET_HashCode hash; | 112 | struct GNUNET_HashCode hash; |
115 | 113 | ||
diff --git a/src/dht/test_dht_topo.c b/src/dht/test_dht_topo.c index 8be3064f7..79edb2b0c 100644 --- a/src/dht/test_dht_topo.c +++ b/src/dht/test_dht_topo.c | |||
@@ -332,19 +332,17 @@ dht_get_handler (void *cls, | |||
332 | "Get successful\n"); | 332 | "Get successful\n"); |
333 | #if 0 | 333 | #if 0 |
334 | { | 334 | { |
335 | int i; | ||
336 | |||
337 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 335 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
338 | "PATH: (get %u, put %u)\n", | 336 | "PATH: (get %u, put %u)\n", |
339 | get_path_length, | 337 | get_path_length, |
340 | put_path_length); | 338 | put_path_length); |
341 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 339 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
342 | " LOCAL\n"); | 340 | " LOCAL\n"); |
343 | for (i = get_path_length - 1; i >= 0; i--) | 341 | for (int i = get_path_length - 1; i >= 0; i--) |
344 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 342 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
345 | " %s\n", | 343 | " %s\n", |
346 | GNUNET_i2s (&get_path[i])); | 344 | GNUNET_i2s (&get_path[i])); |
347 | for (i = put_path_length - 1; i >= 0; i--) | 345 | for (int i = put_path_length - 1; i >= 0; i--) |
348 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 346 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
349 | " %s\n", | 347 | " %s\n", |
350 | GNUNET_i2s (&put_path[i])); | 348 | GNUNET_i2s (&put_path[i])); |
@@ -384,12 +382,11 @@ do_puts (void *cls) | |||
384 | struct GNUNET_DHT_Handle **hs = cls; | 382 | struct GNUNET_DHT_Handle **hs = cls; |
385 | struct GNUNET_HashCode key; | 383 | struct GNUNET_HashCode key; |
386 | struct GNUNET_HashCode value; | 384 | struct GNUNET_HashCode value; |
387 | unsigned int i; | ||
388 | 385 | ||
389 | put_task = NULL; | 386 | put_task = NULL; |
390 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 387 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
391 | "Putting values into DHT\n"); | 388 | "Putting values into DHT\n"); |
392 | for (i = 0; i < NUM_PEERS; i++) | 389 | for (unsigned int i = 0; i < NUM_PEERS; i++) |
393 | { | 390 | { |
394 | GNUNET_CRYPTO_hash (&i, | 391 | GNUNET_CRYPTO_hash (&i, |
395 | sizeof (i), | 392 | sizeof (i), |
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c index 5cb1ebfd9..ae40feea0 100644 --- a/src/exit/gnunet-daemon-exit.c +++ b/src/exit/gnunet-daemon-exit.c | |||
@@ -3426,16 +3426,11 @@ do_dht_put (void *cls); | |||
3426 | * Schedules the next PUT. | 3426 | * Schedules the next PUT. |
3427 | * | 3427 | * |
3428 | * @param cls closure, NULL | 3428 | * @param cls closure, NULL |
3429 | * @param success #GNUNET_OK if the operation worked (unused) | ||
3430 | */ | 3429 | */ |
3431 | static void | 3430 | static void |
3432 | dht_put_cont (void *cls, | 3431 | dht_put_cont (void *cls) |
3433 | int success) | ||
3434 | { | 3432 | { |
3435 | dht_put = NULL; | 3433 | dht_put = NULL; |
3436 | dht_task = GNUNET_SCHEDULER_add_delayed (DHT_PUT_FREQUENCY, | ||
3437 | &do_dht_put, | ||
3438 | NULL); | ||
3439 | } | 3434 | } |
3440 | 3435 | ||
3441 | 3436 | ||
@@ -3450,7 +3445,9 @@ do_dht_put (void *cls) | |||
3450 | { | 3445 | { |
3451 | struct GNUNET_TIME_Absolute expiration; | 3446 | struct GNUNET_TIME_Absolute expiration; |
3452 | 3447 | ||
3453 | dht_task = NULL; | 3448 | dht_task = GNUNET_SCHEDULER_add_delayed (DHT_PUT_FREQUENCY, |
3449 | &do_dht_put, | ||
3450 | NULL); | ||
3454 | expiration = GNUNET_TIME_absolute_ntoh (dns_advertisement.expiration_time); | 3451 | expiration = GNUNET_TIME_absolute_ntoh (dns_advertisement.expiration_time); |
3455 | if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us < | 3452 | if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us < |
3456 | GNUNET_TIME_UNIT_HOURS.rel_value_us) | 3453 | GNUNET_TIME_UNIT_HOURS.rel_value_us) |
@@ -3463,6 +3460,8 @@ do_dht_put (void *cls) | |||
3463 | &dns_advertisement.purpose, | 3460 | &dns_advertisement.purpose, |
3464 | &dns_advertisement.signature)); | 3461 | &dns_advertisement.signature)); |
3465 | } | 3462 | } |
3463 | if (NULL != dht_put) | ||
3464 | GNUNET_DHT_put_cancel (dht_put); | ||
3466 | dht_put = GNUNET_DHT_put (dht, | 3465 | dht_put = GNUNET_DHT_put (dht, |
3467 | &dht_put_key, | 3466 | &dht_put_key, |
3468 | 1 /* replication */, | 3467 | 1 /* replication */, |
diff --git a/src/fs/gnunet-service-fs_put.c b/src/fs/gnunet-service-fs_put.c index e8c7f586d..bb8560fff 100644 --- a/src/fs/gnunet-service-fs_put.c +++ b/src/fs/gnunet-service-fs_put.c | |||
@@ -135,14 +135,9 @@ schedule_next_put (struct PutOperator *po) | |||
135 | * Continuation called after DHT PUT operation has finished. | 135 | * Continuation called after DHT PUT operation has finished. |
136 | * | 136 | * |
137 | * @param cls type of blocks to gather | 137 | * @param cls type of blocks to gather |
138 | * @param success GNUNET_OK if the PUT was transmitted, | ||
139 | * GNUNET_NO on timeout, | ||
140 | * GNUNET_SYSERR on disconnect from service | ||
141 | * after the PUT message was transmitted | ||
142 | * (so we don't know if it was received or not) | ||
143 | */ | 138 | */ |
144 | static void | 139 | static void |
145 | delay_dht_put_blocks (void *cls, int success) | 140 | delay_dht_put_blocks (void *cls) |
146 | { | 141 | { |
147 | struct PutOperator *po = cls; | 142 | struct PutOperator *po = cls; |
148 | 143 | ||
diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h index d798482e3..a4c63889e 100644 --- a/src/include/gnunet_dht_service.h +++ b/src/include/gnunet_dht_service.h | |||
@@ -142,22 +142,6 @@ struct GNUNET_DHT_PutHandle; | |||
142 | 142 | ||
143 | 143 | ||
144 | /** | 144 | /** |
145 | * Type of a PUT continuation. You must not call | ||
146 | * #GNUNET_DHT_disconnect in this continuation. | ||
147 | * | ||
148 | * @param cls closure | ||
149 | * @param success #GNUNET_OK if the PUT was transmitted, | ||
150 | * #GNUNET_NO on timeout, | ||
151 | * #GNUNET_SYSERR on disconnect from service | ||
152 | * after the PUT message was transmitted | ||
153 | * (so we don't know if it was received or not) | ||
154 | */ | ||
155 | typedef void | ||
156 | (*GNUNET_DHT_PutContinuation)(void *cls, | ||
157 | int success); | ||
158 | |||
159 | |||
160 | /** | ||
161 | * Perform a PUT operation storing data in the DHT. | 145 | * Perform a PUT operation storing data in the DHT. |
162 | * | 146 | * |
163 | * @param handle handle to DHT service | 147 | * @param handle handle to DHT service |
@@ -184,7 +168,7 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, | |||
184 | size_t size, | 168 | size_t size, |
185 | const void *data, | 169 | const void *data, |
186 | struct GNUNET_TIME_Absolute exp, | 170 | struct GNUNET_TIME_Absolute exp, |
187 | GNUNET_DHT_PutContinuation cont, | 171 | GNUNET_SCHEDULER_TaskCallback cont, |
188 | void *cont_cls); | 172 | void *cont_cls); |
189 | 173 | ||
190 | 174 | ||
diff --git a/src/include/gnunet_namestore_plugin.h b/src/include/gnunet_namestore_plugin.h index 802d7bac5..c3ab4d8bf 100644 --- a/src/include/gnunet_namestore_plugin.h +++ b/src/include/gnunet_namestore_plugin.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2012, 2013 GNUnet e.V. | 3 | Copyright (C) 2012, 2013, 2018 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -47,6 +47,7 @@ extern "C" | |||
47 | * Function called for each matching record. | 47 | * Function called for each matching record. |
48 | * | 48 | * |
49 | * @param cls closure | 49 | * @param cls closure |
50 | * @param serial unique serial number of the record | ||
50 | * @param zone_key private key of the zone | 51 | * @param zone_key private key of the zone |
51 | * @param label name that is being mapped (at most 255 characters long) | 52 | * @param label name that is being mapped (at most 255 characters long) |
52 | * @param rd_count number of entries in @a rd array | 53 | * @param rd_count number of entries in @a rd array |
@@ -54,6 +55,7 @@ extern "C" | |||
54 | */ | 55 | */ |
55 | typedef void | 56 | typedef void |
56 | (*GNUNET_NAMESTORE_RecordIterator) (void *cls, | 57 | (*GNUNET_NAMESTORE_RecordIterator) (void *cls, |
58 | uint64_t serial, | ||
57 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key, | 59 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key, |
58 | const char *label, | 60 | const char *label, |
59 | unsigned int rd_count, | 61 | unsigned int rd_count, |
@@ -113,7 +115,7 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
113 | * | 115 | * |
114 | * @param cls closure (internal context for the plugin) | 116 | * @param cls closure (internal context for the plugin) |
115 | * @param zone private key of the zone, NULL for all zones | 117 | * @param zone private key of the zone, NULL for all zones |
116 | * @param offset offset in the list of all matching records | 118 | * @param serial serial (to exclude) in the list of matching records |
117 | * @param limit maximum number of results to return to @a iter | 119 | * @param limit maximum number of results to return to @a iter |
118 | * @param iter function to call with the result | 120 | * @param iter function to call with the result |
119 | * @param iter_cls closure for @a iter | 121 | * @param iter_cls closure for @a iter |
@@ -122,7 +124,7 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
122 | int | 124 | int |
123 | (*iterate_records) (void *cls, | 125 | (*iterate_records) (void *cls, |
124 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 126 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
125 | uint64_t offset, | 127 | uint64_t serial, |
126 | uint64_t limit, | 128 | uint64_t limit, |
127 | GNUNET_NAMESTORE_RecordIterator iter, | 129 | GNUNET_NAMESTORE_RecordIterator iter, |
128 | void *iter_cls); | 130 | void *iter_cls); |
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index d692b28ff..bf1b48679 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -624,11 +624,6 @@ extern "C" | |||
624 | #define GNUNET_MESSAGE_TYPE_DHT_MONITOR_STOP 154 | 624 | #define GNUNET_MESSAGE_TYPE_DHT_MONITOR_STOP 154 |
625 | 625 | ||
626 | /** | 626 | /** |
627 | * Acknowledge receiving PUT request | ||
628 | */ | ||
629 | #define GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT_OK 155 | ||
630 | |||
631 | /** | ||
632 | * Certain results are already known to the client, filter those. | 627 | * Certain results are already known to the client, filter those. |
633 | */ | 628 | */ |
634 | #define GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN 156 | 629 | #define GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN 156 |
diff --git a/src/namestore/gnunet-namestore-fcfsd.c b/src/namestore/gnunet-namestore-fcfsd.c index 6e45f8227..903253b1a 100644 --- a/src/namestore/gnunet-namestore-fcfsd.c +++ b/src/namestore/gnunet-namestore-fcfsd.c | |||
@@ -324,6 +324,7 @@ iterate_cb (void *cls, | |||
324 | char* pkey; | 324 | char* pkey; |
325 | char* new_buf; | 325 | char* new_buf; |
326 | 326 | ||
327 | (void) zone_key; | ||
327 | if (1 != rd_len) | 328 | if (1 != rd_len) |
328 | { | 329 | { |
329 | GNUNET_NAMESTORE_zone_iterator_next (zr->list_it, | 330 | GNUNET_NAMESTORE_zone_iterator_next (zr->list_it, |
@@ -439,6 +440,7 @@ fill_s_reply (const char *info, | |||
439 | char *reply; | 440 | char *reply; |
440 | struct MHD_Response *response; | 441 | struct MHD_Response *response; |
441 | 442 | ||
443 | (void) request; | ||
442 | GNUNET_asprintf (&reply, | 444 | GNUNET_asprintf (&reply, |
443 | SUBMIT_PAGE, | 445 | SUBMIT_PAGE, |
444 | info, | 446 | info, |
@@ -587,6 +589,8 @@ zone_to_name_cb (void *cls, | |||
587 | struct Request *request = cls; | 589 | struct Request *request = cls; |
588 | struct GNUNET_GNSRECORD_Data r; | 590 | struct GNUNET_GNSRECORD_Data r; |
589 | 591 | ||
592 | (void) rd; | ||
593 | (void) zone_key; | ||
590 | request->qe = NULL; | 594 | request->qe = NULL; |
591 | if (0 != rd_count) | 595 | if (0 != rd_count) |
592 | { | 596 | { |
@@ -644,6 +648,9 @@ lookup_block_processor (void *cls, | |||
644 | { | 648 | { |
645 | struct Request *request = cls; | 649 | struct Request *request = cls; |
646 | 650 | ||
651 | (void) label; | ||
652 | (void) rd; | ||
653 | (void) zone; | ||
647 | request->qe = NULL; | 654 | request->qe = NULL; |
648 | if (0 == rd_count) | 655 | if (0 == rd_count) |
649 | { | 656 | { |
@@ -715,6 +722,8 @@ create_response (void *cls, | |||
715 | struct GNUNET_CRYPTO_EcdsaPublicKey pub; | 722 | struct GNUNET_CRYPTO_EcdsaPublicKey pub; |
716 | int ret; | 723 | int ret; |
717 | 724 | ||
725 | (void) cls; | ||
726 | (void) version; | ||
718 | if ( (0 == strcmp (method, MHD_HTTP_METHOD_GET)) || | 727 | if ( (0 == strcmp (method, MHD_HTTP_METHOD_GET)) || |
719 | (0 == strcmp (method, MHD_HTTP_METHOD_HEAD)) ) | 728 | (0 == strcmp (method, MHD_HTTP_METHOD_HEAD)) ) |
720 | { | 729 | { |
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index 7b8312b46..d329dcb3b 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c | |||
@@ -661,6 +661,8 @@ handle_reverse_lookup (void *cls, | |||
661 | { | 661 | { |
662 | (void) cls; | 662 | (void) cls; |
663 | (void) zone; | 663 | (void) zone; |
664 | (void) rd_count; | ||
665 | (void) rd; | ||
664 | reverse_qe = NULL; | 666 | reverse_qe = NULL; |
665 | if (NULL == label) | 667 | if (NULL == label) |
666 | FPRINTF (stdout, | 668 | FPRINTF (stdout, |
@@ -712,6 +714,7 @@ del_monitor (void *cls, | |||
712 | char *vs; | 714 | char *vs; |
713 | 715 | ||
714 | (void) cls; | 716 | (void) cls; |
717 | (void) zone; | ||
715 | del_qe = NULL; | 718 | del_qe = NULL; |
716 | if (0 == rd_count) | 719 | if (0 == rd_count) |
717 | { | 720 | { |
@@ -1092,6 +1095,9 @@ id_connect_cb (void *cls, | |||
1092 | { | 1095 | { |
1093 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; | 1096 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; |
1094 | 1097 | ||
1098 | (void) cls; | ||
1099 | (void) ctx; | ||
1100 | (void) name; | ||
1095 | if (NULL == ego) | 1101 | if (NULL == ego) |
1096 | { | 1102 | { |
1097 | get_default = GNUNET_IDENTITY_get (idh, | 1103 | get_default = GNUNET_IDENTITY_get (idh, |
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index b9061ed9f..e3936a7cc 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -75,6 +75,15 @@ struct ZoneIteration | |||
75 | struct GNUNET_CRYPTO_EcdsaPrivateKey zone; | 75 | struct GNUNET_CRYPTO_EcdsaPrivateKey zone; |
76 | 76 | ||
77 | /** | 77 | /** |
78 | * Last sequence number in the zone iteration used to address next | ||
79 | * result of the zone iteration in the store | ||
80 | * | ||
81 | * Initialy set to 0. | ||
82 | * Updated in #zone_iterate_proc() | ||
83 | */ | ||
84 | uint64_t seq; | ||
85 | |||
86 | /** | ||
78 | * The operation id fot the zone iteration in the response for the client | 87 | * The operation id fot the zone iteration in the response for the client |
79 | */ | 88 | */ |
80 | uint32_t request_id; | 89 | uint32_t request_id; |
@@ -152,13 +161,13 @@ struct ZoneMonitor | |||
152 | struct GNUNET_SCHEDULER_Task *task; | 161 | struct GNUNET_SCHEDULER_Task *task; |
153 | 162 | ||
154 | /** | 163 | /** |
155 | * Offset of the zone iteration used to address next result of the zone | 164 | * Last sequence number in the zone iteration used to address next |
156 | * iteration in the store | 165 | * result of the zone iteration in the store |
157 | * | 166 | * |
158 | * Initialy set to 0. | 167 | * Initialy set to 0. |
159 | * Incremented with by every call to #handle_iteration_next | 168 | * Updated in #monitor_iterate_cb() |
160 | */ | 169 | */ |
161 | uint32_t offset; | 170 | uint64_t seq; |
162 | 171 | ||
163 | }; | 172 | }; |
164 | 173 | ||
@@ -394,6 +403,7 @@ client_connect_cb (void *cls, | |||
394 | * record, which (if found) is then copied to @a cls for future use. | 403 | * record, which (if found) is then copied to @a cls for future use. |
395 | * | 404 | * |
396 | * @param cls a `struct GNUNET_GNSRECORD_Data **` for storing the nick (if found) | 405 | * @param cls a `struct GNUNET_GNSRECORD_Data **` for storing the nick (if found) |
406 | * @param seq sequence number of the record | ||
397 | * @param private_key the private key of the zone (unused) | 407 | * @param private_key the private key of the zone (unused) |
398 | * @param label should be #GNUNET_GNS_EMPTY_LABEL_AT | 408 | * @param label should be #GNUNET_GNS_EMPTY_LABEL_AT |
399 | * @param rd_count number of records in @a rd | 409 | * @param rd_count number of records in @a rd |
@@ -401,6 +411,7 @@ client_connect_cb (void *cls, | |||
401 | */ | 411 | */ |
402 | static void | 412 | static void |
403 | lookup_nick_it (void *cls, | 413 | lookup_nick_it (void *cls, |
414 | uint64_t seq, | ||
404 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key, | 415 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key, |
405 | const char *label, | 416 | const char *label, |
406 | unsigned int rd_count, | 417 | unsigned int rd_count, |
@@ -409,6 +420,7 @@ lookup_nick_it (void *cls, | |||
409 | struct GNUNET_GNSRECORD_Data **res = cls; | 420 | struct GNUNET_GNSRECORD_Data **res = cls; |
410 | 421 | ||
411 | (void) private_key; | 422 | (void) private_key; |
423 | (void) seq; | ||
412 | if (0 != strcmp (label, GNUNET_GNS_EMPTY_LABEL_AT)) | 424 | if (0 != strcmp (label, GNUNET_GNS_EMPTY_LABEL_AT)) |
413 | { | 425 | { |
414 | GNUNET_break (0); | 426 | GNUNET_break (0); |
@@ -730,6 +742,9 @@ refresh_block (struct NamestoreClient *nc, | |||
730 | "Namecache updates skipped (NC disabled)", | 742 | "Namecache updates skipped (NC disabled)", |
731 | 1, | 743 | 1, |
732 | GNUNET_NO); | 744 | GNUNET_NO); |
745 | send_store_response (nc, | ||
746 | GNUNET_OK, | ||
747 | rid); | ||
733 | return; | 748 | return; |
734 | } | 749 | } |
735 | exp_time = GNUNET_GNSRECORD_record_get_expiration_time (res_count, | 750 | exp_time = GNUNET_GNSRECORD_record_get_expiration_time (res_count, |
@@ -813,9 +828,11 @@ struct RecordLookupContext | |||
813 | 828 | ||
814 | /** | 829 | /** |
815 | * FIXME. | 830 | * FIXME. |
831 | * @param seq sequence number of the record | ||
816 | */ | 832 | */ |
817 | static void | 833 | static void |
818 | lookup_it (void *cls, | 834 | lookup_it (void *cls, |
835 | uint64_t seq, | ||
819 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key, | 836 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key, |
820 | const char *label, | 837 | const char *label, |
821 | unsigned int rd_count, | 838 | unsigned int rd_count, |
@@ -826,6 +843,7 @@ lookup_it (void *cls, | |||
826 | unsigned int rdc_res; | 843 | unsigned int rdc_res; |
827 | 844 | ||
828 | (void) private_key; | 845 | (void) private_key; |
846 | (void) seq; | ||
829 | if (0 == strcmp (label, | 847 | if (0 == strcmp (label, |
830 | rlc->label)) | 848 | rlc->label)) |
831 | { | 849 | { |
@@ -1212,6 +1230,7 @@ struct ZoneToNameCtx | |||
1212 | * Zone to name iterator | 1230 | * Zone to name iterator |
1213 | * | 1231 | * |
1214 | * @param cls struct ZoneToNameCtx * | 1232 | * @param cls struct ZoneToNameCtx * |
1233 | * @param seq sequence number of the record | ||
1215 | * @param zone_key the zone key | 1234 | * @param zone_key the zone key |
1216 | * @param name name | 1235 | * @param name name |
1217 | * @param rd_count number of records in @a rd | 1236 | * @param rd_count number of records in @a rd |
@@ -1219,6 +1238,7 @@ struct ZoneToNameCtx | |||
1219 | */ | 1238 | */ |
1220 | static void | 1239 | static void |
1221 | handle_zone_to_name_it (void *cls, | 1240 | handle_zone_to_name_it (void *cls, |
1241 | uint64_t seq, | ||
1222 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, | 1242 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, |
1223 | const char *name, | 1243 | const char *name, |
1224 | unsigned int rd_count, | 1244 | unsigned int rd_count, |
@@ -1234,6 +1254,7 @@ handle_zone_to_name_it (void *cls, | |||
1234 | char *name_tmp; | 1254 | char *name_tmp; |
1235 | char *rd_tmp; | 1255 | char *rd_tmp; |
1236 | 1256 | ||
1257 | (void) seq; | ||
1237 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1258 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1238 | "Found result for zone-to-name lookup: `%s'\n", | 1259 | "Found result for zone-to-name lookup: `%s'\n", |
1239 | name); | 1260 | name); |
@@ -1342,8 +1363,9 @@ struct ZoneIterationProcResult | |||
1342 | 1363 | ||
1343 | /** | 1364 | /** |
1344 | * Process results for zone iteration from database | 1365 | * Process results for zone iteration from database |
1345 | * | 1366 | * |
1346 | * @param cls struct ZoneIterationProcResult *proc | 1367 | * @param cls struct ZoneIterationProcResult |
1368 | * @param seq sequence number of the record | ||
1347 | * @param zone_key the zone key | 1369 | * @param zone_key the zone key |
1348 | * @param name name | 1370 | * @param name name |
1349 | * @param rd_count number of records for this name | 1371 | * @param rd_count number of records for this name |
@@ -1351,6 +1373,7 @@ struct ZoneIterationProcResult | |||
1351 | */ | 1373 | */ |
1352 | static void | 1374 | static void |
1353 | zone_iterate_proc (void *cls, | 1375 | zone_iterate_proc (void *cls, |
1376 | uint64_t seq, | ||
1354 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, | 1377 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, |
1355 | const char *name, | 1378 | const char *name, |
1356 | unsigned int rd_count, | 1379 | unsigned int rd_count, |
@@ -1380,6 +1403,7 @@ zone_iterate_proc (void *cls, | |||
1380 | return; | 1403 | return; |
1381 | } | 1404 | } |
1382 | proc->limit--; | 1405 | proc->limit--; |
1406 | proc->zi->seq = seq; | ||
1383 | send_lookup_response (proc->zi->nc, | 1407 | send_lookup_response (proc->zi->nc, |
1384 | proc->zi->request_id, | 1408 | proc->zi->request_id, |
1385 | zone_key, | 1409 | zone_key, |
@@ -1416,12 +1440,15 @@ run_zone_iteration_round (struct ZoneIteration *zi, | |||
1416 | struct ZoneIterationProcResult proc; | 1440 | struct ZoneIterationProcResult proc; |
1417 | struct GNUNET_MQ_Envelope *env; | 1441 | struct GNUNET_MQ_Envelope *env; |
1418 | struct RecordResultMessage *rrm; | 1442 | struct RecordResultMessage *rrm; |
1443 | struct GNUNET_TIME_Absolute start; | ||
1444 | struct GNUNET_TIME_Relative duration; | ||
1419 | 1445 | ||
1420 | memset (&proc, | 1446 | memset (&proc, |
1421 | 0, | 1447 | 0, |
1422 | sizeof (proc)); | 1448 | sizeof (proc)); |
1423 | proc.zi = zi; | 1449 | proc.zi = zi; |
1424 | proc.limit = limit; | 1450 | proc.limit = limit; |
1451 | start = GNUNET_TIME_absolute_get (); | ||
1425 | GNUNET_break (GNUNET_SYSERR != | 1452 | GNUNET_break (GNUNET_SYSERR != |
1426 | GSN_database->iterate_records (GSN_database->cls, | 1453 | GSN_database->iterate_records (GSN_database->cls, |
1427 | (0 == memcmp (&zi->zone, | 1454 | (0 == memcmp (&zi->zone, |
@@ -1429,18 +1456,29 @@ run_zone_iteration_round (struct ZoneIteration *zi, | |||
1429 | sizeof (zero))) | 1456 | sizeof (zero))) |
1430 | ? NULL | 1457 | ? NULL |
1431 | : &zi->zone, | 1458 | : &zi->zone, |
1432 | zi->offset, | 1459 | zi->seq, |
1433 | limit, | 1460 | limit, |
1434 | &zone_iterate_proc, | 1461 | &zone_iterate_proc, |
1435 | &proc)); | 1462 | &proc)); |
1436 | zi->offset += (limit - proc.limit); | 1463 | duration = GNUNET_TIME_absolute_get_duration (start); |
1464 | duration = GNUNET_TIME_relative_divide (duration, | ||
1465 | limit - proc.limit); | ||
1466 | GNUNET_STATISTICS_set (statistics, | ||
1467 | "NAMESTORE iteration delay (μs/record)", | ||
1468 | duration.rel_value_us, | ||
1469 | GNUNET_NO); | ||
1437 | if (0 == proc.limit) | 1470 | if (0 == proc.limit) |
1438 | { | 1471 | { |
1439 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1472 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1440 | "More results available\n"); | 1473 | "Returned %llu results, more results available\n", |
1474 | (unsigned long long) limit); | ||
1441 | return; /* more results later after we get the | 1475 | return; /* more results later after we get the |
1442 | #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT message */ | 1476 | #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT message */ |
1443 | } | 1477 | } |
1478 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1479 | "Completed iteration after %llu/%llu results\n", | ||
1480 | (unsigned long long) (limit - proc.limit), | ||
1481 | (unsigned long long) limit); | ||
1444 | /* send empty response to indicate end of list */ | 1482 | /* send empty response to indicate end of list */ |
1445 | env = GNUNET_MQ_msg (rrm, | 1483 | env = GNUNET_MQ_msg (rrm, |
1446 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT); | 1484 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT); |
@@ -1587,6 +1625,7 @@ monitor_next (void *cls); | |||
1587 | * A #GNUNET_NAMESTORE_RecordIterator for monitors. | 1625 | * A #GNUNET_NAMESTORE_RecordIterator for monitors. |
1588 | * | 1626 | * |
1589 | * @param cls a 'struct ZoneMonitor *' with information about the monitor | 1627 | * @param cls a 'struct ZoneMonitor *' with information about the monitor |
1628 | * @param seq sequence number of the record | ||
1590 | * @param zone_key zone key of the zone | 1629 | * @param zone_key zone key of the zone |
1591 | * @param name name | 1630 | * @param name name |
1592 | * @param rd_count number of records in @a rd | 1631 | * @param rd_count number of records in @a rd |
@@ -1594,6 +1633,7 @@ monitor_next (void *cls); | |||
1594 | */ | 1633 | */ |
1595 | static void | 1634 | static void |
1596 | monitor_iterate_cb (void *cls, | 1635 | monitor_iterate_cb (void *cls, |
1636 | uint64_t seq, | ||
1597 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, | 1637 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, |
1598 | const char *name, | 1638 | const char *name, |
1599 | unsigned int rd_count, | 1639 | unsigned int rd_count, |
@@ -1601,6 +1641,7 @@ monitor_iterate_cb (void *cls, | |||
1601 | { | 1641 | { |
1602 | struct ZoneMonitor *zm = cls; | 1642 | struct ZoneMonitor *zm = cls; |
1603 | 1643 | ||
1644 | zm->seq = seq; | ||
1604 | if (NULL == name) | 1645 | if (NULL == name) |
1605 | { | 1646 | { |
1606 | /* finished with iteration */ | 1647 | /* finished with iteration */ |
@@ -1673,7 +1714,7 @@ monitor_next (void *cls) | |||
1673 | sizeof (zero))) | 1714 | sizeof (zero))) |
1674 | ? NULL | 1715 | ? NULL |
1675 | : &zm->zone, | 1716 | : &zm->zone, |
1676 | zm->offset++, | 1717 | zm->seq, |
1677 | 1, | 1718 | 1, |
1678 | &monitor_iterate_cb, | 1719 | &monitor_iterate_cb, |
1679 | zm); | 1720 | zm); |
@@ -1717,7 +1758,7 @@ run (void *cls, | |||
1717 | "DISABLE"); | 1758 | "DISABLE"); |
1718 | GSN_cfg = cfg; | 1759 | GSN_cfg = cfg; |
1719 | monitor_nc = GNUNET_notification_context_create (1); | 1760 | monitor_nc = GNUNET_notification_context_create (1); |
1720 | if (GNUNET_NO == disable_namecache) | 1761 | if (GNUNET_YES != disable_namecache) |
1721 | { | 1762 | { |
1722 | namecache = GNUNET_NAMECACHE_connect (cfg); | 1763 | namecache = GNUNET_NAMECACHE_connect (cfg); |
1723 | GNUNET_assert (NULL != namecache); | 1764 | GNUNET_assert (NULL != namecache); |
diff --git a/src/namestore/namestore.h b/src/namestore/namestore.h index b398af8a9..207b35662 100644 --- a/src/namestore/namestore.h +++ b/src/namestore/namestore.h | |||
@@ -161,7 +161,7 @@ struct LabelLookupResponseMessage | |||
161 | * Length of serialized record data | 161 | * Length of serialized record data |
162 | */ | 162 | */ |
163 | uint16_t rd_len GNUNET_PACKED; | 163 | uint16_t rd_len GNUNET_PACKED; |
164 | 164 | ||
165 | /** | 165 | /** |
166 | * Number of records contained | 166 | * Number of records contained |
167 | */ | 167 | */ |
@@ -169,7 +169,7 @@ struct LabelLookupResponseMessage | |||
169 | 169 | ||
170 | /** | 170 | /** |
171 | * Was the label found in the database?? | 171 | * Was the label found in the database?? |
172 | * GNUNET_YES or GNUNET_NO | 172 | * #GNUNET_YES or #GNUNET_NO |
173 | */ | 173 | */ |
174 | uint16_t found GNUNET_PACKED; | 174 | uint16_t found GNUNET_PACKED; |
175 | 175 | ||
diff --git a/src/namestore/plugin_namestore_flat.c b/src/namestore/plugin_namestore_flat.c index f061ab7d1..f40154915 100644 --- a/src/namestore/plugin_namestore_flat.c +++ b/src/namestore/plugin_namestore_flat.c | |||
@@ -523,6 +523,7 @@ namestore_flat_lookup_records (void *cls, | |||
523 | return GNUNET_NO; | 523 | return GNUNET_NO; |
524 | if (NULL != iter) | 524 | if (NULL != iter) |
525 | iter (iter_cls, | 525 | iter (iter_cls, |
526 | 0, | ||
526 | entry->private_key, | 527 | entry->private_key, |
527 | entry->label, | 528 | entry->label, |
528 | entry->record_count, | 529 | entry->record_count, |
@@ -547,6 +548,12 @@ struct IterateContext | |||
547 | uint64_t limit; | 548 | uint64_t limit; |
548 | 549 | ||
549 | /** | 550 | /** |
551 | * What is the position of the current entry, counting | ||
552 | * starts from 1. | ||
553 | */ | ||
554 | uint64_t pos; | ||
555 | |||
556 | /** | ||
550 | * Target zone. | 557 | * Target zone. |
551 | */ | 558 | */ |
552 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone; | 559 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone; |
@@ -581,6 +588,7 @@ iterate_zones (void *cls, | |||
581 | struct FlatFileEntry *entry = value; | 588 | struct FlatFileEntry *entry = value; |
582 | 589 | ||
583 | (void) key; | 590 | (void) key; |
591 | ic->pos++; | ||
584 | if (0 == ic->limit) | 592 | if (0 == ic->limit) |
585 | return GNUNET_NO; | 593 | return GNUNET_NO; |
586 | if ( (NULL != ic->zone) && | 594 | if ( (NULL != ic->zone) && |
@@ -594,6 +602,7 @@ iterate_zones (void *cls, | |||
594 | return GNUNET_YES; | 602 | return GNUNET_YES; |
595 | } | 603 | } |
596 | ic->iter (ic->iter_cls, | 604 | ic->iter (ic->iter_cls, |
605 | ic->pos, | ||
597 | entry->private_key, | 606 | entry->private_key, |
598 | entry->label, | 607 | entry->label, |
599 | entry->record_count, | 608 | entry->record_count, |
@@ -611,7 +620,7 @@ iterate_zones (void *cls, | |||
611 | * | 620 | * |
612 | * @param cls closure (internal context for the plugin) | 621 | * @param cls closure (internal context for the plugin) |
613 | * @param zone hash of public key of the zone, NULL to iterate over all zones | 622 | * @param zone hash of public key of the zone, NULL to iterate over all zones |
614 | * @param offset offset in the list of all matching records | 623 | * @param serial serial number to exclude in the list of all matching records |
615 | * @param limit maximum number of results to return to @a iter | 624 | * @param limit maximum number of results to return to @a iter |
616 | * @param iter function to call with the result | 625 | * @param iter function to call with the result |
617 | * @param iter_cls closure for @a iter | 626 | * @param iter_cls closure for @a iter |
@@ -620,7 +629,7 @@ iterate_zones (void *cls, | |||
620 | static int | 629 | static int |
621 | namestore_flat_iterate_records (void *cls, | 630 | namestore_flat_iterate_records (void *cls, |
622 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 631 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
623 | uint64_t offset, | 632 | uint64_t serial, |
624 | uint64_t limit, | 633 | uint64_t limit, |
625 | GNUNET_NAMESTORE_RecordIterator iter, | 634 | GNUNET_NAMESTORE_RecordIterator iter, |
626 | void *iter_cls) | 635 | void *iter_cls) |
@@ -628,7 +637,8 @@ namestore_flat_iterate_records (void *cls, | |||
628 | struct Plugin *plugin = cls; | 637 | struct Plugin *plugin = cls; |
629 | struct IterateContext ic; | 638 | struct IterateContext ic; |
630 | 639 | ||
631 | ic.offset = offset; | 640 | ic.offset = serial; |
641 | ic.pos = 0; | ||
632 | ic.limit = limit; | 642 | ic.limit = limit; |
633 | ic.iter = iter; | 643 | ic.iter = iter; |
634 | ic.iter_cls = iter_cls; | 644 | ic.iter_cls = iter_cls; |
@@ -663,6 +673,7 @@ zone_to_name (void *cls, | |||
663 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) | 673 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) |
664 | { | 674 | { |
665 | plugin->iter (plugin->iter_cls, | 675 | plugin->iter (plugin->iter_cls, |
676 | 0, | ||
666 | entry->private_key, | 677 | entry->private_key, |
667 | entry->label, | 678 | entry->label, |
668 | entry->record_count, | 679 | entry->record_count, |
diff --git a/src/namestore/plugin_namestore_postgres.c b/src/namestore/plugin_namestore_postgres.c index 4a24ddf88..69e28b0d0 100644 --- a/src/namestore/plugin_namestore_postgres.c +++ b/src/namestore/plugin_namestore_postgres.c | |||
@@ -65,7 +65,8 @@ static int | |||
65 | database_setup (struct Plugin *plugin) | 65 | database_setup (struct Plugin *plugin) |
66 | { | 66 | { |
67 | struct GNUNET_PQ_ExecuteStatement es_temporary = | 67 | struct GNUNET_PQ_ExecuteStatement es_temporary = |
68 | GNUNET_PQ_make_execute ("CREATE TEMPORARY TABLE IF NOT EXISTS ns097records (" | 68 | GNUNET_PQ_make_execute ("CREATE TEMPORARY TABLE IF NOT EXISTS ns098records (" |
69 | " seq BIGSERIAL PRIMARY KEY," | ||
69 | " zone_private_key BYTEA NOT NULL DEFAULT ''," | 70 | " zone_private_key BYTEA NOT NULL DEFAULT ''," |
70 | " pkey BYTEA DEFAULT ''," | 71 | " pkey BYTEA DEFAULT ''," |
71 | " rvalue BYTEA NOT NULL DEFAULT ''," | 72 | " rvalue BYTEA NOT NULL DEFAULT ''," |
@@ -75,7 +76,8 @@ database_setup (struct Plugin *plugin) | |||
75 | ")" | 76 | ")" |
76 | "WITH OIDS"); | 77 | "WITH OIDS"); |
77 | struct GNUNET_PQ_ExecuteStatement es_default = | 78 | struct GNUNET_PQ_ExecuteStatement es_default = |
78 | GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS ns097records (" | 79 | GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS ns098records (" |
80 | " seq BIGSERIAL PRIMARY KEY," | ||
79 | " zone_private_key BYTEA NOT NULL DEFAULT ''," | 81 | " zone_private_key BYTEA NOT NULL DEFAULT ''," |
80 | " pkey BYTEA DEFAULT ''," | 82 | " pkey BYTEA DEFAULT ''," |
81 | " rvalue BYTEA NOT NULL DEFAULT ''," | 83 | " rvalue BYTEA NOT NULL DEFAULT ''," |
@@ -125,13 +127,11 @@ database_setup (struct Plugin *plugin) | |||
125 | struct GNUNET_PQ_ExecuteStatement es[] = { | 127 | struct GNUNET_PQ_ExecuteStatement es[] = { |
126 | *cr, | 128 | *cr, |
127 | GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_pkey_reverse " | 129 | GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_pkey_reverse " |
128 | "ON ns097records (zone_private_key,pkey)"), | 130 | "ON ns098records (zone_private_key,pkey)"), |
129 | GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_pkey_iter " | 131 | GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_pkey_iter " |
130 | "ON ns097records (zone_private_key,rvalue)"), | 132 | "ON ns098records (zone_private_key,seq)"), |
131 | GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS it_iter " | ||
132 | "ON ns097records (rvalue)"), | ||
133 | GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_label " | 133 | GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_label " |
134 | "ON ns097records (label)"), | 134 | "ON ns098records (label)"), |
135 | GNUNET_PQ_EXECUTE_STATEMENT_END | 135 | GNUNET_PQ_EXECUTE_STATEMENT_END |
136 | }; | 136 | }; |
137 | 137 | ||
@@ -148,28 +148,28 @@ database_setup (struct Plugin *plugin) | |||
148 | { | 148 | { |
149 | struct GNUNET_PQ_PreparedStatement ps[] = { | 149 | struct GNUNET_PQ_PreparedStatement ps[] = { |
150 | GNUNET_PQ_make_prepare ("store_records", | 150 | GNUNET_PQ_make_prepare ("store_records", |
151 | "INSERT INTO ns097records (zone_private_key, pkey, rvalue, record_count, record_data, label) VALUES " | 151 | "INSERT INTO ns098records (zone_private_key, pkey, rvalue, record_count, record_data, label) VALUES " |
152 | "($1, $2, $3, $4, $5, $6)", | 152 | "($1, $2, $3, $4, $5, $6)", |
153 | 6), | 153 | 6), |
154 | GNUNET_PQ_make_prepare ("delete_records", | 154 | GNUNET_PQ_make_prepare ("delete_records", |
155 | "DELETE FROM ns097records " | 155 | "DELETE FROM ns098records " |
156 | "WHERE zone_private_key=$1 AND label=$2", | 156 | "WHERE zone_private_key=$1 AND label=$2", |
157 | 2), | 157 | 2), |
158 | GNUNET_PQ_make_prepare ("zone_to_name", | 158 | GNUNET_PQ_make_prepare ("zone_to_name", |
159 | "SELECT record_count,record_data,label FROM ns097records" | 159 | "SELECT seq,record_count,record_data,label FROM ns098records" |
160 | " WHERE zone_private_key=$1 AND pkey=$2", | 160 | " WHERE zone_private_key=$1 AND pkey=$2", |
161 | 2), | 161 | 2), |
162 | GNUNET_PQ_make_prepare ("iterate_zone", | 162 | GNUNET_PQ_make_prepare ("iterate_zone", |
163 | "SELECT record_count,record_data,label FROM ns097records " | 163 | "SELECT seq,record_count,record_data,label FROM ns098records " |
164 | "WHERE zone_private_key=$1 ORDER BY rvalue OFFSET $2 LIMIT $3", | 164 | "WHERE zone_private_key=$1 AND seq > $2 ORDER BY seq ASC LIMIT $3", |
165 | 3), | 165 | 3), |
166 | GNUNET_PQ_make_prepare ("iterate_all_zones", | 166 | GNUNET_PQ_make_prepare ("iterate_all_zones", |
167 | "SELECT record_count,record_data,label,zone_private_key" | 167 | "SELECT seq,record_count,record_data,label,zone_private_key" |
168 | " FROM ns097records ORDER BY rvalue OFFSET $1 LIMIT $2", | 168 | " FROM ns098records WHERE seq > $1 ORDER BY seq ASC LIMIT $2", |
169 | 2), | 169 | 2), |
170 | GNUNET_PQ_make_prepare ("lookup_label", | 170 | GNUNET_PQ_make_prepare ("lookup_label", |
171 | "SELECT record_count,record_data,label " | 171 | "SELECT seq,record_count,record_data,label " |
172 | "FROM ns097records WHERE zone_private_key=$1 AND label=$2", | 172 | "FROM ns098records WHERE zone_private_key=$1 AND label=$2", |
173 | 2), | 173 | 2), |
174 | GNUNET_PQ_PREPARED_STATEMENT_END | 174 | GNUNET_PQ_PREPARED_STATEMENT_END |
175 | }; | 175 | }; |
@@ -224,7 +224,8 @@ namestore_postgres_store_records (void *cls, | |||
224 | } | 224 | } |
225 | rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, | 225 | rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, |
226 | UINT64_MAX); | 226 | UINT64_MAX); |
227 | data_size = GNUNET_GNSRECORD_records_get_size (rd_count, rd); | 227 | data_size = GNUNET_GNSRECORD_records_get_size (rd_count, |
228 | rd); | ||
228 | if (data_size > 64 * 65536) | 229 | if (data_size > 64 * 65536) |
229 | { | 230 | { |
230 | GNUNET_break (0); | 231 | GNUNET_break (0); |
@@ -312,12 +313,14 @@ parse_result_call_iterator (void *cls, | |||
312 | return; /* no need to do more work */ | 313 | return; /* no need to do more work */ |
313 | for (unsigned int i=0;i<num_results;i++) | 314 | for (unsigned int i=0;i<num_results;i++) |
314 | { | 315 | { |
316 | uint64_t serial; | ||
315 | void *data; | 317 | void *data; |
316 | size_t data_size; | 318 | size_t data_size; |
317 | uint32_t record_count; | 319 | uint32_t record_count; |
318 | char *label; | 320 | char *label; |
319 | struct GNUNET_CRYPTO_EcdsaPrivateKey zk; | 321 | struct GNUNET_CRYPTO_EcdsaPrivateKey zk; |
320 | struct GNUNET_PQ_ResultSpec rs_with_zone[] = { | 322 | struct GNUNET_PQ_ResultSpec rs_with_zone[] = { |
323 | GNUNET_PQ_result_spec_uint64 ("seq", &serial), | ||
321 | GNUNET_PQ_result_spec_uint32 ("record_count", &record_count), | 324 | GNUNET_PQ_result_spec_uint32 ("record_count", &record_count), |
322 | GNUNET_PQ_result_spec_variable_size ("record_data", &data, &data_size), | 325 | GNUNET_PQ_result_spec_variable_size ("record_data", &data, &data_size), |
323 | GNUNET_PQ_result_spec_string ("label", &label), | 326 | GNUNET_PQ_result_spec_string ("label", &label), |
@@ -325,6 +328,7 @@ parse_result_call_iterator (void *cls, | |||
325 | GNUNET_PQ_result_spec_end | 328 | GNUNET_PQ_result_spec_end |
326 | }; | 329 | }; |
327 | struct GNUNET_PQ_ResultSpec rs_without_zone[] = { | 330 | struct GNUNET_PQ_ResultSpec rs_without_zone[] = { |
331 | GNUNET_PQ_result_spec_uint64 ("seq", &serial), | ||
328 | GNUNET_PQ_result_spec_uint32 ("record_count", &record_count), | 332 | GNUNET_PQ_result_spec_uint32 ("record_count", &record_count), |
329 | GNUNET_PQ_result_spec_variable_size ("record_data", &data, &data_size), | 333 | GNUNET_PQ_result_spec_variable_size ("record_data", &data, &data_size), |
330 | GNUNET_PQ_result_spec_string ("label", &label), | 334 | GNUNET_PQ_result_spec_string ("label", &label), |
@@ -365,6 +369,7 @@ parse_result_call_iterator (void *cls, | |||
365 | return; | 369 | return; |
366 | } | 370 | } |
367 | pc->iter (pc->iter_cls, | 371 | pc->iter (pc->iter_cls, |
372 | serial, | ||
368 | (NULL == pc->zone_key) ? &zk : pc->zone_key, | 373 | (NULL == pc->zone_key) ? &zk : pc->zone_key, |
369 | label, | 374 | label, |
370 | record_count, | 375 | record_count, |
@@ -422,7 +427,7 @@ namestore_postgres_lookup_records (void *cls, | |||
422 | * | 427 | * |
423 | * @param cls closure (internal context for the plugin) | 428 | * @param cls closure (internal context for the plugin) |
424 | * @param zone hash of public key of the zone, NULL to iterate over all zones | 429 | * @param zone hash of public key of the zone, NULL to iterate over all zones |
425 | * @param offset offset in the list of all matching records | 430 | * @param serial serial number to exclude in the list of all matching records |
426 | * @param limit maximum number of results to fetch | 431 | * @param limit maximum number of results to fetch |
427 | * @param iter function to call with the result | 432 | * @param iter function to call with the result |
428 | * @param iter_cls closure for @a iter | 433 | * @param iter_cls closure for @a iter |
@@ -431,7 +436,7 @@ namestore_postgres_lookup_records (void *cls, | |||
431 | static int | 436 | static int |
432 | namestore_postgres_iterate_records (void *cls, | 437 | namestore_postgres_iterate_records (void *cls, |
433 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 438 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
434 | uint64_t offset, | 439 | uint64_t serial, |
435 | uint64_t limit, | 440 | uint64_t limit, |
436 | GNUNET_NAMESTORE_RecordIterator iter, | 441 | GNUNET_NAMESTORE_RecordIterator iter, |
437 | void *iter_cls) | 442 | void *iter_cls) |
@@ -447,7 +452,7 @@ namestore_postgres_iterate_records (void *cls, | |||
447 | if (NULL == zone) | 452 | if (NULL == zone) |
448 | { | 453 | { |
449 | struct GNUNET_PQ_QueryParam params_without_zone[] = { | 454 | struct GNUNET_PQ_QueryParam params_without_zone[] = { |
450 | GNUNET_PQ_query_param_uint64 (&offset), | 455 | GNUNET_PQ_query_param_uint64 (&serial), |
451 | GNUNET_PQ_query_param_uint64 (&limit), | 456 | GNUNET_PQ_query_param_uint64 (&limit), |
452 | GNUNET_PQ_query_param_end | 457 | GNUNET_PQ_query_param_end |
453 | }; | 458 | }; |
@@ -462,7 +467,7 @@ namestore_postgres_iterate_records (void *cls, | |||
462 | { | 467 | { |
463 | struct GNUNET_PQ_QueryParam params_with_zone[] = { | 468 | struct GNUNET_PQ_QueryParam params_with_zone[] = { |
464 | GNUNET_PQ_query_param_auto_from_type (zone), | 469 | GNUNET_PQ_query_param_auto_from_type (zone), |
465 | GNUNET_PQ_query_param_uint64 (&offset), | 470 | GNUNET_PQ_query_param_uint64 (&serial), |
466 | GNUNET_PQ_query_param_uint64 (&limit), | 471 | GNUNET_PQ_query_param_uint64 (&limit), |
467 | GNUNET_PQ_query_param_end | 472 | GNUNET_PQ_query_param_end |
468 | }; | 473 | }; |
diff --git a/src/namestore/plugin_namestore_sqlite.c b/src/namestore/plugin_namestore_sqlite.c index f905787b5..b54b4dba2 100644 --- a/src/namestore/plugin_namestore_sqlite.c +++ b/src/namestore/plugin_namestore_sqlite.c | |||
@@ -147,15 +147,13 @@ create_indices (sqlite3 * dbh) | |||
147 | /* create indices */ | 147 | /* create indices */ |
148 | if ( (SQLITE_OK != | 148 | if ( (SQLITE_OK != |
149 | sqlite3_exec (dbh, | 149 | sqlite3_exec (dbh, |
150 | "CREATE INDEX IF NOT EXISTS ir_pkey_reverse ON ns097records (zone_private_key,pkey)", | 150 | "CREATE INDEX IF NOT EXISTS ir_pkey_reverse " |
151 | "ON ns098records (zone_private_key,pkey)", | ||
151 | NULL, NULL, NULL)) || | 152 | NULL, NULL, NULL)) || |
152 | (SQLITE_OK != | 153 | (SQLITE_OK != |
153 | sqlite3_exec (dbh, | 154 | sqlite3_exec (dbh, |
154 | "CREATE INDEX IF NOT EXISTS ir_pkey_iter ON ns097records (zone_private_key,rvalue)", | 155 | "CREATE INDEX IF NOT EXISTS ir_pkey_iter " |
155 | NULL, NULL, NULL)) || | 156 | "ON ns098records (zone_private_key,uid)", |
156 | (SQLITE_OK != | ||
157 | sqlite3_exec (dbh, | ||
158 | "CREATE INDEX IF NOT EXISTS it_iter ON ns097records (rvalue)", | ||
159 | NULL, NULL, NULL)) ) | 157 | NULL, NULL, NULL)) ) |
160 | LOG (GNUNET_ERROR_TYPE_ERROR, | 158 | LOG (GNUNET_ERROR_TYPE_ERROR, |
161 | "Failed to create indices: %s\n", | 159 | "Failed to create indices: %s\n", |
@@ -260,22 +258,24 @@ database_setup (struct Plugin *plugin) | |||
260 | /* Create table */ | 258 | /* Create table */ |
261 | CHECK (SQLITE_OK == | 259 | CHECK (SQLITE_OK == |
262 | sq_prepare (plugin->dbh, | 260 | sq_prepare (plugin->dbh, |
263 | "SELECT 1 FROM sqlite_master WHERE tbl_name = 'ns097records'", | 261 | "SELECT 1 FROM sqlite_master WHERE tbl_name = 'ns098records'", |
264 | &stmt)); | 262 | &stmt)); |
265 | if ((sqlite3_step (stmt) == SQLITE_DONE) && | 263 | if ( (sqlite3_step (stmt) == SQLITE_DONE) && |
266 | (sqlite3_exec | 264 | (SQLITE_OK != |
267 | (plugin->dbh, | 265 | sqlite3_exec (plugin->dbh, |
268 | "CREATE TABLE ns097records (" | 266 | "CREATE TABLE ns098records (" |
269 | " zone_private_key BLOB NOT NULL," | 267 | " uid INTEGER PRIMARY KEY," |
270 | " pkey BLOB," | 268 | " zone_private_key BLOB NOT NULL," |
271 | " rvalue INT8 NOT NULL," | 269 | " pkey BLOB," |
272 | " record_count INT NOT NULL," | 270 | " rvalue INT8 NOT NULL," |
273 | " record_data BLOB NOT NULL," | 271 | " record_count INT NOT NULL," |
274 | " label TEXT NOT NULL" | 272 | " record_data BLOB NOT NULL," |
275 | ")", | 273 | " label TEXT NOT NULL" |
276 | NULL, NULL, NULL) != SQLITE_OK)) | 274 | ")", |
275 | NULL, NULL, NULL)) ) | ||
277 | { | 276 | { |
278 | LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, | 277 | LOG_SQLITE (plugin, |
278 | GNUNET_ERROR_TYPE_ERROR, | ||
279 | "sqlite3_exec"); | 279 | "sqlite3_exec"); |
280 | sqlite3_finalize (stmt); | 280 | sqlite3_finalize (stmt); |
281 | return GNUNET_SYSERR; | 281 | return GNUNET_SYSERR; |
@@ -286,33 +286,40 @@ database_setup (struct Plugin *plugin) | |||
286 | 286 | ||
287 | if ( (SQLITE_OK != | 287 | if ( (SQLITE_OK != |
288 | sq_prepare (plugin->dbh, | 288 | sq_prepare (plugin->dbh, |
289 | "INSERT INTO ns097records (zone_private_key, pkey, rvalue, record_count, record_data, label)" | 289 | "INSERT INTO ns098records (zone_private_key, pkey, rvalue, record_count, record_data, label)" |
290 | " VALUES (?, ?, ?, ?, ?, ?)", | 290 | " VALUES (?, ?, ?, ?, ?, ?)", |
291 | &plugin->store_records)) || | 291 | &plugin->store_records)) || |
292 | (SQLITE_OK != | 292 | (SQLITE_OK != |
293 | sq_prepare (plugin->dbh, | 293 | sq_prepare (plugin->dbh, |
294 | "DELETE FROM ns097records WHERE zone_private_key=? AND label=?", | 294 | "DELETE FROM ns098records WHERE zone_private_key=? AND label=?", |
295 | &plugin->delete_records)) || | 295 | &plugin->delete_records)) || |
296 | (SQLITE_OK != | 296 | (SQLITE_OK != |
297 | sq_prepare (plugin->dbh, | 297 | sq_prepare (plugin->dbh, |
298 | "SELECT record_count,record_data,label" | 298 | "SELECT uid,record_count,record_data,label" |
299 | " FROM ns097records WHERE zone_private_key=? AND pkey=?", | 299 | " FROM ns098records" |
300 | " WHERE zone_private_key=? AND pkey=?", | ||
300 | &plugin->zone_to_name)) || | 301 | &plugin->zone_to_name)) || |
301 | (SQLITE_OK != | 302 | (SQLITE_OK != |
302 | sq_prepare (plugin->dbh, | 303 | sq_prepare (plugin->dbh, |
303 | "SELECT record_count,record_data,label" | 304 | "SELECT uid,record_count,record_data,label" |
304 | " FROM ns097records WHERE zone_private_key=?" | 305 | " FROM ns098records" |
305 | " ORDER BY rvalue LIMIT ? OFFSET ?", | 306 | " WHERE zone_private_key=? AND _rowid_ >= ?" |
307 | " ORDER BY _rowid_ ASC" | ||
308 | " LIMIT ?", | ||
306 | &plugin->iterate_zone)) || | 309 | &plugin->iterate_zone)) || |
307 | (SQLITE_OK != | 310 | (SQLITE_OK != |
308 | sq_prepare (plugin->dbh, | 311 | sq_prepare (plugin->dbh, |
309 | "SELECT record_count,record_data,label,zone_private_key" | 312 | "SELECT uid,record_count,record_data,label,zone_private_key" |
310 | " FROM ns097records ORDER BY rvalue LIMIT ? OFFSET ?", | 313 | " FROM ns098records" |
314 | " WHERE _rowid_ >= ?" | ||
315 | " ORDER BY _rowid_ ASC" | ||
316 | " LIMIT ?", | ||
311 | &plugin->iterate_all_zones)) || | 317 | &plugin->iterate_all_zones)) || |
312 | (SQLITE_OK != | 318 | (SQLITE_OK != |
313 | sq_prepare (plugin->dbh, | 319 | sq_prepare (plugin->dbh, |
314 | "SELECT record_count,record_data,label,zone_private_key" | 320 | "SELECT uid,record_count,record_data,label,zone_private_key" |
315 | " FROM ns097records WHERE zone_private_key=? AND label=?", | 321 | " FROM ns098records" |
322 | " WHERE zone_private_key=? AND label=?", | ||
316 | &plugin->lookup_label)) | 323 | &plugin->lookup_label)) |
317 | ) | 324 | ) |
318 | { | 325 | { |
@@ -405,10 +412,11 @@ namestore_sqlite_store_records (void *cls, | |||
405 | struct GNUNET_CRYPTO_EcdsaPublicKey pkey; | 412 | struct GNUNET_CRYPTO_EcdsaPublicKey pkey; |
406 | uint64_t rvalue; | 413 | uint64_t rvalue; |
407 | size_t data_size; | 414 | size_t data_size; |
408 | unsigned int i; | ||
409 | 415 | ||
410 | memset (&pkey, 0, sizeof (pkey)); | 416 | memset (&pkey, |
411 | for (i=0;i<rd_count;i++) | 417 | 0, |
418 | sizeof (pkey)); | ||
419 | for (unsigned int i=0;i<rd_count;i++) | ||
412 | if (GNUNET_GNSRECORD_TYPE_PKEY == rd[i].record_type) | 420 | if (GNUNET_GNSRECORD_TYPE_PKEY == rd[i].record_type) |
413 | { | 421 | { |
414 | GNUNET_break (sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) == | 422 | GNUNET_break (sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) == |
@@ -539,28 +547,50 @@ get_records_and_call_iterator (struct Plugin *plugin, | |||
539 | GNUNET_NAMESTORE_RecordIterator iter, | 547 | GNUNET_NAMESTORE_RecordIterator iter, |
540 | void *iter_cls) | 548 | void *iter_cls) |
541 | { | 549 | { |
542 | uint32_t record_count; | ||
543 | size_t data_size; | ||
544 | void *data; | ||
545 | char *label; | ||
546 | struct GNUNET_CRYPTO_EcdsaPrivateKey zk; | ||
547 | int ret; | 550 | int ret; |
548 | int sret; | 551 | int sret; |
549 | 552 | ||
550 | ret = GNUNET_OK; | 553 | ret = GNUNET_OK; |
551 | for (uint64_t i = 0;i<limit ; i++) | 554 | for (uint64_t i = 0;i<limit ; i++) |
552 | { | 555 | { |
553 | if (SQLITE_ROW == (sret = sqlite3_step (stmt))) | 556 | sret = sqlite3_step (stmt); |
557 | |||
558 | if (SQLITE_DONE == sret) | ||
559 | { | ||
560 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
561 | "Iteration done (no results)\n"); | ||
562 | ret = GNUNET_NO; | ||
563 | break; | ||
564 | } | ||
565 | if (SQLITE_ROW != sret) | ||
554 | { | 566 | { |
567 | LOG_SQLITE (plugin, | ||
568 | GNUNET_ERROR_TYPE_ERROR, | ||
569 | "sqlite_step"); | ||
570 | ret = GNUNET_SYSERR; | ||
571 | break; | ||
572 | } | ||
573 | |||
574 | { | ||
575 | uint64_t seq; | ||
576 | uint32_t record_count; | ||
577 | size_t data_size; | ||
578 | void *data; | ||
579 | char *label; | ||
580 | struct GNUNET_CRYPTO_EcdsaPrivateKey zk; | ||
555 | struct GNUNET_SQ_ResultSpec rs[] = { | 581 | struct GNUNET_SQ_ResultSpec rs[] = { |
582 | GNUNET_SQ_result_spec_uint64 (&seq), | ||
556 | GNUNET_SQ_result_spec_uint32 (&record_count), | 583 | GNUNET_SQ_result_spec_uint32 (&record_count), |
557 | GNUNET_SQ_result_spec_variable_size (&data, &data_size), | 584 | GNUNET_SQ_result_spec_variable_size (&data, |
585 | &data_size), | ||
558 | GNUNET_SQ_result_spec_string (&label), | 586 | GNUNET_SQ_result_spec_string (&label), |
559 | GNUNET_SQ_result_spec_end | 587 | GNUNET_SQ_result_spec_end |
560 | }; | 588 | }; |
561 | struct GNUNET_SQ_ResultSpec rsx[] = { | 589 | struct GNUNET_SQ_ResultSpec rsx[] = { |
590 | GNUNET_SQ_result_spec_uint64 (&seq), | ||
562 | GNUNET_SQ_result_spec_uint32 (&record_count), | 591 | GNUNET_SQ_result_spec_uint32 (&record_count), |
563 | GNUNET_SQ_result_spec_variable_size (&data, &data_size), | 592 | GNUNET_SQ_result_spec_variable_size (&data, |
593 | &data_size), | ||
564 | GNUNET_SQ_result_spec_string (&label), | 594 | GNUNET_SQ_result_spec_string (&label), |
565 | GNUNET_SQ_result_spec_auto_from_type (&zk), | 595 | GNUNET_SQ_result_spec_auto_from_type (&zk), |
566 | GNUNET_SQ_result_spec_end | 596 | GNUNET_SQ_result_spec_end |
@@ -604,6 +634,7 @@ get_records_and_call_iterator (struct Plugin *plugin, | |||
604 | { | 634 | { |
605 | if (NULL != iter) | 635 | if (NULL != iter) |
606 | iter (iter_cls, | 636 | iter (iter_cls, |
637 | seq + 1, | ||
607 | zone_key, | 638 | zone_key, |
608 | label, | 639 | label, |
609 | record_count, | 640 | record_count, |
@@ -612,21 +643,6 @@ get_records_and_call_iterator (struct Plugin *plugin, | |||
612 | } | 643 | } |
613 | GNUNET_SQ_cleanup_result (rs); | 644 | GNUNET_SQ_cleanup_result (rs); |
614 | } | 645 | } |
615 | else | ||
616 | { | ||
617 | if (SQLITE_DONE != sret) | ||
618 | { | ||
619 | LOG_SQLITE (plugin, | ||
620 | GNUNET_ERROR_TYPE_ERROR, | ||
621 | "sqlite_step"); | ||
622 | ret = GNUNET_SYSERR; | ||
623 | } | ||
624 | else | ||
625 | { | ||
626 | ret = GNUNET_NO; | ||
627 | } | ||
628 | break; | ||
629 | } | ||
630 | } | 646 | } |
631 | GNUNET_SQ_reset (plugin->dbh, | 647 | GNUNET_SQ_reset (plugin->dbh, |
632 | stmt); | 648 | stmt); |
@@ -685,7 +701,7 @@ namestore_sqlite_lookup_records (void *cls, | |||
685 | * | 701 | * |
686 | * @param cls closure (internal context for the plugin) | 702 | * @param cls closure (internal context for the plugin) |
687 | * @param zone hash of public key of the zone, NULL to iterate over all zones | 703 | * @param zone hash of public key of the zone, NULL to iterate over all zones |
688 | * @param offset offset in the list of all matching records | 704 | * @param serial serial number to exclude in the list of all matching records |
689 | * @param limit maximum number of results to return | 705 | * @param limit maximum number of results to return |
690 | * @param iter function to call with the result | 706 | * @param iter function to call with the result |
691 | * @param iter_cls closure for @a iter | 707 | * @param iter_cls closure for @a iter |
@@ -694,7 +710,7 @@ namestore_sqlite_lookup_records (void *cls, | |||
694 | static int | 710 | static int |
695 | namestore_sqlite_iterate_records (void *cls, | 711 | namestore_sqlite_iterate_records (void *cls, |
696 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 712 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
697 | uint64_t offset, | 713 | uint64_t serial, |
698 | uint64_t limit, | 714 | uint64_t limit, |
699 | GNUNET_NAMESTORE_RecordIterator iter, | 715 | GNUNET_NAMESTORE_RecordIterator iter, |
700 | void *iter_cls) | 716 | void *iter_cls) |
@@ -706,8 +722,8 @@ namestore_sqlite_iterate_records (void *cls, | |||
706 | if (NULL == zone) | 722 | if (NULL == zone) |
707 | { | 723 | { |
708 | struct GNUNET_SQ_QueryParam params[] = { | 724 | struct GNUNET_SQ_QueryParam params[] = { |
725 | GNUNET_SQ_query_param_uint64 (&serial), | ||
709 | GNUNET_SQ_query_param_uint64 (&limit), | 726 | GNUNET_SQ_query_param_uint64 (&limit), |
710 | GNUNET_SQ_query_param_uint64 (&offset), | ||
711 | GNUNET_SQ_query_param_end | 727 | GNUNET_SQ_query_param_end |
712 | }; | 728 | }; |
713 | 729 | ||
@@ -719,8 +735,8 @@ namestore_sqlite_iterate_records (void *cls, | |||
719 | { | 735 | { |
720 | struct GNUNET_SQ_QueryParam params[] = { | 736 | struct GNUNET_SQ_QueryParam params[] = { |
721 | GNUNET_SQ_query_param_auto_from_type (zone), | 737 | GNUNET_SQ_query_param_auto_from_type (zone), |
738 | GNUNET_SQ_query_param_uint64 (&serial), | ||
722 | GNUNET_SQ_query_param_uint64 (&limit), | 739 | GNUNET_SQ_query_param_uint64 (&limit), |
723 | GNUNET_SQ_query_param_uint64 (&offset), | ||
724 | GNUNET_SQ_query_param_end | 740 | GNUNET_SQ_query_param_end |
725 | }; | 741 | }; |
726 | 742 | ||
@@ -761,7 +777,8 @@ static int | |||
761 | namestore_sqlite_zone_to_name (void *cls, | 777 | namestore_sqlite_zone_to_name (void *cls, |
762 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 778 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
763 | const struct GNUNET_CRYPTO_EcdsaPublicKey *value_zone, | 779 | const struct GNUNET_CRYPTO_EcdsaPublicKey *value_zone, |
764 | GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls) | 780 | GNUNET_NAMESTORE_RecordIterator iter, |
781 | void *iter_cls) | ||
765 | { | 782 | { |
766 | struct Plugin *plugin = cls; | 783 | struct Plugin *plugin = cls; |
767 | struct GNUNET_SQ_QueryParam params[] = { | 784 | struct GNUNET_SQ_QueryParam params[] = { |
diff --git a/src/namestore/test_namestore_api_monitoring.c b/src/namestore/test_namestore_api_monitoring.c index efbd6badf..68a3e4fb8 100644 --- a/src/namestore/test_namestore_api_monitoring.c +++ b/src/namestore/test_namestore_api_monitoring.c | |||
@@ -209,7 +209,9 @@ zone_proc (void *cls, | |||
209 | 209 | ||
210 | 210 | ||
211 | static void | 211 | static void |
212 | put_cont (void *cls, int32_t success, const char *emsg) | 212 | put_cont (void *cls, |
213 | int32_t success, | ||
214 | const char *emsg) | ||
213 | { | 215 | { |
214 | static int c = 0; | 216 | static int c = 0; |
215 | char *label = cls; | 217 | char *label = cls; |
@@ -232,10 +234,12 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
232 | else | 234 | else |
233 | { | 235 | { |
234 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 236 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
235 | "Failed to created records\n"); | 237 | "Failed to create record `%s'\n", |
238 | label); | ||
236 | GNUNET_break (0); | 239 | GNUNET_break (0); |
237 | GNUNET_SCHEDULER_cancel (endbadly_task); | 240 | GNUNET_SCHEDULER_cancel (endbadly_task); |
238 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | 241 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, |
242 | NULL); | ||
239 | } | 243 | } |
240 | } | 244 | } |
241 | 245 | ||
@@ -341,10 +345,16 @@ run (void *cls, | |||
341 | /* name in different zone */ | 345 | /* name in different zone */ |
342 | GNUNET_asprintf(&s_name_3, "dummy3"); | 346 | GNUNET_asprintf(&s_name_3, "dummy3"); |
343 | s_rd_3 = create_record(1); | 347 | s_rd_3 = create_record(1); |
344 | GNUNET_assert (NULL != (ns_ops[2] = GNUNET_NAMESTORE_records_store (nsh, privkey2, s_name_3, | 348 | GNUNET_assert (NULL != (ns_ops[2] = |
345 | 1, s_rd_3, &put_cont, s_name_3))); | 349 | GNUNET_NAMESTORE_records_store (nsh, |
346 | 350 | privkey2, | |
347 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 1\n"); | 351 | s_name_3, |
352 | 1, | ||
353 | s_rd_3, | ||
354 | &put_cont, | ||
355 | s_name_3))); | ||
356 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
357 | "Created record 1\n"); | ||
348 | GNUNET_asprintf(&s_name_1, "dummy1"); | 358 | GNUNET_asprintf(&s_name_1, "dummy1"); |
349 | s_rd_1 = create_record(1); | 359 | s_rd_1 = create_record(1); |
350 | GNUNET_assert (NULL != (ns_ops[0] = GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_1, | 360 | GNUNET_assert (NULL != (ns_ops[0] = GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_1, |
diff --git a/src/namestore/test_plugin_namestore.c b/src/namestore/test_plugin_namestore.c index d591eb325..ac2a0bba9 100644 --- a/src/namestore/test_plugin_namestore.c +++ b/src/namestore/test_plugin_namestore.c | |||
@@ -90,6 +90,7 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
90 | 90 | ||
91 | static void | 91 | static void |
92 | test_record (void *cls, | 92 | test_record (void *cls, |
93 | uint64_t seq, | ||
93 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key, | 94 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key, |
94 | const char *label, | 95 | const char *label, |
95 | unsigned int rd_count, | 96 | unsigned int rd_count, |
@@ -112,7 +113,9 @@ test_record (void *cls, | |||
112 | GNUNET_assert (rd[i].record_type == 1 + (id % 13)); | 113 | GNUNET_assert (rd[i].record_type == 1 + (id % 13)); |
113 | GNUNET_assert (rd[i].flags == 0); | 114 | GNUNET_assert (rd[i].flags == 0); |
114 | } | 115 | } |
115 | memset (&tzone_private_key, (id % 241), sizeof (tzone_private_key)); | 116 | memset (&tzone_private_key, |
117 | (id % 241), | ||
118 | sizeof (tzone_private_key)); | ||
116 | GNUNET_assert (0 == strcmp (label, tname)); | 119 | GNUNET_assert (0 == strcmp (label, tname)); |
117 | GNUNET_assert (0 == memcmp (&tzone_private_key, | 120 | GNUNET_assert (0 == memcmp (&tzone_private_key, |
118 | private_key, | 121 | private_key, |
@@ -156,11 +159,12 @@ put_record (struct GNUNET_NAMESTORE_PluginFunctions *nsp, | |||
156 | } | 159 | } |
157 | memset (&zone_private_key, (id % 241), sizeof (zone_private_key)); | 160 | memset (&zone_private_key, (id % 241), sizeof (zone_private_key)); |
158 | memset (&signature, (id % 243), sizeof (signature)); | 161 | memset (&signature, (id % 243), sizeof (signature)); |
159 | GNUNET_assert (GNUNET_OK == nsp->store_records (nsp->cls, | 162 | GNUNET_assert (GNUNET_OK == |
160 | &zone_private_key, | 163 | nsp->store_records (nsp->cls, |
161 | label, | 164 | &zone_private_key, |
162 | rd_count, | 165 | label, |
163 | rd)); | 166 | rd_count, |
167 | rd)); | ||
164 | } | 168 | } |
165 | 169 | ||
166 | 170 | ||
diff --git a/src/util/mq.c b/src/util/mq.c index af700836c..dbcce704d 100644 --- a/src/util/mq.c +++ b/src/util/mq.c | |||
@@ -578,11 +578,9 @@ void | |||
578 | GNUNET_MQ_set_handlers_closure (struct GNUNET_MQ_Handle *mq, | 578 | GNUNET_MQ_set_handlers_closure (struct GNUNET_MQ_Handle *mq, |
579 | void *handlers_cls) | 579 | void *handlers_cls) |
580 | { | 580 | { |
581 | unsigned int i; | ||
582 | |||
583 | if (NULL == mq->handlers) | 581 | if (NULL == mq->handlers) |
584 | return; | 582 | return; |
585 | for (i=0;NULL != mq->handlers[i].cb; i++) | 583 | for (unsigned int i=0;NULL != mq->handlers[i].cb; i++) |
586 | mq->handlers[i].cls = handlers_cls; | 584 | mq->handlers[i].cls = handlers_cls; |
587 | } | 585 | } |
588 | 586 | ||
@@ -782,7 +780,9 @@ GNUNET_MQ_notify_sent (struct GNUNET_MQ_Envelope *ev, | |||
782 | GNUNET_SCHEDULER_TaskCallback cb, | 780 | GNUNET_SCHEDULER_TaskCallback cb, |
783 | void *cb_cls) | 781 | void *cb_cls) |
784 | { | 782 | { |
785 | GNUNET_assert (NULL == ev->sent_cb); | 783 | /* allow setting *OR* clearing callback */ |
784 | GNUNET_assert ( (NULL == ev->sent_cb) || | ||
785 | (NULL == cb) ); | ||
786 | ev->sent_cb = cb; | 786 | ev->sent_cb = cb; |
787 | ev->sent_cls = cb_cls; | 787 | ev->sent_cls = cb_cls; |
788 | } | 788 | } |
diff --git a/src/zonemaster/gnunet-service-zonemaster.c b/src/zonemaster/gnunet-service-zonemaster.c index 3516e8d0f..55e1a0eee 100644 --- a/src/zonemaster/gnunet-service-zonemaster.c +++ b/src/zonemaster/gnunet-service-zonemaster.c | |||
@@ -37,6 +37,12 @@ | |||
37 | 37 | ||
38 | 38 | ||
39 | /** | 39 | /** |
40 | * How often should we (re)publish each record before | ||
41 | * it expires? | ||
42 | */ | ||
43 | #define PUBLISH_OPS_PER_EXPIRATION 4 | ||
44 | |||
45 | /** | ||
40 | * How often do we measure the delta between desired zone | 46 | * How often do we measure the delta between desired zone |
41 | * iteration speed and actual speed, and tell statistics | 47 | * iteration speed and actual speed, and tell statistics |
42 | * service about it? | 48 | * service about it? |
@@ -44,24 +50,24 @@ | |||
44 | #define DELTA_INTERVAL 100 | 50 | #define DELTA_INTERVAL 100 |
45 | 51 | ||
46 | /** | 52 | /** |
47 | * How many records do we fetch | 53 | * How many records do we fetch in one shot from the namestore? |
48 | * in one shot from the namestore? | ||
49 | */ | 54 | */ |
50 | #define NS_BLOCK_SIZE 100 | 55 | #define NS_BLOCK_SIZE 1000 |
51 | 56 | ||
52 | /** | 57 | /** |
53 | * The initial interval in milliseconds between puts in | 58 | * How many pending DHT operations do we allow at most? |
54 | * a zone iteration | ||
55 | */ | 59 | */ |
56 | #define INITIAL_PUT_INTERVAL GNUNET_TIME_UNIT_MILLISECONDS | 60 | #define DHT_QUEUE_LIMIT 2000 |
57 | 61 | ||
58 | /** | 62 | /** |
59 | * The lower bound for the zone iteration interval | 63 | * The initial interval in milliseconds btween puts in |
64 | * a zone iteration | ||
60 | */ | 65 | */ |
61 | #define MINIMUM_ZONE_ITERATION_INTERVAL GNUNET_TIME_UNIT_SECONDS | 66 | #define INITIAL_PUT_INTERVAL GNUNET_TIME_UNIT_MILLISECONDS |
62 | 67 | ||
63 | /** | 68 | /** |
64 | * The upper bound for the zone iteration interval | 69 | * The upper bound for the zone iteration interval |
70 | * (per record). | ||
65 | */ | 71 | */ |
66 | #define MAXIMUM_ZONE_ITERATION_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) | 72 | #define MAXIMUM_ZONE_ITERATION_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) |
67 | 73 | ||
@@ -107,6 +113,11 @@ struct DhtPutActivity | |||
107 | * Handle for the DHT PUT operation. | 113 | * Handle for the DHT PUT operation. |
108 | */ | 114 | */ |
109 | struct GNUNET_DHT_PutHandle *ph; | 115 | struct GNUNET_DHT_PutHandle *ph; |
116 | |||
117 | /** | ||
118 | * When was this PUT initiated? | ||
119 | */ | ||
120 | struct GNUNET_TIME_Absolute start_date; | ||
110 | }; | 121 | }; |
111 | 122 | ||
112 | 123 | ||
@@ -161,6 +172,16 @@ static struct DhtPutActivity *it_head; | |||
161 | static struct DhtPutActivity *it_tail; | 172 | static struct DhtPutActivity *it_tail; |
162 | 173 | ||
163 | /** | 174 | /** |
175 | * Number of entries in the DHT queue #it_head. | ||
176 | */ | ||
177 | static unsigned int dht_queue_length; | ||
178 | |||
179 | /** | ||
180 | * Number of entries in the DHT queue #ma_head. | ||
181 | */ | ||
182 | static unsigned int ma_queue_length; | ||
183 | |||
184 | /** | ||
164 | * Useful for zone update for DHT put | 185 | * Useful for zone update for DHT put |
165 | */ | 186 | */ |
166 | static unsigned long long num_public_records; | 187 | static unsigned long long num_public_records; |
@@ -172,7 +193,7 @@ static unsigned long long last_num_public_records; | |||
172 | 193 | ||
173 | /** | 194 | /** |
174 | * Number of successful put operations performed in the current | 195 | * Number of successful put operations performed in the current |
175 | * measurement cycle (as measured in #check_zone_dht_next()). | 196 | * measurement cycle (as measured in #check_zone_namestore_next()). |
176 | */ | 197 | */ |
177 | static unsigned long long put_cnt; | 198 | static unsigned long long put_cnt; |
178 | 199 | ||
@@ -192,9 +213,10 @@ static struct GNUNET_TIME_Relative next_put_interval; | |||
192 | static struct GNUNET_TIME_Relative min_relative_record_time; | 213 | static struct GNUNET_TIME_Relative min_relative_record_time; |
193 | 214 | ||
194 | /** | 215 | /** |
195 | * Zone iteration PUT interval. | 216 | * Minimum relative expiration time of records seem during the last |
217 | * zone iteration. | ||
196 | */ | 218 | */ |
197 | static struct GNUNET_TIME_Relative put_interval; | 219 | static struct GNUNET_TIME_Relative last_min_relative_record_time; |
198 | 220 | ||
199 | /** | 221 | /** |
200 | * Default time window for zone iteration | 222 | * Default time window for zone iteration |
@@ -255,6 +277,7 @@ shutdown_task (void *cls) | |||
255 | { | 277 | { |
256 | struct DhtPutActivity *ma; | 278 | struct DhtPutActivity *ma; |
257 | 279 | ||
280 | (void) cls; | ||
258 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 281 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
259 | "Shutting down!\n"); | 282 | "Shutting down!\n"); |
260 | while (NULL != (ma = ma_head)) | 283 | while (NULL != (ma = ma_head)) |
@@ -265,6 +288,15 @@ shutdown_task (void *cls) | |||
265 | ma); | 288 | ma); |
266 | GNUNET_free (ma); | 289 | GNUNET_free (ma); |
267 | } | 290 | } |
291 | while (NULL != (ma = it_head)) | ||
292 | { | ||
293 | GNUNET_DHT_put_cancel (ma->ph); | ||
294 | GNUNET_CONTAINER_DLL_remove (it_head, | ||
295 | it_tail, | ||
296 | ma); | ||
297 | dht_queue_length--; | ||
298 | GNUNET_free (ma); | ||
299 | } | ||
268 | if (NULL != statistics) | 300 | if (NULL != statistics) |
269 | { | 301 | { |
270 | GNUNET_STATISTICS_destroy (statistics, | 302 | GNUNET_STATISTICS_destroy (statistics, |
@@ -307,11 +339,12 @@ shutdown_task (void *cls) | |||
307 | /** | 339 | /** |
308 | * Method called periodically that triggers iteration over authoritative records | 340 | * Method called periodically that triggers iteration over authoritative records |
309 | * | 341 | * |
310 | * @param cls closure | 342 | * @param cls NULL |
311 | */ | 343 | */ |
312 | static void | 344 | static void |
313 | publish_zone_dht_next (void *cls) | 345 | publish_zone_namestore_next (void *cls) |
314 | { | 346 | { |
347 | (void) cls; | ||
315 | zone_publish_task = NULL; | 348 | zone_publish_task = NULL; |
316 | GNUNET_assert (NULL != namestore_iter); | 349 | GNUNET_assert (NULL != namestore_iter); |
317 | GNUNET_assert (0 == ns_iteration_left); | 350 | GNUNET_assert (0 == ns_iteration_left); |
@@ -335,15 +368,13 @@ publish_zone_dht_start (void *cls); | |||
335 | * by a monitor is done. | 368 | * by a monitor is done. |
336 | * | 369 | * |
337 | * @param cls a `struct DhtPutActivity` | 370 | * @param cls a `struct DhtPutActivity` |
338 | * @param success #GNUNET_OK on success | ||
339 | */ | 371 | */ |
340 | static void | 372 | static void |
341 | dht_put_monitor_continuation (void *cls, | 373 | dht_put_monitor_continuation (void *cls) |
342 | int success) | ||
343 | { | 374 | { |
344 | struct DhtPutActivity *ma = cls; | 375 | struct DhtPutActivity *ma = cls; |
345 | 376 | ||
346 | num_public_records++; | 377 | ma_queue_length--; |
347 | GNUNET_CONTAINER_DLL_remove (ma_head, | 378 | GNUNET_CONTAINER_DLL_remove (ma_head, |
348 | ma_tail, | 379 | ma_tail, |
349 | ma); | 380 | ma); |
@@ -352,28 +383,50 @@ dht_put_monitor_continuation (void *cls, | |||
352 | 383 | ||
353 | 384 | ||
354 | /** | 385 | /** |
355 | * Check if the current zone iteration needs to be continued | 386 | * Calculate #next_put_interval. |
356 | * by calling #publish_zone_dht_next(), and if so with what delay. | ||
357 | */ | 387 | */ |
358 | static void | 388 | static void |
359 | check_zone_dht_next () | 389 | calculate_put_interval () |
360 | { | 390 | { |
361 | struct GNUNET_TIME_Relative delay; | 391 | if (0 == num_public_records) |
362 | 392 | { | |
363 | if (0 != ns_iteration_left) | 393 | /** |
364 | return; /* current NAMESTORE iteration not yet done */ | 394 | * If no records are known (startup) or none present |
365 | if (NULL != it_head) | 395 | * we can safely set the interval to the value for a single |
366 | return; /* waiting on DHT */ | 396 | * record |
367 | delay = GNUNET_TIME_relative_subtract (next_put_interval, | 397 | */ |
368 | sub_delta); | 398 | next_put_interval = zone_publish_time_window; |
369 | /* We delay *once* per #NS_BLOCK_SIZE, so we need to multiply the | 399 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
370 | per-record delay calculated so far with the #NS_BLOCK_SIZE */ | 400 | "No records in namestore database.\n"); |
371 | delay = GNUNET_TIME_relative_multiply (delay, | 401 | } |
372 | NS_BLOCK_SIZE); | 402 | else |
373 | GNUNET_assert (NULL == zone_publish_task); | 403 | { |
374 | zone_publish_task = GNUNET_SCHEDULER_add_delayed (delay, | 404 | last_min_relative_record_time |
375 | &publish_zone_dht_next, | 405 | = GNUNET_TIME_relative_min (last_min_relative_record_time, |
376 | NULL); | 406 | min_relative_record_time); |
407 | zone_publish_time_window | ||
408 | = GNUNET_TIME_relative_min (GNUNET_TIME_relative_divide (last_min_relative_record_time, | ||
409 | PUBLISH_OPS_PER_EXPIRATION), | ||
410 | zone_publish_time_window_default); | ||
411 | next_put_interval | ||
412 | = GNUNET_TIME_relative_divide (zone_publish_time_window, | ||
413 | last_num_public_records); | ||
414 | } | ||
415 | next_put_interval | ||
416 | = GNUNET_TIME_relative_min (next_put_interval, | ||
417 | MAXIMUM_ZONE_ITERATION_INTERVAL); | ||
418 | GNUNET_STATISTICS_set (statistics, | ||
419 | "Minimum relative record expiration (in ms)", | ||
420 | last_min_relative_record_time.rel_value_us / 1000LL, | ||
421 | GNUNET_NO); | ||
422 | GNUNET_STATISTICS_set (statistics, | ||
423 | "Zone publication time window (in ms)", | ||
424 | zone_publish_time_window.rel_value_us / 1000LL, | ||
425 | GNUNET_NO); | ||
426 | GNUNET_STATISTICS_set (statistics, | ||
427 | "Target zone iteration velocity (μs)", | ||
428 | next_put_interval.rel_value_us, | ||
429 | GNUNET_NO); | ||
377 | } | 430 | } |
378 | 431 | ||
379 | 432 | ||
@@ -381,16 +434,20 @@ check_zone_dht_next () | |||
381 | * Re-calculate our velocity and the desired velocity. | 434 | * Re-calculate our velocity and the desired velocity. |
382 | * We have succeeded in making #DELTA_INTERVAL puts, so | 435 | * We have succeeded in making #DELTA_INTERVAL puts, so |
383 | * now calculate the new desired delay between puts. | 436 | * now calculate the new desired delay between puts. |
437 | * | ||
438 | * @param cnt how many records were processed since the last call? | ||
384 | */ | 439 | */ |
385 | static void | 440 | static void |
386 | update_velocity () | 441 | update_velocity (unsigned int cnt) |
387 | { | 442 | { |
388 | struct GNUNET_TIME_Relative delta; | 443 | struct GNUNET_TIME_Relative delta; |
389 | unsigned long long pct = 0; | 444 | unsigned long long pct = 0; |
390 | 445 | ||
446 | if (0 == cnt) | ||
447 | return; | ||
391 | /* How fast were we really? */ | 448 | /* How fast were we really? */ |
392 | delta = GNUNET_TIME_absolute_get_duration (last_put_100); | 449 | delta = GNUNET_TIME_absolute_get_duration (last_put_100); |
393 | delta.rel_value_us /= DELTA_INTERVAL; | 450 | delta.rel_value_us /= cnt; |
394 | last_put_100 = GNUNET_TIME_absolute_get (); | 451 | last_put_100 = GNUNET_TIME_absolute_get (); |
395 | 452 | ||
396 | /* calculate expected frequency */ | 453 | /* calculate expected frequency */ |
@@ -399,18 +456,9 @@ update_velocity () | |||
399 | { | 456 | { |
400 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 457 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
401 | "Last record count was lower than current record count. Reducing interval.\n"); | 458 | "Last record count was lower than current record count. Reducing interval.\n"); |
402 | put_interval = GNUNET_TIME_relative_divide (zone_publish_time_window, | 459 | last_num_public_records = num_public_records * LATE_ITERATION_SPEEDUP_FACTOR; |
403 | num_public_records); | 460 | calculate_put_interval (); |
404 | next_put_interval = GNUNET_TIME_relative_divide (put_interval, | ||
405 | LATE_ITERATION_SPEEDUP_FACTOR); | ||
406 | } | ||
407 | else | ||
408 | { | ||
409 | next_put_interval = put_interval; | ||
410 | } | 461 | } |
411 | |||
412 | next_put_interval = GNUNET_TIME_relative_min (next_put_interval, | ||
413 | MAXIMUM_ZONE_ITERATION_INTERVAL); | ||
414 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 462 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
415 | "Desired global zone iteration interval is %s/record!\n", | 463 | "Desired global zone iteration interval is %s/record!\n", |
416 | GNUNET_STRINGS_relative_time_to_string (next_put_interval, | 464 | GNUNET_STRINGS_relative_time_to_string (next_put_interval, |
@@ -418,11 +466,7 @@ update_velocity () | |||
418 | 466 | ||
419 | /* Tell statistics actual vs. desired speed */ | 467 | /* Tell statistics actual vs. desired speed */ |
420 | GNUNET_STATISTICS_set (statistics, | 468 | GNUNET_STATISTICS_set (statistics, |
421 | "Target zone iteration velocity (μs)", | 469 | "Current zone iteration velocity (μs/record)", |
422 | next_put_interval.rel_value_us, | ||
423 | GNUNET_NO); | ||
424 | GNUNET_STATISTICS_set (statistics, | ||
425 | "Current zone iteration velocity (μs)", | ||
426 | delta.rel_value_us, | 470 | delta.rel_value_us, |
427 | GNUNET_NO); | 471 | GNUNET_NO); |
428 | /* update "sub_delta" based on difference, taking | 472 | /* update "sub_delta" based on difference, taking |
@@ -466,12 +510,21 @@ update_velocity () | |||
466 | if (0 == next_put_interval.rel_value_us) | 510 | if (0 == next_put_interval.rel_value_us) |
467 | pct = UINT64_MAX; /* desired speed is infinity ... */ | 511 | pct = UINT64_MAX; /* desired speed is infinity ... */ |
468 | else | 512 | else |
469 | pct = (sub_delta.rel_value_us - next_put_interval.rel_value_us) * 100LLU | 513 | pct = (sub_delta.rel_value_us - |
514 | next_put_interval.rel_value_us) * 100LLU | ||
470 | / next_put_interval.rel_value_us; | 515 | / next_put_interval.rel_value_us; |
471 | sub_delta = next_put_interval; | 516 | sub_delta = next_put_interval; |
472 | } | 517 | } |
473 | } | 518 | } |
474 | GNUNET_STATISTICS_set (statistics, | 519 | GNUNET_STATISTICS_set (statistics, |
520 | "# size of the DHT queue (it)", | ||
521 | dht_queue_length, | ||
522 | GNUNET_NO); | ||
523 | GNUNET_STATISTICS_set (statistics, | ||
524 | "# size of the DHT queue (mon)", | ||
525 | ma_queue_length, | ||
526 | GNUNET_NO); | ||
527 | GNUNET_STATISTICS_set (statistics, | ||
475 | "% speed increase needed for target velocity", | 528 | "% speed increase needed for target velocity", |
476 | pct, | 529 | pct, |
477 | GNUNET_NO); | 530 | GNUNET_NO); |
@@ -483,36 +536,55 @@ update_velocity () | |||
483 | 536 | ||
484 | 537 | ||
485 | /** | 538 | /** |
539 | * Check if the current zone iteration needs to be continued | ||
540 | * by calling #publish_zone_namestore_next(), and if so with what delay. | ||
541 | */ | ||
542 | static void | ||
543 | check_zone_namestore_next () | ||
544 | { | ||
545 | struct GNUNET_TIME_Relative delay; | ||
546 | |||
547 | if (0 != ns_iteration_left) | ||
548 | return; /* current NAMESTORE iteration not yet done */ | ||
549 | update_velocity (put_cnt); | ||
550 | put_cnt = 0; | ||
551 | delay = GNUNET_TIME_relative_subtract (next_put_interval, | ||
552 | sub_delta); | ||
553 | /* We delay *once* per #NS_BLOCK_SIZE, so we need to multiply the | ||
554 | per-record delay calculated so far with the #NS_BLOCK_SIZE */ | ||
555 | GNUNET_STATISTICS_set (statistics, | ||
556 | "Current artificial NAMESTORE delay (μs/record)", | ||
557 | delay.rel_value_us, | ||
558 | GNUNET_NO); | ||
559 | delay = GNUNET_TIME_relative_multiply (delay, | ||
560 | NS_BLOCK_SIZE); | ||
561 | GNUNET_assert (NULL == zone_publish_task); | ||
562 | zone_publish_task = GNUNET_SCHEDULER_add_delayed (delay, | ||
563 | &publish_zone_namestore_next, | ||
564 | NULL); | ||
565 | } | ||
566 | |||
567 | |||
568 | /** | ||
486 | * Continuation called from DHT once the PUT operation is done. | 569 | * Continuation called from DHT once the PUT operation is done. |
487 | * | 570 | * |
488 | * @param cls a `struct DhtPutActivity` | 571 | * @param cls a `struct DhtPutActivity` |
489 | * @param success #GNUNET_OK on success | ||
490 | */ | 572 | */ |
491 | static void | 573 | static void |
492 | dht_put_continuation (void *cls, | 574 | dht_put_continuation (void *cls) |
493 | int success) | ||
494 | { | 575 | { |
495 | struct DhtPutActivity *ma = cls; | 576 | struct DhtPutActivity *ma = cls; |
496 | 577 | ||
497 | num_public_records++; | ||
498 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 578 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
499 | "PUT complete (%s)\n", | 579 | "PUT complete\n"); |
500 | (GNUNET_OK == success) ? "success" : "failure"); | 580 | dht_queue_length--; |
501 | GNUNET_CONTAINER_DLL_remove (it_head, | 581 | GNUNET_CONTAINER_DLL_remove (it_head, |
502 | it_tail, | 582 | it_tail, |
503 | ma); | 583 | ma); |
504 | GNUNET_free (ma); | 584 | GNUNET_free (ma); |
505 | if (GNUNET_OK == success) | ||
506 | { | ||
507 | put_cnt++; | ||
508 | if (0 == put_cnt % DELTA_INTERVAL) | ||
509 | update_velocity (); | ||
510 | } | ||
511 | check_zone_dht_next (); | ||
512 | } | 585 | } |
513 | 586 | ||
514 | 587 | ||
515 | |||
516 | /** | 588 | /** |
517 | * Convert namestore records from the internal format to that | 589 | * Convert namestore records from the internal format to that |
518 | * suitable for publication (removes private records, converts | 590 | * suitable for publication (removes private records, converts |
@@ -572,7 +644,7 @@ perform_dht_put (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | |||
572 | const char *label, | 644 | const char *label, |
573 | const struct GNUNET_GNSRECORD_Data *rd_public, | 645 | const struct GNUNET_GNSRECORD_Data *rd_public, |
574 | unsigned int rd_public_count, | 646 | unsigned int rd_public_count, |
575 | GNUNET_DHT_PutContinuation cont, | 647 | GNUNET_SCHEDULER_TaskCallback cont, |
576 | void *cont_cls) | 648 | void *cont_cls) |
577 | { | 649 | { |
578 | struct GNUNET_GNSRECORD_Block *block; | 650 | struct GNUNET_GNSRECORD_Block *block; |
@@ -616,6 +688,7 @@ perform_dht_put (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | |||
616 | label, | 688 | label, |
617 | GNUNET_STRINGS_absolute_time_to_string (expire), | 689 | GNUNET_STRINGS_absolute_time_to_string (expire), |
618 | GNUNET_h2s (&query)); | 690 | GNUNET_h2s (&query)); |
691 | num_public_records++; | ||
619 | ret = GNUNET_DHT_put (dht_handle, | 692 | ret = GNUNET_DHT_put (dht_handle, |
620 | &query, | 693 | &query, |
621 | DHT_GNS_REPLICATION_LEVEL, | 694 | DHT_GNS_REPLICATION_LEVEL, |
@@ -674,53 +747,27 @@ zone_iteration_finished (void *cls) | |||
674 | namestore_iter = NULL; | 747 | namestore_iter = NULL; |
675 | last_num_public_records = num_public_records; | 748 | last_num_public_records = num_public_records; |
676 | first_zone_iteration = GNUNET_NO; | 749 | first_zone_iteration = GNUNET_NO; |
677 | if (0 == num_public_records) | 750 | last_min_relative_record_time = min_relative_record_time; |
678 | { | 751 | calculate_put_interval (); |
679 | /** | ||
680 | * If no records are known (startup) or none present | ||
681 | * we can safely set the interval to the value for a single | ||
682 | * record | ||
683 | */ | ||
684 | put_interval = zone_publish_time_window; | ||
685 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | ||
686 | "No records in namestore database.\n"); | ||
687 | } | ||
688 | else | ||
689 | { | ||
690 | /* If records are present, next publication is based on the minimum | ||
691 | * relative expiration time of the records published divided by 4 | ||
692 | */ | ||
693 | zone_publish_time_window | ||
694 | = GNUNET_TIME_relative_min (GNUNET_TIME_relative_divide (min_relative_record_time, 4), | ||
695 | zone_publish_time_window_default); | ||
696 | put_interval = GNUNET_TIME_relative_divide (zone_publish_time_window, | ||
697 | num_public_records); | ||
698 | } | ||
699 | /* reset for next iteration */ | 752 | /* reset for next iteration */ |
700 | min_relative_record_time = GNUNET_TIME_UNIT_FOREVER_REL; | 753 | min_relative_record_time |
701 | put_interval = GNUNET_TIME_relative_max (MINIMUM_ZONE_ITERATION_INTERVAL, | 754 | = GNUNET_TIME_relative_multiply (GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY, |
702 | put_interval); | 755 | PUBLISH_OPS_PER_EXPIRATION); |
703 | put_interval = GNUNET_TIME_relative_min (put_interval, | ||
704 | MAXIMUM_ZONE_ITERATION_INTERVAL); | ||
705 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 756 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
706 | "Zone iteration finished. Adjusted zone iteration interval to %s\n", | 757 | "Zone iteration finished. Adjusted zone iteration interval to %s\n", |
707 | GNUNET_STRINGS_relative_time_to_string (put_interval, | 758 | GNUNET_STRINGS_relative_time_to_string (next_put_interval, |
708 | GNUNET_YES)); | 759 | GNUNET_YES)); |
709 | GNUNET_STATISTICS_set (statistics, | 760 | GNUNET_STATISTICS_set (statistics, |
710 | "Current zone iteration interval (in ms)", | 761 | "Current zone iteration interval (in ms)", |
711 | put_interval.rel_value_us / 1000LL, | 762 | next_put_interval.rel_value_us / 1000LL, |
712 | GNUNET_NO); | 763 | GNUNET_NO); |
713 | GNUNET_STATISTICS_update (statistics, | ||
714 | "Number of zone iterations", | ||
715 | 1, | ||
716 | GNUNET_NO); | ||
717 | GNUNET_STATISTICS_set (statistics, | 764 | GNUNET_STATISTICS_set (statistics, |
718 | "Number of public records in DHT", | 765 | "Number of public records in DHT", |
719 | last_num_public_records, | 766 | last_num_public_records, |
720 | GNUNET_NO); | 767 | GNUNET_NO); |
721 | GNUNET_assert (NULL == zone_publish_task); | 768 | GNUNET_assert (NULL == zone_publish_task); |
722 | if (0 == num_public_records) | 769 | if (0 == last_num_public_records) |
723 | zone_publish_task = GNUNET_SCHEDULER_add_delayed (put_interval, | 770 | zone_publish_task = GNUNET_SCHEDULER_add_delayed (next_put_interval, |
724 | &publish_zone_dht_start, | 771 | &publish_zone_dht_start, |
725 | NULL); | 772 | NULL); |
726 | else | 773 | else |
@@ -756,33 +803,51 @@ put_gns_record (void *cls, | |||
756 | rd_public); | 803 | rd_public); |
757 | if (0 == rd_public_count) | 804 | if (0 == rd_public_count) |
758 | { | 805 | { |
759 | GNUNET_assert (NULL == zone_publish_task); | ||
760 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 806 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
761 | "Record set empty, moving to next record set\n"); | 807 | "Record set empty, moving to next record set\n"); |
762 | check_zone_dht_next (); | 808 | check_zone_namestore_next (); |
763 | return; | 809 | return; |
764 | } | 810 | } |
765 | /* We got a set of records to publish */ | 811 | /* We got a set of records to publish */ |
766 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 812 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
767 | "Starting DHT PUT\n"); | 813 | "Starting DHT PUT\n"); |
768 | ma = GNUNET_new (struct DhtPutActivity); | 814 | ma = GNUNET_new (struct DhtPutActivity); |
815 | ma->start_date = GNUNET_TIME_absolute_get (); | ||
769 | ma->ph = perform_dht_put (key, | 816 | ma->ph = perform_dht_put (key, |
770 | label, | 817 | label, |
771 | rd_public, | 818 | rd_public, |
772 | rd_public_count, | 819 | rd_public_count, |
773 | &dht_put_continuation, | 820 | &dht_put_continuation, |
774 | ma); | 821 | ma); |
822 | put_cnt++; | ||
823 | if (0 == put_cnt % DELTA_INTERVAL) | ||
824 | update_velocity (DELTA_INTERVAL); | ||
825 | check_zone_namestore_next (); | ||
775 | if (NULL == ma->ph) | 826 | if (NULL == ma->ph) |
776 | { | 827 | { |
777 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 828 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
778 | "Could not perform DHT PUT, is the DHT running?\n"); | 829 | "Could not perform DHT PUT, is the DHT running?\n"); |
779 | GNUNET_free (ma); | 830 | GNUNET_free (ma); |
780 | check_zone_dht_next (); | ||
781 | return; | 831 | return; |
782 | } | 832 | } |
783 | GNUNET_CONTAINER_DLL_insert (it_head, | 833 | dht_queue_length++; |
784 | it_tail, | 834 | GNUNET_CONTAINER_DLL_insert_tail (it_head, |
785 | ma); | 835 | it_tail, |
836 | ma); | ||
837 | if (dht_queue_length > DHT_QUEUE_LIMIT) | ||
838 | { | ||
839 | ma = it_head; | ||
840 | GNUNET_CONTAINER_DLL_remove (it_head, | ||
841 | it_tail, | ||
842 | ma); | ||
843 | GNUNET_DHT_put_cancel (ma->ph); | ||
844 | dht_queue_length--; | ||
845 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
846 | "DHT PUT unconfirmed after %s, aborting PUT\n", | ||
847 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (ma->start_date), | ||
848 | GNUNET_YES)); | ||
849 | GNUNET_free (ma); | ||
850 | } | ||
786 | } | 851 | } |
787 | 852 | ||
788 | 853 | ||
@@ -815,6 +880,7 @@ publish_zone_dht_start (void *cls) | |||
815 | NULL, | 880 | NULL, |
816 | &zone_iteration_finished, | 881 | &zone_iteration_finished, |
817 | NULL); | 882 | NULL); |
883 | GNUNET_assert (NULL != namestore_iter); | ||
818 | } | 884 | } |
819 | 885 | ||
820 | 886 | ||
@@ -839,6 +905,7 @@ handle_monitor_event (void *cls, | |||
839 | unsigned int rd_public_count; | 905 | unsigned int rd_public_count; |
840 | struct DhtPutActivity *ma; | 906 | struct DhtPutActivity *ma; |
841 | 907 | ||
908 | (void) cls; | ||
842 | GNUNET_STATISTICS_update (statistics, | 909 | GNUNET_STATISTICS_update (statistics, |
843 | "Namestore monitor events received", | 910 | "Namestore monitor events received", |
844 | 1, | 911 | 1, |
@@ -854,7 +921,9 @@ handle_monitor_event (void *cls, | |||
854 | rd_public); | 921 | rd_public); |
855 | if (0 == rd_public_count) | 922 | if (0 == rd_public_count) |
856 | return; /* nothing to do */ | 923 | return; /* nothing to do */ |
924 | num_public_records++; | ||
857 | ma = GNUNET_new (struct DhtPutActivity); | 925 | ma = GNUNET_new (struct DhtPutActivity); |
926 | ma->start_date = GNUNET_TIME_absolute_get (); | ||
858 | ma->ph = perform_dht_put (zone, | 927 | ma->ph = perform_dht_put (zone, |
859 | label, | 928 | label, |
860 | rd, | 929 | rd, |
@@ -867,9 +936,24 @@ handle_monitor_event (void *cls, | |||
867 | GNUNET_free (ma); | 936 | GNUNET_free (ma); |
868 | return; | 937 | return; |
869 | } | 938 | } |
870 | GNUNET_CONTAINER_DLL_insert (ma_head, | 939 | GNUNET_CONTAINER_DLL_insert_tail (ma_head, |
871 | ma_tail, | 940 | ma_tail, |
872 | ma); | 941 | ma); |
942 | ma_queue_length++; | ||
943 | if (ma_queue_length > DHT_QUEUE_LIMIT) | ||
944 | { | ||
945 | ma = it_head; | ||
946 | GNUNET_CONTAINER_DLL_remove (ma_head, | ||
947 | ma_tail, | ||
948 | ma); | ||
949 | GNUNET_DHT_put_cancel (ma->ph); | ||
950 | ma_queue_length--; | ||
951 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
952 | "DHT PUT unconfirmed after %s, aborting PUT\n", | ||
953 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (ma->start_date), | ||
954 | GNUNET_YES)); | ||
955 | GNUNET_free (ma); | ||
956 | } | ||
873 | } | 957 | } |
874 | 958 | ||
875 | 959 | ||
@@ -939,8 +1023,12 @@ run (void *cls, | |||
939 | unsigned long long max_parallel_bg_queries = 128; | 1023 | unsigned long long max_parallel_bg_queries = 128; |
940 | 1024 | ||
941 | (void) cls; | 1025 | (void) cls; |
1026 | (void) service; | ||
942 | last_put_100 = GNUNET_TIME_absolute_get (); /* first time! */ | 1027 | last_put_100 = GNUNET_TIME_absolute_get (); /* first time! */ |
943 | min_relative_record_time = GNUNET_TIME_UNIT_FOREVER_REL; | 1028 | min_relative_record_time |
1029 | = GNUNET_TIME_relative_multiply (GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY, | ||
1030 | PUBLISH_OPS_PER_EXPIRATION); | ||
1031 | next_put_interval = INITIAL_PUT_INTERVAL; | ||
944 | namestore_handle = GNUNET_NAMESTORE_connect (c); | 1032 | namestore_handle = GNUNET_NAMESTORE_connect (c); |
945 | if (NULL == namestore_handle) | 1033 | if (NULL == namestore_handle) |
946 | { | 1034 | { |
@@ -952,7 +1040,6 @@ run (void *cls, | |||
952 | cache_keys = GNUNET_CONFIGURATION_get_value_yesno (c, | 1040 | cache_keys = GNUNET_CONFIGURATION_get_value_yesno (c, |
953 | "namestore", | 1041 | "namestore", |
954 | "CACHE_KEYS"); | 1042 | "CACHE_KEYS"); |
955 | put_interval = INITIAL_PUT_INTERVAL; | ||
956 | zone_publish_time_window_default = DEFAULT_ZONE_PUBLISH_TIME_WINDOW; | 1043 | zone_publish_time_window_default = DEFAULT_ZONE_PUBLISH_TIME_WINDOW; |
957 | if (GNUNET_OK == | 1044 | if (GNUNET_OK == |
958 | GNUNET_CONFIGURATION_get_value_time (c, | 1045 | GNUNET_CONFIGURATION_get_value_time (c, |
@@ -984,7 +1071,8 @@ run (void *cls, | |||
984 | { | 1071 | { |
985 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1072 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
986 | _("Could not connect to DHT!\n")); | 1073 | _("Could not connect to DHT!\n")); |
987 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | 1074 | GNUNET_SCHEDULER_add_now (&shutdown_task, |
1075 | NULL); | ||
988 | return; | 1076 | return; |
989 | } | 1077 | } |
990 | 1078 | ||
@@ -992,6 +1080,10 @@ run (void *cls, | |||
992 | first_zone_iteration = GNUNET_YES;\ | 1080 | first_zone_iteration = GNUNET_YES;\ |
993 | statistics = GNUNET_STATISTICS_create ("zonemaster", | 1081 | statistics = GNUNET_STATISTICS_create ("zonemaster", |
994 | c); | 1082 | c); |
1083 | GNUNET_STATISTICS_set (statistics, | ||
1084 | "Target zone iteration velocity (μs)", | ||
1085 | next_put_interval.rel_value_us, | ||
1086 | GNUNET_NO); | ||
995 | zmon = GNUNET_NAMESTORE_zone_monitor_start (c, | 1087 | zmon = GNUNET_NAMESTORE_zone_monitor_start (c, |
996 | NULL, | 1088 | NULL, |
997 | GNUNET_NO, | 1089 | GNUNET_NO, |
@@ -1002,7 +1094,8 @@ run (void *cls, | |||
1002 | &monitor_sync_event, | 1094 | &monitor_sync_event, |
1003 | NULL); | 1095 | NULL); |
1004 | GNUNET_break (NULL != zmon); | 1096 | GNUNET_break (NULL != zmon); |
1005 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); | 1097 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
1098 | NULL); | ||
1006 | } | 1099 | } |
1007 | 1100 | ||
1008 | 1101 | ||