diff options
author | Schanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de> | 2018-01-08 07:58:36 +0100 |
---|---|---|
committer | Schanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de> | 2018-01-08 07:58:36 +0100 |
commit | 3f52ce03cb13118bef9a6fbe380f229e2cbec45f (patch) | |
tree | 0f986c12192fcdd5d05fe575f66f01a0cf5ddf4e | |
parent | 7ad94d1427d304483e9bf1cf1d12065f8e41d712 (diff) | |
parent | 0120859e1ea2f0591602f446d4bc054e9230c801 (diff) | |
download | gnunet-3f52ce03cb13118bef9a6fbe380f229e2cbec45f.tar.gz gnunet-3f52ce03cb13118bef9a6fbe380f229e2cbec45f.zip |
Merge branch 'master' of git+ssh://gnunet.org/gnunet
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | doc/documentation/chapters/developer.texi | 12 | ||||
-rw-r--r-- | doc/documentation/chapters/philosophy.texi | 11 | ||||
-rw-r--r-- | doc/documentation/chapters/user.texi | 6 | ||||
-rw-r--r-- | doc/documentation/gnunet-c-tutorial.texi | 2 | ||||
-rw-r--r-- | src/fs/fs_search.c | 19 | ||||
-rw-r--r-- | src/fs/fs_uri.c | 25 | ||||
-rw-r--r-- | src/gns/gnunet-dns2gns.c | 45 | ||||
-rw-r--r-- | src/include/gnunet_fs_service.h | 3 | ||||
-rw-r--r-- | src/include/gnunet_network_lib.h | 2 | ||||
-rw-r--r-- | src/nat/gnunet-nat.c | 12 | ||||
-rw-r--r-- | src/nse/gnunet-nse-profiler.c | 19 | ||||
-rw-r--r-- | src/peerinfo/gnunet-service-peerinfo.c | 6 | ||||
-rw-r--r-- | src/psycstore/psycstore_api.c | 3 | ||||
-rw-r--r-- | src/rps/test_rps.c | 212 | ||||
-rw-r--r-- | src/set/gnunet-service-set_union.c | 9 | ||||
-rw-r--r-- | src/social/gnunet-service-social.c | 75 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 4 | ||||
-rw-r--r-- | src/transport/plugin_transport_tcp.c | 7 | ||||
-rw-r--r-- | src/util/common_allocation.c | 5 | ||||
-rw-r--r-- | src/util/configuration.c | 1 | ||||
-rw-r--r-- | src/util/crypto_hash.c | 6 | ||||
-rw-r--r-- | src/util/network.c | 86 | ||||
-rw-r--r-- | src/util/scheduler.c | 17 |
24 files changed, 427 insertions, 161 deletions
@@ -33,6 +33,7 @@ Contributions also came from: | |||
33 | Adam Warrington [ UPnP ] | 33 | Adam Warrington [ UPnP ] |
34 | Adriano Peluso [ Documentation export to Texinfo ] | 34 | Adriano Peluso [ Documentation export to Texinfo ] |
35 | Alex Harper [ OS X CPU load ] | 35 | Alex Harper [ OS X CPU load ] |
36 | Amirouche Boubekki <amirouche@hypermove.net> | ||
36 | Andrew McDonald <andrew@mcdonald.org.uk> [ SHA-512] | 37 | Andrew McDonald <andrew@mcdonald.org.uk> [ SHA-512] |
37 | Andy Green <andy@warmcat.com> | 38 | Andy Green <andy@warmcat.com> |
38 | Antti Salonen | 39 | Antti Salonen |
diff --git a/doc/documentation/chapters/developer.texi b/doc/documentation/chapters/developer.texi index ada6d37a0..a99f6a481 100644 --- a/doc/documentation/chapters/developer.texi +++ b/doc/documentation/chapters/developer.texi | |||
@@ -94,6 +94,7 @@ following links: | |||
94 | @c ** FIXME: Link to files in source, not online. | 94 | @c ** FIXME: Link to files in source, not online. |
95 | @c ** FIXME: Where is the Java tutorial? | 95 | @c ** FIXME: Where is the Java tutorial? |
96 | @itemize @bullet | 96 | @itemize @bullet |
97 | @c broken link | ||
97 | @item @uref{https://gnunet.org/git/gnunet.git/plain/doc/gnunet-c-tutorial.pdf, GNUnet C tutorial} | 98 | @item @uref{https://gnunet.org/git/gnunet.git/plain/doc/gnunet-c-tutorial.pdf, GNUnet C tutorial} |
98 | @item GNUnet Java tutorial | 99 | @item GNUnet Java tutorial |
99 | @end itemize | 100 | @end itemize |
@@ -273,7 +274,7 @@ library is a wapper around block plugins which provide the necessary | |||
273 | functions for each block type. | 274 | functions for each block type. |
274 | @item @file{statistics/} --- statistics service | 275 | @item @file{statistics/} --- statistics service |
275 | The statistics service enables associating | 276 | The statistics service enables associating |
276 | values (of type uint64_t) with a componenet name and a string. The main | 277 | values (of type uint64_t) with a component name and a string. The main |
277 | uses is debugging (counting events), performance tracking and user | 278 | uses is debugging (counting events), performance tracking and user |
278 | entertainment (what did my peer do today?). | 279 | entertainment (what did my peer do today?). |
279 | @item @file{arm/} --- Automatic Restart Manager (ARM) | 280 | @item @file{arm/} --- Automatic Restart Manager (ARM) |
@@ -2450,7 +2451,7 @@ memcpy (tbuf, nameTrans, strlen (nameTrans) + 1); | |||
2450 | 2451 | ||
2451 | Note that, here the functions @code{htonl}, @code{htons} and | 2452 | Note that, here the functions @code{htonl}, @code{htons} and |
2452 | @code{GNUNET_TIME_absolute_hton} are applied to convert little endian | 2453 | @code{GNUNET_TIME_absolute_hton} are applied to convert little endian |
2453 | into big endian, about the usage of the big/small edian order and the | 2454 | into big endian, about the usage of the big/small endian order and the |
2454 | corresponding conversion function please refer to Introduction of | 2455 | corresponding conversion function please refer to Introduction of |
2455 | Big Endian and Little Endian. | 2456 | Big Endian and Little Endian. |
2456 | 2457 | ||
@@ -7027,6 +7028,7 @@ bandwidth consumption. | |||
7027 | 7028 | ||
7028 | @c %**end of header | 7029 | @c %**end of header |
7029 | 7030 | ||
7031 | @c inconsistent use of ``must'' above it's written ``MUST'' | ||
7030 | In contrast to GET operations, developers @strong{must} manually re-run | 7032 | In contrast to GET operations, developers @strong{must} manually re-run |
7031 | PUT operations periodically (if they intend the content to continue to be | 7033 | PUT operations periodically (if they intend the content to continue to be |
7032 | available). Content stored in the DHT expires or might be lost due to | 7034 | available). Content stored in the DHT expires or might be lost due to |
@@ -7055,7 +7057,7 @@ Using the monitoring API, applications can choose to monitor these | |||
7055 | requests, possibly limiting themselves to requests for a particular block | 7057 | requests, possibly limiting themselves to requests for a particular block |
7056 | type. | 7058 | type. |
7057 | 7059 | ||
7058 | The monitoring API is not only usefu only for diagnostics, it can also be | 7060 | The monitoring API is not only useful for diagnostics, it can also be |
7059 | used to trigger application operations based on PUT operations. | 7061 | used to trigger application operations based on PUT operations. |
7060 | For example, an application may use PUTs to distribute work requests to | 7062 | For example, an application may use PUTs to distribute work requests to |
7061 | other peers. | 7063 | other peers. |
@@ -7149,7 +7151,7 @@ already knows more than about a thousand blocks may need to send | |||
7149 | several of these messages. Naturally, the client should transmit these | 7151 | several of these messages. Naturally, the client should transmit these |
7150 | messages as quickly as possible after the original GET request such that | 7152 | messages as quickly as possible after the original GET request such that |
7151 | the DHT can filter those results in the network early on. Naturally, as | 7153 | the DHT can filter those results in the network early on. Naturally, as |
7152 | these messages are send after the original request, it is conceivalbe | 7154 | these messages are sent after the original request, it is conceivalbe |
7153 | that the DHT service may return blocks that match those already known | 7155 | that the DHT service may return blocks that match those already known |
7154 | to the client anyway. | 7156 | to the client anyway. |
7155 | 7157 | ||
@@ -7240,7 +7242,7 @@ A peer can search the DHT by sending @code{struct PeerGetMessage}s of type | |||
7240 | @code{GNUNET_MESSAGE_TYPE_DHT_P2P_GET} to other peers. In addition to the | 7242 | @code{GNUNET_MESSAGE_TYPE_DHT_P2P_GET} to other peers. In addition to the |
7241 | usual information about the request (type, routing options, desired | 7243 | usual information about the request (type, routing options, desired |
7242 | replication level for the request, the key and the extended query), a GET | 7244 | replication level for the request, the key and the extended query), a GET |
7243 | request also again contains a hop counter, a Bloom filter over the peers | 7245 | request also contains a hop counter, a Bloom filter over the peers |
7244 | that have processed the request already and depending on the routing | 7246 | that have processed the request already and depending on the routing |
7245 | options the full path traversed by the GET. | 7247 | options the full path traversed by the GET. |
7246 | Finally, a GET request includes a variable-size second Bloom filter and a | 7248 | Finally, a GET request includes a variable-size second Bloom filter and a |
diff --git a/doc/documentation/chapters/philosophy.texi b/doc/documentation/chapters/philosophy.texi index c8e2651c3..681d5acc3 100644 --- a/doc/documentation/chapters/philosophy.texi +++ b/doc/documentation/chapters/philosophy.texi | |||
@@ -47,7 +47,9 @@ Refer to @uref{https://www.gnu.org/philosophy/free-sw.html, https://www.gnu.org/ | |||
47 | @item GNUnet must only disclose the minimal amount of information | 47 | @item GNUnet must only disclose the minimal amount of information |
48 | necessary. | 48 | necessary. |
49 | @c TODO: Explain 'fully' in the terminology section. | 49 | @c TODO: Explain 'fully' in the terminology section. |
50 | @item GNUnet must be fully distributed and survive Byzantine failures | 50 | @item GNUnet must be fully distributed and survive |
51 | @uref{https://en.wikipedia.org/wiki/Byzantine_fault_tolerance, Byzantine failures} | ||
52 | @footnote{@uref{https://en.wikipedia.org/wiki/Byzantine_fault_tolerance, https://en.wikipedia.org/wiki/Byzantine_fault_tolerance}} | ||
51 | at any position in the network. | 53 | at any position in the network. |
52 | @item GNUnet must make it explicit to the user which entities are | 54 | @item GNUnet must make it explicit to the user which entities are |
53 | considered to be trustworthy when establishing secured communications. | 55 | considered to be trustworthy when establishing secured communications. |
@@ -163,7 +165,7 @@ DH (Diffie---Hellman) key exchange using ephemeral eliptic curve | |||
163 | cryptography. The ephemeral ECC (Eliptic Curve Cryptography) keys are | 165 | cryptography. The ephemeral ECC (Eliptic Curve Cryptography) keys are |
164 | signed using ECDSA (@uref{http://en.wikipedia.org/wiki/ECDSA, ECDSA}). | 166 | signed using ECDSA (@uref{http://en.wikipedia.org/wiki/ECDSA, ECDSA}). |
165 | The shared secret from ECDHE is used to create a pair of session keys | 167 | The shared secret from ECDHE is used to create a pair of session keys |
166 | @c FIXME: LOng word for HKDF | 168 | @c FIXME: LOng word for HKDF. More FIXMEs: Explain MITM etc. |
167 | (using HKDF) which are then used to encrypt the communication between the | 169 | (using HKDF) which are then used to encrypt the communication between the |
168 | two peers using both 256-bit AES (Advanced Encryption Standard) | 170 | two peers using both 256-bit AES (Advanced Encryption Standard) |
169 | and 256-bit Twofish (with independently derived secret keys). | 171 | and 256-bit Twofish (with independently derived secret keys). |
@@ -173,8 +175,6 @@ without requiring signatures each time. GNUnet uses SHA-512 | |||
173 | (Secure Hash Algorithm) hash codes to verify the integrity of messages. | 175 | (Secure Hash Algorithm) hash codes to verify the integrity of messages. |
174 | 176 | ||
175 | In GNUnet, the identity of a host is its public key. For that reason, | 177 | In GNUnet, the identity of a host is its public key. For that reason, |
176 | @c FIXME: is it clear to the average reader what a man-in-the-middle | ||
177 | @c attack is? | ||
178 | man-in-the-middle attacks will not break the authentication or accounting | 178 | man-in-the-middle attacks will not break the authentication or accounting |
179 | goals. Essentially, for GNUnet, the IP of the host has nothing to do with | 179 | goals. Essentially, for GNUnet, the IP of the host has nothing to do with |
180 | the identity of the host. As the public key is the only thing that truly | 180 | the identity of the host. As the public key is the only thing that truly |
@@ -420,8 +420,9 @@ public key first. | |||
420 | @node Egos | 420 | @node Egos |
421 | @subsection Egos | 421 | @subsection Egos |
422 | 422 | ||
423 | @c what is the difference between peer identity and egos? It seems | ||
424 | @c like both are linked to public-private key pair. | ||
423 | Egos are your "identities" in GNUnet. Any user can assume multiple | 425 | Egos are your "identities" in GNUnet. Any user can assume multiple |
424 | identities, for example to separate their activities online. Egos can | 426 | identities, for example to separate their activities online. Egos can |
425 | correspond to pseudonyms or real-world identities. Technically, an | 427 | correspond to pseudonyms or real-world identities. Technically, an |
426 | ego is first of all a public-private key pair. | 428 | ego is first of all a public-private key pair. |
427 | |||
diff --git a/doc/documentation/chapters/user.texi b/doc/documentation/chapters/user.texi index 4159a6b32..1a30a7336 100644 --- a/doc/documentation/chapters/user.texi +++ b/doc/documentation/chapters/user.texi | |||
@@ -1183,6 +1183,8 @@ shared under the keyword "Das Kapital". | |||
1183 | 1183 | ||
1184 | Search results are printed by gnunet-search like this: | 1184 | Search results are printed by gnunet-search like this: |
1185 | 1185 | ||
1186 | @c it will be better the avoid the ellipsis altogether because I don't | ||
1187 | @c understand the explanation below that | ||
1186 | @example | 1188 | @example |
1187 | $ gnunet-download -o "COPYING" --- gnunet://fs/chk/N8...C92.17992 | 1189 | $ gnunet-download -o "COPYING" --- gnunet://fs/chk/N8...C92.17992 |
1188 | => The GNU Public License <= (mimetype: text/plain) | 1190 | => The GNU Public License <= (mimetype: text/plain) |
@@ -1192,6 +1194,7 @@ $ gnunet-download -o "COPYING" --- gnunet://fs/chk/N8...C92.17992 | |||
1192 | The first line is the command you would have to enter to download | 1194 | The first line is the command you would have to enter to download |
1193 | the file. The argument passed to @code{-o} is the suggested | 1195 | the file. The argument passed to @code{-o} is the suggested |
1194 | filename (you may change it to whatever you like). | 1196 | filename (you may change it to whatever you like). |
1197 | @c except it's triple dash in the above example --- | ||
1195 | The @code{--} is followed by key for decrypting the file, | 1198 | The @code{--} is followed by key for decrypting the file, |
1196 | the query for searching the file, a checksum (in hexadecimal) | 1199 | the query for searching the file, a checksum (in hexadecimal) |
1197 | finally the size of the file in bytes. | 1200 | finally the size of the file in bytes. |
@@ -1235,6 +1238,7 @@ GNUnet's file-encoding mechanism will ensure file integrity, even if the | |||
1235 | existing file was not downloaded from GNUnet in the first place. | 1238 | existing file was not downloaded from GNUnet in the first place. |
1236 | 1239 | ||
1237 | You may want to use the @command{-V} switch (must be added before | 1240 | You may want to use the @command{-V} switch (must be added before |
1241 | @c Same as above it's triple dash | ||
1238 | the @command{--}) to turn on verbose reporting. In this case, | 1242 | the @command{--}) to turn on verbose reporting. In this case, |
1239 | @command{gnunet-download} will print the current number of | 1243 | @command{gnunet-download} will print the current number of |
1240 | bytes downloaded whenever new data was received. | 1244 | bytes downloaded whenever new data was received. |
@@ -1301,7 +1305,7 @@ unavailable. | |||
1301 | @c %**end of header | 1305 | @c %**end of header |
1302 | 1306 | ||
1303 | Each namespace is associated with meta-data that describes | 1307 | Each namespace is associated with meta-data that describes |
1304 | the namespace. This meta data is provided by the user at | 1308 | the namespace. This meta-data is provided by the user at |
1305 | the time that the namespace is advertised. Advertisements | 1309 | the time that the namespace is advertised. Advertisements |
1306 | are published under keywords so that they can be found using | 1310 | are published under keywords so that they can be found using |
1307 | normal keyword-searches. This way, users can learn about new | 1311 | normal keyword-searches. This way, users can learn about new |
diff --git a/doc/documentation/gnunet-c-tutorial.texi b/doc/documentation/gnunet-c-tutorial.texi index f39c7de64..7eafa9ea9 100644 --- a/doc/documentation/gnunet-c-tutorial.texi +++ b/doc/documentation/gnunet-c-tutorial.texi | |||
@@ -244,6 +244,7 @@ $ wget $GNUPGFTP/libgpg-error/libgpg-error-1.27.tar.bz2 | |||
244 | $ tar xf libgpg-error-1.27.tar.bz2 | 244 | $ tar xf libgpg-error-1.27.tar.bz2 |
245 | $ cd libgpg-error-1.27 | 245 | $ cd libgpg-error-1.27 |
246 | $ ./configure | 246 | $ ./configure |
247 | $ make | ||
247 | $ sudo make install | 248 | $ sudo make install |
248 | $ cd .. | 249 | $ cd .. |
249 | @end example | 250 | @end example |
@@ -254,6 +255,7 @@ $ wget $GNUPGFTP/libgcrypt/libgcrypt-1.7.6.tar.bz2 | |||
254 | $ tar xf libgcrypt-1.7.6.tar.bz2 | 255 | $ tar xf libgcrypt-1.7.6.tar.bz2 |
255 | $ cd libgcrypt-1.7.6 | 256 | $ cd libgcrypt-1.7.6 |
256 | $ ./configure | 257 | $ ./configure |
258 | $ make | ||
257 | $ sudo make install | 259 | $ sudo make install |
258 | $ cd .. | 260 | $ cd .. |
259 | @end example | 261 | @end example |
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c index 8c6f5edcf..83aae2fc5 100644 --- a/src/fs/fs_search.c +++ b/src/fs/fs_search.c | |||
@@ -568,7 +568,13 @@ process_ksk_result (struct GNUNET_FS_SearchContext *sc, | |||
568 | 568 | ||
569 | /* check if new */ | 569 | /* check if new */ |
570 | GNUNET_assert (NULL != sc); | 570 | GNUNET_assert (NULL != sc); |
571 | GNUNET_FS_uri_to_key (uri, &key); | 571 | if (GNUNET_OK != |
572 | GNUNET_FS_uri_to_key (uri, | ||
573 | &key)) | ||
574 | { | ||
575 | GNUNET_break_op (0); | ||
576 | return; | ||
577 | } | ||
572 | if (GNUNET_SYSERR == | 578 | if (GNUNET_SYSERR == |
573 | GNUNET_CONTAINER_multihashmap_get_multiple (ent->results, | 579 | GNUNET_CONTAINER_multihashmap_get_multiple (ent->results, |
574 | &key, | 580 | &key, |
@@ -680,8 +686,15 @@ process_sks_result (struct GNUNET_FS_SearchContext *sc, | |||
680 | 686 | ||
681 | /* check if new */ | 687 | /* check if new */ |
682 | GNUNET_assert (NULL != sc); | 688 | GNUNET_assert (NULL != sc); |
683 | GNUNET_FS_uri_to_key (uri, &key); | 689 | if (GNUNET_OK != |
684 | GNUNET_CRYPTO_hash_xor (&uri->data.chk.chk.key, &uri->data.chk.chk.query, | 690 | GNUNET_FS_uri_to_key (uri, |
691 | &key)) | ||
692 | { | ||
693 | GNUNET_break (0); | ||
694 | return; | ||
695 | } | ||
696 | GNUNET_CRYPTO_hash_xor (&uri->data.chk.chk.key, | ||
697 | &uri->data.chk.chk.query, | ||
685 | &key); | 698 | &key); |
686 | if (GNUNET_SYSERR == | 699 | if (GNUNET_SYSERR == |
687 | GNUNET_CONTAINER_multihashmap_get_multiple (sc->master_result_map, &key, | 700 | GNUNET_CONTAINER_multihashmap_get_multiple (sc->master_result_map, &key, |
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c index 11968b750..b90c75981 100644 --- a/src/fs/fs_uri.c +++ b/src/fs/fs_uri.c | |||
@@ -96,8 +96,9 @@ | |||
96 | * | 96 | * |
97 | * @param uri uri to convert to a unique key | 97 | * @param uri uri to convert to a unique key |
98 | * @param key where to store the unique key | 98 | * @param key where to store the unique key |
99 | * @return #GNUNET_OK on success | ||
99 | */ | 100 | */ |
100 | void | 101 | int |
101 | GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri, | 102 | GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri, |
102 | struct GNUNET_HashCode *key) | 103 | struct GNUNET_HashCode *key) |
103 | { | 104 | { |
@@ -105,25 +106,35 @@ GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri, | |||
105 | { | 106 | { |
106 | case GNUNET_FS_URI_CHK: | 107 | case GNUNET_FS_URI_CHK: |
107 | *key = uri->data.chk.chk.query; | 108 | *key = uri->data.chk.chk.query; |
108 | return; | 109 | return GNUNET_OK; |
109 | case GNUNET_FS_URI_SKS: | 110 | case GNUNET_FS_URI_SKS: |
110 | GNUNET_CRYPTO_hash (uri->data.sks.identifier, | 111 | GNUNET_CRYPTO_hash (uri->data.sks.identifier, |
111 | strlen (uri->data.sks.identifier), key); | 112 | strlen (uri->data.sks.identifier), |
112 | break; | 113 | key); |
114 | return GNUNET_OK; | ||
113 | case GNUNET_FS_URI_KSK: | 115 | case GNUNET_FS_URI_KSK: |
114 | if (uri->data.ksk.keywordCount > 0) | 116 | if (uri->data.ksk.keywordCount > 0) |
117 | { | ||
115 | GNUNET_CRYPTO_hash (uri->data.ksk.keywords[0], | 118 | GNUNET_CRYPTO_hash (uri->data.ksk.keywords[0], |
116 | strlen (uri->data.ksk.keywords[0]), key); | 119 | strlen (uri->data.ksk.keywords[0]), |
120 | key); | ||
121 | return GNUNET_OK; | ||
122 | } | ||
123 | else | ||
124 | { | ||
125 | memset (key, 0, sizeof (struct GNUNET_HashCode)); | ||
126 | return GNUNET_SYSERR; | ||
127 | } | ||
117 | break; | 128 | break; |
118 | case GNUNET_FS_URI_LOC: | 129 | case GNUNET_FS_URI_LOC: |
119 | GNUNET_CRYPTO_hash (&uri->data.loc.fi, | 130 | GNUNET_CRYPTO_hash (&uri->data.loc.fi, |
120 | sizeof (struct FileIdentifier) + | 131 | sizeof (struct FileIdentifier) + |
121 | sizeof (struct GNUNET_PeerIdentity), | 132 | sizeof (struct GNUNET_PeerIdentity), |
122 | key); | 133 | key); |
123 | break; | 134 | return GNUNET_OK; |
124 | default: | 135 | default: |
125 | memset (key, 0, sizeof (struct GNUNET_HashCode)); | 136 | memset (key, 0, sizeof (struct GNUNET_HashCode)); |
126 | break; | 137 | return GNUNET_SYSERR; |
127 | } | 138 | } |
128 | } | 139 | } |
129 | 140 | ||
diff --git a/src/gns/gnunet-dns2gns.c b/src/gns/gnunet-dns2gns.c index 424677d14..2f0de030d 100644 --- a/src/gns/gnunet-dns2gns.c +++ b/src/gns/gnunet-dns2gns.c | |||
@@ -533,14 +533,21 @@ read_dns4 (void *cls) | |||
533 | } | 533 | } |
534 | { | 534 | { |
535 | char buf[size + 1]; | 535 | char buf[size + 1]; |
536 | ssize_t sret; | ||
536 | 537 | ||
537 | addrlen = sizeof (v4); | 538 | addrlen = sizeof (v4); |
538 | GNUNET_break (size == | 539 | sret = GNUNET_NETWORK_socket_recvfrom (listen_socket4, |
539 | GNUNET_NETWORK_socket_recvfrom (listen_socket4, | 540 | buf, |
540 | buf, | 541 | size + 1, |
541 | size + 1, | 542 | (struct sockaddr *) &v4, |
542 | (struct sockaddr *) &v4, | 543 | &addrlen); |
543 | &addrlen)); | 544 | if (0 > sret) |
545 | { | ||
546 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, | ||
547 | "recvfrom"); | ||
548 | return; | ||
549 | } | ||
550 | GNUNET_break (size == (size_t) sret); | ||
544 | handle_request (listen_socket4, | 551 | handle_request (listen_socket4, |
545 | &v4, | 552 | &v4, |
546 | addrlen, | 553 | addrlen, |
@@ -579,16 +586,26 @@ read_dns6 (void *cls) | |||
579 | } | 586 | } |
580 | { | 587 | { |
581 | char buf[size]; | 588 | char buf[size]; |
589 | ssize_t sret; | ||
582 | 590 | ||
583 | addrlen = sizeof (v6); | 591 | addrlen = sizeof (v6); |
584 | GNUNET_break (size == | 592 | sret = GNUNET_NETWORK_socket_recvfrom (listen_socket6, |
585 | GNUNET_NETWORK_socket_recvfrom (listen_socket6, | 593 | buf, |
586 | buf, | 594 | size, |
587 | size, | 595 | (struct sockaddr *) &v6, |
588 | (struct sockaddr *) &v6, | 596 | &addrlen); |
589 | &addrlen)); | 597 | if (0 > sret) |
590 | handle_request (listen_socket6, &v6, addrlen, | 598 | { |
591 | buf, size); | 599 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, |
600 | "recvfrom"); | ||
601 | return; | ||
602 | } | ||
603 | GNUNET_break (size == (size_t) sret); | ||
604 | handle_request (listen_socket6, | ||
605 | &v6, | ||
606 | addrlen, | ||
607 | buf, | ||
608 | size); | ||
592 | } | 609 | } |
593 | } | 610 | } |
594 | 611 | ||
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h index ac418072e..cbad374b5 100644 --- a/src/include/gnunet_fs_service.h +++ b/src/include/gnunet_fs_service.h | |||
@@ -109,8 +109,9 @@ typedef int | |||
109 | * | 109 | * |
110 | * @param uri uri to convert to a unique key | 110 | * @param uri uri to convert to a unique key |
111 | * @param key wherer to store the unique key | 111 | * @param key wherer to store the unique key |
112 | * @return #GNUNET_OK on success | ||
112 | */ | 113 | */ |
113 | void | 114 | int |
114 | GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri, | 115 | GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri, |
115 | struct GNUNET_HashCode *key); | 116 | struct GNUNET_HashCode *key); |
116 | 117 | ||
diff --git a/src/include/gnunet_network_lib.h b/src/include/gnunet_network_lib.h index 9e692bbbf..2c344749f 100644 --- a/src/include/gnunet_network_lib.h +++ b/src/include/gnunet_network_lib.h | |||
@@ -53,7 +53,7 @@ struct GNUNET_NETWORK_FDSet | |||
53 | { | 53 | { |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * Maximum number of any socket socket descriptor in the set (plus one) | 56 | * Maximum number of any socket descriptor in the set (plus one) |
57 | */ | 57 | */ |
58 | int nsds; | 58 | int nsds; |
59 | 59 | ||
diff --git a/src/nat/gnunet-nat.c b/src/nat/gnunet-nat.c index b3cf2e946..72f343627 100644 --- a/src/nat/gnunet-nat.c +++ b/src/nat/gnunet-nat.c | |||
@@ -377,10 +377,16 @@ run (void *cls, | |||
377 | ls = GNUNET_NETWORK_socket_create (af, | 377 | ls = GNUNET_NETWORK_socket_create (af, |
378 | SOCK_DGRAM, | 378 | SOCK_DGRAM, |
379 | IPPROTO_UDP); | 379 | IPPROTO_UDP); |
380 | if (NULL == ls) | ||
381 | { | ||
382 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | ||
383 | "Failed to create socket\n"); | ||
384 | goto fail_and_shutdown; | ||
385 | } | ||
380 | if (GNUNET_OK != | 386 | if (GNUNET_OK != |
381 | GNUNET_NETWORK_socket_bind (ls, | 387 | GNUNET_NETWORK_socket_bind (ls, |
382 | local_sa, | 388 | local_sa, |
383 | local_len)) | 389 | local_len)) |
384 | { | 390 | { |
385 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 391 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
386 | "Failed to bind to %s: %s\n", | 392 | "Failed to bind to %s: %s\n", |
diff --git a/src/nse/gnunet-nse-profiler.c b/src/nse/gnunet-nse-profiler.c index 4a10022e3..b665812e5 100644 --- a/src/nse/gnunet-nse-profiler.c +++ b/src/nse/gnunet-nse-profiler.c | |||
@@ -374,13 +374,14 @@ nse_disconnect_adapter (void *cls, | |||
374 | */ | 374 | */ |
375 | static int | 375 | static int |
376 | stat_iterator (void *cls, | 376 | stat_iterator (void *cls, |
377 | const char *subsystem, | 377 | const char *subsystem, |
378 | const char *name, | 378 | const char *name, |
379 | uint64_t value, int is_persistent) | 379 | uint64_t value, |
380 | int is_persistent) | ||
380 | { | 381 | { |
381 | char *output_buffer; | 382 | char *output_buffer; |
382 | struct GNUNET_TIME_Absolute now; | 383 | struct GNUNET_TIME_Absolute now; |
383 | size_t size; | 384 | int size; |
384 | unsigned int flag; | 385 | unsigned int flag; |
385 | 386 | ||
386 | GNUNET_assert (NULL != data_file); | 387 | GNUNET_assert (NULL != data_file); |
@@ -390,8 +391,14 @@ stat_iterator (void *cls, | |||
390 | flag = 1; | 391 | flag = 1; |
391 | size = GNUNET_asprintf (&output_buffer, "%llu %llu %u\n", | 392 | size = GNUNET_asprintf (&output_buffer, "%llu %llu %u\n", |
392 | now.abs_value_us / 1000LL / 1000LL, | 393 | now.abs_value_us / 1000LL / 1000LL, |
393 | value, flag); | 394 | value, flag); |
394 | if (size != GNUNET_DISK_file_write (data_file, output_buffer, size)) | 395 | if (0 > size) |
396 | { | ||
397 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Error formatting output buffer.\n"); | ||
398 | GNUNET_free (output_buffer); | ||
399 | return GNUNET_SYSERR; | ||
400 | } | ||
401 | if (size != GNUNET_DISK_file_write (data_file, output_buffer, (size_t) size)) | ||
395 | { | 402 | { |
396 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n"); | 403 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n"); |
397 | GNUNET_free (output_buffer); | 404 | GNUNET_free (output_buffer); |
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c index bdb6e5e0d..6b39149be 100644 --- a/src/peerinfo/gnunet-service-peerinfo.c +++ b/src/peerinfo/gnunet-service-peerinfo.c | |||
@@ -1146,12 +1146,12 @@ handle_hello (void *cls, | |||
1146 | struct GNUNET_SERVICE_Client *client = cls; | 1146 | struct GNUNET_SERVICE_Client *client = cls; |
1147 | struct GNUNET_PeerIdentity pid; | 1147 | struct GNUNET_PeerIdentity pid; |
1148 | 1148 | ||
1149 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1150 | "HELLO message received for peer `%s'\n", | ||
1151 | GNUNET_i2s (&pid)); | ||
1152 | GNUNET_assert (GNUNET_OK == | 1149 | GNUNET_assert (GNUNET_OK == |
1153 | GNUNET_HELLO_get_id (hello, | 1150 | GNUNET_HELLO_get_id (hello, |
1154 | &pid)); | 1151 | &pid)); |
1152 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1153 | "HELLO message received for peer `%s'\n", | ||
1154 | GNUNET_i2s (&pid)); | ||
1155 | add_host_to_known_hosts (&pid); | 1155 | add_host_to_known_hosts (&pid); |
1156 | update_hello (&pid, | 1156 | update_hello (&pid, |
1157 | hello); | 1157 | hello); |
diff --git a/src/psycstore/psycstore_api.c b/src/psycstore/psycstore_api.c index 16f4a1ae9..5a4865dce 100644 --- a/src/psycstore/psycstore_api.c +++ b/src/psycstore/psycstore_api.c | |||
@@ -362,6 +362,9 @@ do_connect (struct GNUNET_PSYCSTORE_Handle *h) | |||
362 | static void | 362 | static void |
363 | reconnect (void *cls) | 363 | reconnect (void *cls) |
364 | { | 364 | { |
365 | struct GNUNET_PSYCSTORE_Handle *h = cls; | ||
366 | |||
367 | h->reconnect_task = NULL; | ||
365 | do_connect (cls); | 368 | do_connect (cls); |
366 | } | 369 | } |
367 | 370 | ||
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index 0114a19fe..2cc1ac62e 100644 --- a/src/rps/test_rps.c +++ b/src/rps/test_rps.c | |||
@@ -62,6 +62,19 @@ static unsigned int mal_type = 0; | |||
62 | */ | 62 | */ |
63 | static struct GNUNET_TESTBED_Peer **testbed_peers; | 63 | static struct GNUNET_TESTBED_Peer **testbed_peers; |
64 | 64 | ||
65 | /** | ||
66 | * @brief Indicates whether peer should go off- or online | ||
67 | */ | ||
68 | enum PEER_ONLINE_DELTA { | ||
69 | /** | ||
70 | * @brief Indicates peer going online | ||
71 | */ | ||
72 | PEER_GO_ONLINE = 1, | ||
73 | /** | ||
74 | * @brief Indicates peer going offline | ||
75 | */ | ||
76 | PEER_GO_OFFLINE = -1, | ||
77 | }; | ||
65 | 78 | ||
66 | /** | 79 | /** |
67 | * Operation map entry | 80 | * Operation map entry |
@@ -84,10 +97,10 @@ struct OpListEntry | |||
84 | struct GNUNET_TESTBED_Operation *op; | 97 | struct GNUNET_TESTBED_Operation *op; |
85 | 98 | ||
86 | /** | 99 | /** |
87 | * Depending on whether we start or stop NSE service at the peer set this to 1 | 100 | * Depending on whether we start or stop RPS service at the peer, set this to |
88 | * or -1 | 101 | * #PEER_GO_ONLINE (1) or #PEER_GO_OFFLINE (-1) |
89 | */ | 102 | */ |
90 | int delta; | 103 | enum PEER_ONLINE_DELTA delta; |
91 | 104 | ||
92 | /** | 105 | /** |
93 | * Index of the regarding peer | 106 | * Index of the regarding peer |
@@ -188,7 +201,7 @@ struct RPSPeer | |||
188 | int online; | 201 | int online; |
189 | 202 | ||
190 | /** | 203 | /** |
191 | * Number of Peer IDs to request | 204 | * Number of Peer IDs to request during the whole test |
192 | */ | 205 | */ |
193 | unsigned int num_ids_to_request; | 206 | unsigned int num_ids_to_request; |
194 | 207 | ||
@@ -218,6 +231,11 @@ struct RPSPeer | |||
218 | * Number of received PeerIDs | 231 | * Number of received PeerIDs |
219 | */ | 232 | */ |
220 | unsigned int num_recv_ids; | 233 | unsigned int num_recv_ids; |
234 | |||
235 | /** | ||
236 | * Pending operation on that peer | ||
237 | */ | ||
238 | const struct OpListEntry *entry_op_manage; | ||
221 | }; | 239 | }; |
222 | 240 | ||
223 | 241 | ||
@@ -259,6 +277,11 @@ static int ok; | |||
259 | /** | 277 | /** |
260 | * Identifier for the churn task that runs periodically | 278 | * Identifier for the churn task that runs periodically |
261 | */ | 279 | */ |
280 | static struct GNUNET_SCHEDULER_Task *shutdown_task; | ||
281 | |||
282 | /** | ||
283 | * Identifier for the churn task that runs periodically | ||
284 | */ | ||
262 | static struct GNUNET_SCHEDULER_Task *churn_task; | 285 | static struct GNUNET_SCHEDULER_Task *churn_task; |
263 | 286 | ||
264 | /** | 287 | /** |
@@ -267,13 +290,21 @@ static struct GNUNET_SCHEDULER_Task *churn_task; | |||
267 | typedef void (*InitPeer) (struct RPSPeer *rps_peer); | 290 | typedef void (*InitPeer) (struct RPSPeer *rps_peer); |
268 | 291 | ||
269 | /** | 292 | /** |
270 | * Called directly after connecting to the service | 293 | * @brief Called directly after connecting to the service |
294 | * | ||
295 | * @param rps_peer Specific peer the function is called on | ||
296 | * @param h the handle to the rps service | ||
271 | */ | 297 | */ |
272 | typedef void (*PreTest) (void *cls, struct GNUNET_RPS_Handle *h); | 298 | typedef void (*PreTest) (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h); |
273 | 299 | ||
274 | /** | 300 | /** |
301 | * @brief Executes functions to test the api/service for a given peer | ||
302 | * | ||
275 | * Called from within #rps_connect_complete_cb () | 303 | * Called from within #rps_connect_complete_cb () |
276 | * Executes functions to test the api/service | 304 | * Implemented by #churn_test_cb, #profiler_cb, #mal_cb, #single_req_cb, |
305 | * #delay_req_cb, #seed_big_cb, #single_peer_seed_cb, #seed_cb, #req_cancel_cb | ||
306 | * | ||
307 | * @param rps_peer the peer the task runs on | ||
277 | */ | 308 | */ |
278 | typedef void (*MainTest) (struct RPSPeer *rps_peer); | 309 | typedef void (*MainTest) (struct RPSPeer *rps_peer); |
279 | 310 | ||
@@ -306,7 +337,7 @@ struct SingleTestRun | |||
306 | char *name; | 337 | char *name; |
307 | 338 | ||
308 | /** | 339 | /** |
309 | * Called to initialise peer | 340 | * Called with a single peer in order to initialise that peer |
310 | */ | 341 | */ |
311 | InitPeer init_peer; | 342 | InitPeer init_peer; |
312 | 343 | ||
@@ -316,7 +347,7 @@ struct SingleTestRun | |||
316 | PreTest pre_test; | 347 | PreTest pre_test; |
317 | 348 | ||
318 | /** | 349 | /** |
319 | * Function to execute the functions to be tested | 350 | * Main function for each peer |
320 | */ | 351 | */ |
321 | MainTest main_test; | 352 | MainTest main_test; |
322 | 353 | ||
@@ -502,6 +533,8 @@ shutdown_op (void *cls) | |||
502 | { | 533 | { |
503 | unsigned int i; | 534 | unsigned int i; |
504 | 535 | ||
536 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
537 | "Shutdown task scheduled, going down.\n"); | ||
505 | in_shutdown = GNUNET_YES; | 538 | in_shutdown = GNUNET_YES; |
506 | if (NULL != churn_task) | 539 | if (NULL != churn_task) |
507 | { | 540 | { |
@@ -583,6 +616,11 @@ info_cb (void *cb_cls, | |||
583 | { | 616 | { |
584 | struct OpListEntry *entry = (struct OpListEntry *) cb_cls; | 617 | struct OpListEntry *entry = (struct OpListEntry *) cb_cls; |
585 | 618 | ||
619 | if (GNUNET_YES == in_shutdown) | ||
620 | { | ||
621 | return; | ||
622 | } | ||
623 | |||
586 | if (NULL == pinfo || NULL != emsg) | 624 | if (NULL == pinfo || NULL != emsg) |
587 | { | 625 | { |
588 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got Error: %s\n", emsg); | 626 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got Error: %s\n", emsg); |
@@ -632,6 +670,11 @@ rps_connect_complete_cb (void *cls, | |||
632 | struct RPSPeer *rps_peer = cls; | 670 | struct RPSPeer *rps_peer = cls; |
633 | struct GNUNET_RPS_Handle *rps = ca_result; | 671 | struct GNUNET_RPS_Handle *rps = ca_result; |
634 | 672 | ||
673 | if (GNUNET_YES == in_shutdown) | ||
674 | { | ||
675 | return; | ||
676 | } | ||
677 | |||
635 | rps_peer->rps_handle = rps; | 678 | rps_peer->rps_handle = rps; |
636 | rps_peer->online = GNUNET_YES; | 679 | rps_peer->online = GNUNET_YES; |
637 | num_peers_online++; | 680 | num_peers_online++; |
@@ -760,7 +803,10 @@ default_reply_handle (void *cls, | |||
760 | 803 | ||
761 | if (0 == evaluate ()) | 804 | if (0 == evaluate ()) |
762 | { | 805 | { |
763 | GNUNET_SCHEDULER_shutdown (); | 806 | GNUNET_assert (NULL != shutdown_task); |
807 | GNUNET_SCHEDULER_cancel (shutdown_task); | ||
808 | shutdown_task = GNUNET_SCHEDULER_add_now (&shutdown_op, NULL); | ||
809 | GNUNET_assert (NULL!= shutdown_task); | ||
764 | } | 810 | } |
765 | } | 811 | } |
766 | 812 | ||
@@ -904,12 +950,20 @@ static void mal_init_peer (struct RPSPeer *rps_peer) | |||
904 | rps_peer->num_ids_to_request = 1; | 950 | rps_peer->num_ids_to_request = 1; |
905 | } | 951 | } |
906 | 952 | ||
953 | |||
954 | /** | ||
955 | * @brief Set peers to (non-)malicious before execution | ||
956 | * | ||
957 | * Of signature #PreTest | ||
958 | * | ||
959 | * @param rps_peer the peer to set (non-) malicious | ||
960 | * @param h the handle to the service | ||
961 | */ | ||
907 | static void | 962 | static void |
908 | mal_pre (void *cls, struct GNUNET_RPS_Handle *h) | 963 | mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) |
909 | { | 964 | { |
910 | #ifdef ENABLE_MALICIOUS | 965 | #ifdef ENABLE_MALICIOUS |
911 | uint32_t num_mal_peers; | 966 | uint32_t num_mal_peers; |
912 | struct RPSPeer *rps_peer = (struct RPSPeer *) cls; | ||
913 | 967 | ||
914 | GNUNET_assert ( (1 >= portion) && | 968 | GNUNET_assert ( (1 >= portion) && |
915 | (0 < portion) ); | 969 | (0 < portion) ); |
@@ -934,6 +988,11 @@ mal_cb (struct RPSPeer *rps_peer) | |||
934 | { | 988 | { |
935 | uint32_t num_mal_peers; | 989 | uint32_t num_mal_peers; |
936 | 990 | ||
991 | if (GNUNET_YES == in_shutdown) | ||
992 | { | ||
993 | return; | ||
994 | } | ||
995 | |||
937 | #ifdef ENABLE_MALICIOUS | 996 | #ifdef ENABLE_MALICIOUS |
938 | GNUNET_assert ( (1 >= portion) && | 997 | GNUNET_assert ( (1 >= portion) && |
939 | (0 < portion) ); | 998 | (0 < portion) ); |
@@ -956,6 +1015,11 @@ mal_cb (struct RPSPeer *rps_peer) | |||
956 | static void | 1015 | static void |
957 | single_req_cb (struct RPSPeer *rps_peer) | 1016 | single_req_cb (struct RPSPeer *rps_peer) |
958 | { | 1017 | { |
1018 | if (GNUNET_YES == in_shutdown) | ||
1019 | { | ||
1020 | return; | ||
1021 | } | ||
1022 | |||
959 | schedule_missing_requests (rps_peer); | 1023 | schedule_missing_requests (rps_peer); |
960 | } | 1024 | } |
961 | 1025 | ||
@@ -965,6 +1029,11 @@ single_req_cb (struct RPSPeer *rps_peer) | |||
965 | static void | 1029 | static void |
966 | delay_req_cb (struct RPSPeer *rps_peer) | 1030 | delay_req_cb (struct RPSPeer *rps_peer) |
967 | { | 1031 | { |
1032 | if (GNUNET_YES == in_shutdown) | ||
1033 | { | ||
1034 | return; | ||
1035 | } | ||
1036 | |||
968 | schedule_missing_requests (rps_peer); | 1037 | schedule_missing_requests (rps_peer); |
969 | } | 1038 | } |
970 | 1039 | ||
@@ -974,6 +1043,11 @@ delay_req_cb (struct RPSPeer *rps_peer) | |||
974 | static void | 1043 | static void |
975 | seed_cb (struct RPSPeer *rps_peer) | 1044 | seed_cb (struct RPSPeer *rps_peer) |
976 | { | 1045 | { |
1046 | if (GNUNET_YES == in_shutdown) | ||
1047 | { | ||
1048 | return; | ||
1049 | } | ||
1050 | |||
977 | GNUNET_SCHEDULER_add_delayed ( | 1051 | GNUNET_SCHEDULER_add_delayed ( |
978 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), | 1052 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), |
979 | seed_peers, rps_peer); | 1053 | seed_peers, rps_peer); |
@@ -985,6 +1059,11 @@ seed_cb (struct RPSPeer *rps_peer) | |||
985 | static void | 1059 | static void |
986 | seed_big_cb (struct RPSPeer *rps_peer) | 1060 | seed_big_cb (struct RPSPeer *rps_peer) |
987 | { | 1061 | { |
1062 | if (GNUNET_YES == in_shutdown) | ||
1063 | { | ||
1064 | return; | ||
1065 | } | ||
1066 | |||
988 | // TODO test seeding > GNUNET_MAX_MESSAGE_SIZE peers | 1067 | // TODO test seeding > GNUNET_MAX_MESSAGE_SIZE peers |
989 | GNUNET_SCHEDULER_add_delayed ( | 1068 | GNUNET_SCHEDULER_add_delayed ( |
990 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), | 1069 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), |
@@ -1006,6 +1085,11 @@ single_peer_seed_cb (struct RPSPeer *rps_peer) | |||
1006 | static void | 1085 | static void |
1007 | seed_req_cb (struct RPSPeer *rps_peer) | 1086 | seed_req_cb (struct RPSPeer *rps_peer) |
1008 | { | 1087 | { |
1088 | if (GNUNET_YES == in_shutdown) | ||
1089 | { | ||
1090 | return; | ||
1091 | } | ||
1092 | |||
1009 | GNUNET_SCHEDULER_add_delayed ( | 1093 | GNUNET_SCHEDULER_add_delayed ( |
1010 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), | 1094 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), |
1011 | seed_peers, rps_peer); | 1095 | seed_peers, rps_peer); |
@@ -1020,6 +1104,11 @@ seed_req_cb (struct RPSPeer *rps_peer) | |||
1020 | static void | 1104 | static void |
1021 | req_cancel_cb (struct RPSPeer *rps_peer) | 1105 | req_cancel_cb (struct RPSPeer *rps_peer) |
1022 | { | 1106 | { |
1107 | if (GNUNET_YES == in_shutdown) | ||
1108 | { | ||
1109 | return; | ||
1110 | } | ||
1111 | |||
1023 | schedule_missing_requests (rps_peer); | 1112 | schedule_missing_requests (rps_peer); |
1024 | GNUNET_SCHEDULER_add_delayed ( | 1113 | GNUNET_SCHEDULER_add_delayed ( |
1025 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 1114 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
@@ -1034,9 +1123,25 @@ req_cancel_cb (struct RPSPeer *rps_peer) | |||
1034 | static void | 1123 | static void |
1035 | churn (void *cls); | 1124 | churn (void *cls); |
1036 | 1125 | ||
1126 | /** | ||
1127 | * @brief Starts churn | ||
1128 | * | ||
1129 | * Has signature of #MainTest | ||
1130 | * | ||
1131 | * This is not implemented too nicely as this is called for each peer, but we | ||
1132 | * only need to call it once. (Yes we check that we only schedule the task | ||
1133 | * once.) | ||
1134 | * | ||
1135 | * @param rps_peer The peer it's called for | ||
1136 | */ | ||
1037 | static void | 1137 | static void |
1038 | churn_test_cb (struct RPSPeer *rps_peer) | 1138 | churn_test_cb (struct RPSPeer *rps_peer) |
1039 | { | 1139 | { |
1140 | if (GNUNET_YES == in_shutdown) | ||
1141 | { | ||
1142 | return; | ||
1143 | } | ||
1144 | |||
1040 | /* Start churn */ | 1145 | /* Start churn */ |
1041 | if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task) | 1146 | if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task) |
1042 | { | 1147 | { |
@@ -1073,6 +1178,11 @@ churn_cb (void *cls, | |||
1073 | // FIXME | 1178 | // FIXME |
1074 | struct OpListEntry *entry = cls; | 1179 | struct OpListEntry *entry = cls; |
1075 | 1180 | ||
1181 | if (GNUNET_YES == in_shutdown) | ||
1182 | { | ||
1183 | return; | ||
1184 | } | ||
1185 | |||
1076 | GNUNET_TESTBED_operation_done (entry->op); | 1186 | GNUNET_TESTBED_operation_done (entry->op); |
1077 | if (NULL != emsg) | 1187 | if (NULL != emsg) |
1078 | { | 1188 | { |
@@ -1084,7 +1194,7 @@ churn_cb (void *cls, | |||
1084 | 1194 | ||
1085 | num_peers_online += entry->delta; | 1195 | num_peers_online += entry->delta; |
1086 | 1196 | ||
1087 | if (0 > entry->delta) | 1197 | if (PEER_GO_OFFLINE == entry->delta) |
1088 | { /* Peer hopefully just went offline */ | 1198 | { /* Peer hopefully just went offline */ |
1089 | if (GNUNET_YES != rps_peers[entry->index].online) | 1199 | if (GNUNET_YES != rps_peers[entry->index].online) |
1090 | { | 1200 | { |
@@ -1102,7 +1212,7 @@ churn_cb (void *cls, | |||
1102 | rps_peers[entry->index].online = GNUNET_NO; | 1212 | rps_peers[entry->index].online = GNUNET_NO; |
1103 | } | 1213 | } |
1104 | 1214 | ||
1105 | else if (0 < entry->delta) | 1215 | else if (PEER_GO_ONLINE < entry->delta) |
1106 | { /* Peer hopefully just went online */ | 1216 | { /* Peer hopefully just went online */ |
1107 | if (GNUNET_NO != rps_peers[entry->index].online) | 1217 | if (GNUNET_NO != rps_peers[entry->index].online) |
1108 | { | 1218 | { |
@@ -1125,20 +1235,44 @@ churn_cb (void *cls, | |||
1125 | } | 1235 | } |
1126 | rps_peers[entry->index].online = GNUNET_YES; | 1236 | rps_peers[entry->index].online = GNUNET_YES; |
1127 | } | 1237 | } |
1238 | else | ||
1239 | { | ||
1240 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1241 | "Invalid value for delta: %i\n", entry->delta); | ||
1242 | GNUNET_break (0); | ||
1243 | } | ||
1128 | 1244 | ||
1129 | GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry); | 1245 | GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry); |
1246 | rps_peers[entry->index].entry_op_manage = NULL; | ||
1130 | GNUNET_free (entry); | 1247 | GNUNET_free (entry); |
1131 | //if (num_peers_in_round[current_round] == peers_running) | 1248 | //if (num_peers_in_round[current_round] == peers_running) |
1132 | // run_round (); | 1249 | // run_round (); |
1133 | } | 1250 | } |
1134 | 1251 | ||
1252 | /** | ||
1253 | * @brief Set the rps-service up or down for a specific peer | ||
1254 | * | ||
1255 | * @param i index of action | ||
1256 | * @param j index of peer | ||
1257 | * @param delta (#PEER_ONLINE_DELTA) down (-1) or up (1) | ||
1258 | * @param prob_go_on_off the probability of the action | ||
1259 | */ | ||
1135 | static void | 1260 | static void |
1136 | manage_service_wrapper (unsigned int i, unsigned int j, int delta, | 1261 | manage_service_wrapper (unsigned int i, unsigned int j, |
1137 | double prob_go_on_off) | 1262 | enum PEER_ONLINE_DELTA delta, |
1263 | double prob_go_on_off) | ||
1138 | { | 1264 | { |
1139 | struct OpListEntry *entry; | 1265 | struct OpListEntry *entry; |
1140 | uint32_t prob; | 1266 | uint32_t prob; |
1141 | 1267 | ||
1268 | GNUNET_assert (GNUNET_YES == rps_peers[j].online); | ||
1269 | |||
1270 | /* make sure that management operation is not already scheduled */ | ||
1271 | if (NULL != rps_peers[j].entry_op_manage) | ||
1272 | { | ||
1273 | return; | ||
1274 | } | ||
1275 | |||
1142 | prob = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 1276 | prob = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
1143 | UINT32_MAX); | 1277 | UINT32_MAX); |
1144 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1278 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1146,15 +1280,19 @@ manage_service_wrapper (unsigned int i, unsigned int j, int delta, | |||
1146 | i, | 1280 | i, |
1147 | j, | 1281 | j, |
1148 | GNUNET_i2s (rps_peers[j].peer_id), | 1282 | GNUNET_i2s (rps_peers[j].peer_id), |
1149 | (0 > delta) ? "online" : "offline"); | 1283 | (PEER_GO_ONLINE == delta) ? "online" : "offline"); |
1150 | if (prob < prob_go_on_off * UINT32_MAX) | 1284 | if (prob < prob_go_on_off * UINT32_MAX) |
1151 | { | 1285 | { |
1152 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1286 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1153 | "%s goes %s\n", | 1287 | "%s goes %s\n", |
1154 | GNUNET_i2s (rps_peers[j].peer_id), | 1288 | GNUNET_i2s (rps_peers[j].peer_id), |
1155 | (0 > delta) ? "offline" : "online"); | 1289 | (PEER_GO_OFFLINE == delta) ? "offline" : "online"); |
1290 | |||
1291 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1292 | "testbed_peers points to %p, peer 0 to %p\n", | ||
1293 | testbed_peers, testbed_peers[0]); | ||
1156 | 1294 | ||
1157 | if (0 > delta) | 1295 | if (PEER_GO_OFFLINE == delta) |
1158 | cancel_pending_req_rep (&rps_peers[j]); | 1296 | cancel_pending_req_rep (&rps_peers[j]); |
1159 | entry = make_oplist_entry (); | 1297 | entry = make_oplist_entry (); |
1160 | entry->delta = delta; | 1298 | entry->delta = delta; |
@@ -1164,8 +1302,9 @@ manage_service_wrapper (unsigned int i, unsigned int j, int delta, | |||
1164 | "rps", | 1302 | "rps", |
1165 | &churn_cb, | 1303 | &churn_cb, |
1166 | entry, | 1304 | entry, |
1167 | (0 > delta) ? 0 : 1); | 1305 | (PEER_GO_OFFLINE == delta) ? 0 : 1); |
1168 | } | 1306 | } |
1307 | rps_peers[j].entry_op_manage = entry; | ||
1169 | } | 1308 | } |
1170 | 1309 | ||
1171 | 1310 | ||
@@ -1180,9 +1319,15 @@ churn (void *cls) | |||
1180 | double portion_go_online; | 1319 | double portion_go_online; |
1181 | double portion_go_offline; | 1320 | double portion_go_offline; |
1182 | 1321 | ||
1322 | if (GNUNET_YES == in_shutdown) | ||
1323 | { | ||
1324 | return; | ||
1325 | } | ||
1183 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1326 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1184 | "Churn function executing\n"); | 1327 | "Churn function executing\n"); |
1185 | 1328 | ||
1329 | churn_task = NULL; /* Should be invalid by now */ | ||
1330 | |||
1186 | /* Compute the probability for an online peer to go offline | 1331 | /* Compute the probability for an online peer to go offline |
1187 | * this round */ | 1332 | * this round */ |
1188 | portion_online = num_peers_online * 1.0 / num_peers; | 1333 | portion_online = num_peers_online * 1.0 / num_peers; |
@@ -1290,6 +1435,11 @@ profiler_reply_handle (void *cls, | |||
1290 | static void | 1435 | static void |
1291 | profiler_cb (struct RPSPeer *rps_peer) | 1436 | profiler_cb (struct RPSPeer *rps_peer) |
1292 | { | 1437 | { |
1438 | if (GNUNET_YES == in_shutdown) | ||
1439 | { | ||
1440 | return; | ||
1441 | } | ||
1442 | |||
1293 | /* Start churn */ | 1443 | /* Start churn */ |
1294 | if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task) | 1444 | if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task) |
1295 | { | 1445 | { |
@@ -1426,6 +1576,7 @@ run (void *cls, | |||
1426 | entry); | 1576 | entry); |
1427 | } | 1577 | } |
1428 | 1578 | ||
1579 | /* Bring peers up */ | ||
1429 | num_mal_peers = round (portion * num_peers); | 1580 | num_mal_peers = round (portion * num_peers); |
1430 | GNUNET_assert (num_peers == n_peers); | 1581 | GNUNET_assert (num_peers == n_peers); |
1431 | for (i = 0; i < n_peers; i++) | 1582 | for (i = 0; i < n_peers; i++) |
@@ -1448,7 +1599,7 @@ run (void *cls, | |||
1448 | 1599 | ||
1449 | if (NULL != churn_task) | 1600 | if (NULL != churn_task) |
1450 | GNUNET_SCHEDULER_cancel (churn_task); | 1601 | GNUNET_SCHEDULER_cancel (churn_task); |
1451 | GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL); | 1602 | shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL); |
1452 | } | 1603 | } |
1453 | 1604 | ||
1454 | 1605 | ||
@@ -1609,14 +1760,21 @@ main (int argc, char *argv[]) | |||
1609 | with the malicious portion */ | 1760 | with the malicious portion */ |
1610 | 1761 | ||
1611 | ok = 1; | 1762 | ok = 1; |
1612 | (void) GNUNET_TESTBED_test_run (cur_test_run.name, | 1763 | ret_value = GNUNET_TESTBED_test_run (cur_test_run.name, |
1613 | "test_rps.conf", | 1764 | "test_rps.conf", |
1614 | num_peers, | 1765 | num_peers, |
1615 | 0, NULL, NULL, | 1766 | 0, NULL, NULL, |
1616 | &run, NULL); | 1767 | &run, NULL); |
1768 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1769 | "_test_run returned.\n"); | ||
1770 | if (GNUNET_OK != ret_value) | ||
1771 | { | ||
1772 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1773 | "Test did not run successfully!\n"); | ||
1774 | } | ||
1617 | 1775 | ||
1618 | ret_value = cur_test_run.eval_cb(); | 1776 | ret_value = cur_test_run.eval_cb(); |
1619 | GNUNET_free (rps_peers ); | 1777 | GNUNET_free (rps_peers); |
1620 | GNUNET_free (rps_peer_ids); | 1778 | GNUNET_free (rps_peer_ids); |
1621 | GNUNET_CONTAINER_multipeermap_destroy (peer_map); | 1779 | GNUNET_CONTAINER_multipeermap_destroy (peer_map); |
1622 | return ret_value; | 1780 | return ret_value; |
diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c index 9586dcf27..219cc6235 100644 --- a/src/set/gnunet-service-set_union.c +++ b/src/set/gnunet-service-set_union.c | |||
@@ -389,10 +389,11 @@ get_ibf_key (const struct GNUNET_HashCode *src) | |||
389 | struct IBF_Key key; | 389 | struct IBF_Key key; |
390 | uint16_t salt = 0; | 390 | uint16_t salt = 0; |
391 | 391 | ||
392 | GNUNET_CRYPTO_kdf (&key, sizeof (key), | 392 | GNUNET_assert (GNUNET_OK == |
393 | src, sizeof *src, | 393 | GNUNET_CRYPTO_kdf (&key, sizeof (key), |
394 | &salt, sizeof (salt), | 394 | src, sizeof *src, |
395 | NULL, 0); | 395 | &salt, sizeof (salt), |
396 | NULL, 0)); | ||
396 | return key; | 397 | return key; |
397 | } | 398 | } |
398 | 399 | ||
diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c index 5b2a8ba9b..31e3a3dc2 100644 --- a/src/social/gnunet-service-social.c +++ b/src/social/gnunet-service-social.c | |||
@@ -503,17 +503,18 @@ cleanup_guest (struct Guest *gst) | |||
503 | struct GNUNET_CONTAINER_MultiHashMap * | 503 | struct GNUNET_CONTAINER_MultiHashMap * |
504 | plc_gst = GNUNET_CONTAINER_multihashmap_get (place_guests, | 504 | plc_gst = GNUNET_CONTAINER_multihashmap_get (place_guests, |
505 | &plc->pub_key_hash); | 505 | &plc->pub_key_hash); |
506 | GNUNET_assert (NULL != plc_gst); | 506 | if (NULL != plc_gst) |
507 | GNUNET_CONTAINER_multihashmap_remove (plc_gst, &plc->ego_pub_hash, gst); | ||
508 | |||
509 | if (0 == GNUNET_CONTAINER_multihashmap_size (plc_gst)) | ||
510 | { | 507 | { |
511 | GNUNET_CONTAINER_multihashmap_remove (place_guests, &plc->pub_key_hash, | 508 | GNUNET_CONTAINER_multihashmap_remove (plc_gst, &plc->ego_pub_hash, gst); |
512 | plc_gst); | 509 | |
513 | GNUNET_CONTAINER_multihashmap_destroy (plc_gst); | 510 | if (0 == GNUNET_CONTAINER_multihashmap_size (plc_gst)) |
511 | { | ||
512 | GNUNET_CONTAINER_multihashmap_remove (place_guests, &plc->pub_key_hash, | ||
513 | plc_gst); | ||
514 | GNUNET_CONTAINER_multihashmap_destroy (plc_gst); | ||
515 | } | ||
514 | } | 516 | } |
515 | GNUNET_CONTAINER_multihashmap_remove (guests, &plc->pub_key_hash, gst); | 517 | GNUNET_CONTAINER_multihashmap_remove (guests, &plc->pub_key_hash, gst); |
516 | |||
517 | if (NULL != gst->join_req) | 518 | if (NULL != gst->join_req) |
518 | GNUNET_free (gst->join_req); | 519 | GNUNET_free (gst->join_req); |
519 | if (NULL != gst->relays) | 520 | if (NULL != gst->relays) |
@@ -1391,19 +1392,27 @@ msg_proc_parse (const struct MsgProcRequest *mpreq, | |||
1391 | const char **method_prefix, | 1392 | const char **method_prefix, |
1392 | struct GNUNET_HashCode *method_hash) | 1393 | struct GNUNET_HashCode *method_hash) |
1393 | { | 1394 | { |
1394 | uint8_t method_size = ntohs (mpreq->header.size) - sizeof (*mpreq); | 1395 | ssize_t method_size = ntohs (mpreq->header.size) - sizeof (*mpreq); |
1395 | uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &mpreq[1], | 1396 | uint16_t offset; |
1396 | method_size, 1, method_prefix); | ||
1397 | 1397 | ||
1398 | if (0 == offset || offset != method_size || *method_prefix == NULL) | 1398 | if (method_size < 0) |
1399 | { | 1399 | { |
1400 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1400 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1401 | "offset = %u, method_size = %u, method_name = %s\n", | 1401 | "MsgProcRequest has invalid size\n"); |
1402 | offset, method_size, *method_prefix); | ||
1403 | return GNUNET_SYSERR; | 1402 | return GNUNET_SYSERR; |
1404 | } | 1403 | } |
1405 | 1404 | ||
1406 | GNUNET_CRYPTO_hash (*method_prefix, method_size, method_hash); | 1405 | offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &mpreq[1], |
1406 | method_size, | ||
1407 | 1, | ||
1408 | method_prefix); | ||
1409 | if (0 == offset || offset != method_size || *method_prefix == NULL) | ||
1410 | { | ||
1411 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1412 | "MsgProcRequest contains invalid method\n"); | ||
1413 | return GNUNET_SYSERR; | ||
1414 | } | ||
1415 | GNUNET_CRYPTO_hash (*method_prefix, (size_t) method_size, method_hash); | ||
1407 | *flags = ntohl (mpreq->flags); | 1416 | *flags = ntohl (mpreq->flags); |
1408 | return GNUNET_OK; | 1417 | return GNUNET_OK; |
1409 | } | 1418 | } |
@@ -1755,6 +1764,7 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) | |||
1755 | struct GNUNET_CONTAINER_MultiHashMap * | 1764 | struct GNUNET_CONTAINER_MultiHashMap * |
1756 | plc_gst = GNUNET_CONTAINER_multihashmap_get (place_guests, &place_pub_hash); | 1765 | plc_gst = GNUNET_CONTAINER_multihashmap_get (place_guests, &place_pub_hash); |
1757 | struct Guest *gst = NULL; | 1766 | struct Guest *gst = NULL; |
1767 | int new_guest; | ||
1758 | 1768 | ||
1759 | if (NULL != plc_gst) | 1769 | if (NULL != plc_gst) |
1760 | gst = GNUNET_CONTAINER_multihashmap_get (plc_gst, &ego_pub_hash); | 1770 | gst = GNUNET_CONTAINER_multihashmap_get (plc_gst, &ego_pub_hash); |
@@ -1763,9 +1773,12 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) | |||
1763 | "plc_gst = %p, gst = %p\n", | 1773 | "plc_gst = %p, gst = %p\n", |
1764 | plc_gst, | 1774 | plc_gst, |
1765 | gst); | 1775 | gst); |
1776 | |||
1777 | new_guest = GNUNET_NO; | ||
1766 | if (NULL == gst) | 1778 | if (NULL == gst) |
1767 | { | 1779 | { |
1768 | gst = GNUNET_new (struct Guest); | 1780 | gst = GNUNET_new (struct Guest); |
1781 | new_guest = GNUNET_YES; | ||
1769 | } | 1782 | } |
1770 | if (NULL == gst->slave) | 1783 | if (NULL == gst->slave) |
1771 | { | 1784 | { |
@@ -1841,6 +1854,9 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) | |||
1841 | plc_gst = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); | 1854 | plc_gst = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); |
1842 | (void) GNUNET_CONTAINER_multihashmap_put (place_guests, &plc->pub_key_hash, plc_gst, | 1855 | (void) GNUNET_CONTAINER_multihashmap_put (place_guests, &plc->pub_key_hash, plc_gst, |
1843 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 1856 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); |
1857 | } | ||
1858 | if (GNUNET_YES == new_guest) | ||
1859 | { | ||
1844 | (void) GNUNET_CONTAINER_multihashmap_put (plc_gst, &plc->ego_pub_hash, gst, | 1860 | (void) GNUNET_CONTAINER_multihashmap_put (plc_gst, &plc->ego_pub_hash, gst, |
1845 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 1861 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); |
1846 | (void) GNUNET_CONTAINER_multihashmap_put (guests, &plc->pub_key_hash, gst, | 1862 | (void) GNUNET_CONTAINER_multihashmap_put (guests, &plc->pub_key_hash, gst, |
@@ -1862,6 +1878,7 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) | |||
1862 | ret = GNUNET_YES; | 1878 | ret = GNUNET_YES; |
1863 | } | 1879 | } |
1864 | 1880 | ||
1881 | // TODO: explain why free(gst) not necessary | ||
1865 | if (NULL != ret_gst) | 1882 | if (NULL != ret_gst) |
1866 | *ret_gst = gst; | 1883 | *ret_gst = gst; |
1867 | return ret; | 1884 | return ret; |
@@ -2134,20 +2151,34 @@ handle_client_app_connect (void *cls, | |||
2134 | { | 2151 | { |
2135 | struct Client *c = cls; | 2152 | struct Client *c = cls; |
2136 | struct GNUNET_SERVICE_Client *client = c->client; | 2153 | struct GNUNET_SERVICE_Client *client = c->client; |
2137 | 2154 | ssize_t app_id_size = ntohs (creq->header.size) - sizeof (*creq); | |
2138 | uint8_t app_id_size = ntohs (creq->header.size) - sizeof (*creq); | ||
2139 | const char *app_id = NULL; | 2155 | const char *app_id = NULL; |
2140 | uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &creq[1], | 2156 | uint16_t offset; |
2141 | app_id_size, 1, &app_id); | 2157 | |
2158 | if (app_id_size < 0) | ||
2159 | { | ||
2160 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2161 | "AppConnectRequest has invalid size\n"); | ||
2162 | GNUNET_break (0); | ||
2163 | GNUNET_SERVICE_client_drop (client); | ||
2164 | return; | ||
2165 | } | ||
2166 | |||
2167 | offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &creq[1], | ||
2168 | (size_t) app_id_size, | ||
2169 | 1, | ||
2170 | &app_id); | ||
2142 | if (0 == offset || offset != app_id_size) | 2171 | if (0 == offset || offset != app_id_size) |
2143 | { | 2172 | { |
2173 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2174 | "AppConnectRequest contains invalid app ID\n"); | ||
2144 | GNUNET_break (0); | 2175 | GNUNET_break (0); |
2145 | GNUNET_SERVICE_client_drop (client); | 2176 | GNUNET_SERVICE_client_drop (client); |
2146 | return; | 2177 | return; |
2147 | } | 2178 | } |
2148 | 2179 | ||
2149 | struct GNUNET_HashCode app_id_hash; | 2180 | struct GNUNET_HashCode app_id_hash; |
2150 | GNUNET_CRYPTO_hash (app_id, app_id_size, &app_id_hash); | 2181 | GNUNET_CRYPTO_hash (app_id, (size_t) app_id_size, &app_id_hash); |
2151 | 2182 | ||
2152 | GNUNET_CONTAINER_multihashmap_iterate (egos, ego_entry, client); | 2183 | GNUNET_CONTAINER_multihashmap_iterate (egos, ego_entry, client); |
2153 | app_notify_ego_end (client); | 2184 | app_notify_ego_end (client); |
@@ -2172,8 +2203,8 @@ handle_client_app_connect (void *cls, | |||
2172 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2203 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2173 | "%p Application %s connected.\n", app, app_id); | 2204 | "%p Application %s connected.\n", app, app_id); |
2174 | 2205 | ||
2175 | c->app_id = GNUNET_malloc (app_id_size); | 2206 | c->app_id = GNUNET_malloc ((size_t) app_id_size); |
2176 | GNUNET_memcpy (c->app_id, app_id, app_id_size); | 2207 | GNUNET_memcpy (c->app_id, app_id, (size_t) app_id_size); |
2177 | 2208 | ||
2178 | GNUNET_SERVICE_client_continue (client); | 2209 | GNUNET_SERVICE_client_continue (client); |
2179 | } | 2210 | } |
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 8d3e47f94..2bf07bcd7 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -1137,9 +1137,9 @@ disconnect_neighbour (struct NeighbourMapEntry *n) | |||
1137 | * our own receive rate and informs the neighbour about | 1137 | * our own receive rate and informs the neighbour about |
1138 | * the new quota. | 1138 | * the new quota. |
1139 | * | 1139 | * |
1140 | * @param n neighbour entry to change qutoa for | 1140 | * @param n neighbour entry to change quota for |
1141 | * @param quota new quota | 1141 | * @param quota new quota |
1142 | * @return #GNUNET_YES if @a n is still valid, @GNUNET_NO if | 1142 | * @return #GNUNET_YES if @a n is still valid, #GNUNET_NO if |
1143 | * @a n was freed | 1143 | * @a n was freed |
1144 | */ | 1144 | */ |
1145 | static int | 1145 | static int |
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index c5d6e6d34..8b00543c3 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c | |||
@@ -3351,9 +3351,10 @@ handle_tcp_data (void *cls, | |||
3351 | void *vaddr = NULL; | 3351 | void *vaddr = NULL; |
3352 | size_t alen; | 3352 | size_t alen; |
3353 | 3353 | ||
3354 | GNUNET_SERVER_client_get_address (client, | 3354 | GNUNET_assert (GNUNET_OK == |
3355 | &vaddr, | 3355 | GNUNET_SERVER_client_get_address (client, |
3356 | &alen); | 3356 | &vaddr, |
3357 | &alen)); | ||
3357 | LOG (GNUNET_ERROR_TYPE_ERROR, | 3358 | LOG (GNUNET_ERROR_TYPE_ERROR, |
3358 | "Received unexpected %u bytes of type %u from `%s'\n", | 3359 | "Received unexpected %u bytes of type %u from `%s'\n", |
3359 | (unsigned int) ntohs (message->size), | 3360 | (unsigned int) ntohs (message->size), |
diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c index be2538c3f..1c55d72b5 100644 --- a/src/util/common_allocation.c +++ b/src/util/common_allocation.c | |||
@@ -475,8 +475,8 @@ GNUNET_xgrow_ (void **old, | |||
475 | */ | 475 | */ |
476 | int | 476 | int |
477 | GNUNET_asprintf (char **buf, | 477 | GNUNET_asprintf (char **buf, |
478 | const char *format, | 478 | const char *format, |
479 | ...) | 479 | ...) |
480 | { | 480 | { |
481 | int ret; | 481 | int ret; |
482 | va_list args; | 482 | va_list args; |
@@ -484,6 +484,7 @@ GNUNET_asprintf (char **buf, | |||
484 | va_start (args, format); | 484 | va_start (args, format); |
485 | ret = VSNPRINTF (NULL, 0, format, args); | 485 | ret = VSNPRINTF (NULL, 0, format, args); |
486 | va_end (args); | 486 | va_end (args); |
487 | GNUNET_assert (ret >= 0); | ||
487 | *buf = GNUNET_malloc (ret + 1); | 488 | *buf = GNUNET_malloc (ret + 1); |
488 | va_start (args, format); | 489 | va_start (args, format); |
489 | ret = VSPRINTF (*buf, format, args); | 490 | ret = VSPRINTF (*buf, format, args); |
diff --git a/src/util/configuration.c b/src/util/configuration.c index 7f1d98902..25eeaf80f 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c | |||
@@ -421,7 +421,6 @@ GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
421 | size_t m_size; | 421 | size_t m_size; |
422 | size_t c_size; | 422 | size_t c_size; |
423 | 423 | ||
424 | |||
425 | /* Pass1 : calculate the buffer size required */ | 424 | /* Pass1 : calculate the buffer size required */ |
426 | m_size = 0; | 425 | m_size = 0; |
427 | for (sec = cfg->sections; NULL != sec; sec = sec->next) | 426 | for (sec = cfg->sections; NULL != sec; sec = sec->next) |
diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c index 20c7ca7ff..cce9cf82a 100644 --- a/src/util/crypto_hash.c +++ b/src/util/crypto_hash.c | |||
@@ -69,9 +69,9 @@ GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block, | |||
69 | char *np; | 69 | char *np; |
70 | 70 | ||
71 | np = GNUNET_STRINGS_data_to_string ((const unsigned char *) block, | 71 | np = GNUNET_STRINGS_data_to_string ((const unsigned char *) block, |
72 | sizeof (struct GNUNET_HashCode), | 72 | sizeof (struct GNUNET_HashCode), |
73 | (char*) result, | 73 | (char *) result, |
74 | sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1); | 74 | sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1); |
75 | GNUNET_assert (NULL != np); | 75 | GNUNET_assert (NULL != np); |
76 | *np = '\0'; | 76 | *np = '\0'; |
77 | } | 77 | } |
diff --git a/src/util/network.c b/src/util/network.c index 973878f93..0cb1529a6 100644 --- a/src/util/network.c +++ b/src/util/network.c | |||
@@ -91,8 +91,8 @@ GNUNET_NETWORK_test_pf (int pf) | |||
91 | if (EAFNOSUPPORT == errno) | 91 | if (EAFNOSUPPORT == errno) |
92 | return GNUNET_NO; | 92 | return GNUNET_NO; |
93 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 93 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
94 | "Failed to create test socket: %s\n", | 94 | "Failed to create test socket: %s\n", |
95 | STRERROR (errno)); | 95 | STRERROR (errno)); |
96 | return GNUNET_SYSERR; | 96 | return GNUNET_SYSERR; |
97 | } | 97 | } |
98 | #if WINDOWS | 98 | #if WINDOWS |
@@ -128,21 +128,20 @@ GNUNET_NETWORK_shorten_unixpath (char *unixpath) | |||
128 | if (slen < upm) | 128 | if (slen < upm) |
129 | return unixpath; /* no shortening required */ | 129 | return unixpath; /* no shortening required */ |
130 | GNUNET_CRYPTO_hash (unixpath, slen, &sh); | 130 | GNUNET_CRYPTO_hash (unixpath, slen, &sh); |
131 | while (16 + | 131 | while (16 + strlen (unixpath) >= upm) |
132 | strlen (unixpath) >= upm) | ||
133 | { | 132 | { |
134 | if (NULL == (end = strrchr (unixpath, '/'))) | 133 | if (NULL == (end = strrchr (unixpath, '/'))) |
135 | { | 134 | { |
136 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 135 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
137 | _("Unable to shorten unix path `%s' while keeping name unique\n"), | 136 | _("Unable to shorten unix path `%s' while keeping name unique\n"), |
138 | unixpath); | 137 | unixpath); |
139 | GNUNET_free (unixpath); | 138 | GNUNET_free (unixpath); |
140 | return NULL; | 139 | return NULL; |
141 | } | 140 | } |
142 | *end = '\0'; | 141 | *end = '\0'; |
143 | } | 142 | } |
144 | GNUNET_CRYPTO_hash_to_enc (&sh, &ae); | 143 | GNUNET_CRYPTO_hash_to_enc (&sh, &ae); |
145 | strncat (unixpath, (char*) ae.encoding, 16); | 144 | strncat (unixpath, (char *) ae.encoding, 16); |
146 | return unixpath; | 145 | return unixpath; |
147 | } | 146 | } |
148 | 147 | ||
@@ -239,7 +238,6 @@ GNUNET_NETWORK_socket_set_blocking (struct GNUNET_NETWORK_Handle *fd, | |||
239 | int flags = fcntl (fd->fd, F_GETFL); | 238 | int flags = fcntl (fd->fd, F_GETFL); |
240 | 239 | ||
241 | if (flags == -1) | 240 | if (flags == -1) |
242 | |||
243 | { | 241 | { |
244 | LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, | 242 | LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, |
245 | "fcntl"); | 243 | "fcntl"); |
@@ -311,7 +309,7 @@ socket_set_nosigpipe (const struct GNUNET_NETWORK_Handle *h) | |||
311 | 309 | ||
312 | if (0 != | 310 | if (0 != |
313 | setsockopt (h->fd, SOL_SOCKET, SO_NOSIGPIPE, | 311 | setsockopt (h->fd, SOL_SOCKET, SO_NOSIGPIPE, |
314 | (const void *) &abs_value, | 312 | (const void *) &abs_value, |
315 | sizeof (abs_value))) | 313 | sizeof (abs_value))) |
316 | LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "setsockopt"); | 314 | LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "setsockopt"); |
317 | } | 315 | } |
@@ -342,8 +340,10 @@ socket_set_nodelay (const struct GNUNET_NETWORK_Handle *h) | |||
342 | const char *abs_value = "1"; | 340 | const char *abs_value = "1"; |
343 | 341 | ||
344 | if (0 != | 342 | if (0 != |
345 | setsockopt (h->fd, IPPROTO_TCP, TCP_NODELAY, | 343 | setsockopt (h->fd, |
346 | (const void *) abs_value, | 344 | IPPROTO_TCP, |
345 | TCP_NODELAY, | ||
346 | (const void *) abs_value, | ||
347 | sizeof (abs_value))) | 347 | sizeof (abs_value))) |
348 | LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, | 348 | LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, |
349 | "setsockopt"); | 349 | "setsockopt"); |
@@ -365,7 +365,7 @@ socket_set_nodelay (const struct GNUNET_NETWORK_Handle *h) | |||
365 | */ | 365 | */ |
366 | static int | 366 | static int |
367 | initialize_network_handle (struct GNUNET_NETWORK_Handle *h, | 367 | initialize_network_handle (struct GNUNET_NETWORK_Handle *h, |
368 | int af, | 368 | int af, |
369 | int type) | 369 | int type) |
370 | { | 370 | { |
371 | int eno; | 371 | int eno; |
@@ -409,7 +409,7 @@ initialize_network_handle (struct GNUNET_NETWORK_Handle *h, | |||
409 | #ifdef AF_UNIX | 409 | #ifdef AF_UNIX |
410 | && (af != AF_UNIX) | 410 | && (af != AF_UNIX) |
411 | #endif | 411 | #endif |
412 | ) | 412 | ) |
413 | socket_set_nodelay (h); | 413 | socket_set_nodelay (h); |
414 | return GNUNET_OK; | 414 | return GNUNET_OK; |
415 | } | 415 | } |
@@ -426,7 +426,7 @@ initialize_network_handle (struct GNUNET_NETWORK_Handle *h, | |||
426 | struct GNUNET_NETWORK_Handle * | 426 | struct GNUNET_NETWORK_Handle * |
427 | GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc, | 427 | GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc, |
428 | struct sockaddr *address, | 428 | struct sockaddr *address, |
429 | socklen_t *address_len) | 429 | socklen_t *address_len) |
430 | { | 430 | { |
431 | struct GNUNET_NETWORK_Handle *ret; | 431 | struct GNUNET_NETWORK_Handle *ret; |
432 | int eno; | 432 | int eno; |
@@ -443,7 +443,7 @@ GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc, | |||
443 | 443 | ||
444 | if (0 == gsn) | 444 | if (0 == gsn) |
445 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 445 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
446 | "Accepting connection on `%s'\n", | 446 | "Accepting connection on `%s'\n", |
447 | GNUNET_a2s ((const struct sockaddr *) &name, | 447 | GNUNET_a2s ((const struct sockaddr *) &name, |
448 | namelen)); | 448 | namelen)); |
449 | } | 449 | } |
@@ -491,9 +491,11 @@ GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc, | |||
491 | const int on = 1; | 491 | const int on = 1; |
492 | 492 | ||
493 | if (AF_INET6 == desc->af) | 493 | if (AF_INET6 == desc->af) |
494 | if (setsockopt (desc->fd, IPPROTO_IPV6, IPV6_V6ONLY, | 494 | if (setsockopt (desc->fd, |
495 | (const void *) &on, | 495 | IPPROTO_IPV6, |
496 | sizeof (on))) | 496 | IPV6_V6ONLY, |
497 | (const void *) &on, | ||
498 | sizeof (on))) | ||
497 | LOG_STRERROR (GNUNET_ERROR_TYPE_DEBUG, | 499 | LOG_STRERROR (GNUNET_ERROR_TYPE_DEBUG, |
498 | "setsockopt"); | 500 | "setsockopt"); |
499 | } | 501 | } |
@@ -593,8 +595,8 @@ GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc) | |||
593 | if (0 != unlink (dirname)) | 595 | if (0 != unlink (dirname)) |
594 | { | 596 | { |
595 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, | 597 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, |
596 | "unlink", | 598 | "unlink", |
597 | dirname); | 599 | dirname); |
598 | } | 600 | } |
599 | else | 601 | else |
600 | { | 602 | { |
@@ -1209,8 +1211,8 @@ GNUNET_NETWORK_fdset_copy (struct GNUNET_NETWORK_FDSet *to, | |||
1209 | to->handles_size, | 1211 | to->handles_size, |
1210 | from->handles_pos * 2); | 1212 | from->handles_pos * 2); |
1211 | GNUNET_memcpy (to->handles, | 1213 | GNUNET_memcpy (to->handles, |
1212 | from->handles, | 1214 | from->handles, |
1213 | from->handles_pos * sizeof (struct GNUNET_NETWORK_Handle *)); | 1215 | from->handles_pos * sizeof (struct GNUNET_NETWORK_Handle *)); |
1214 | to->handles_pos = from->handles_pos; | 1216 | to->handles_pos = from->handles_pos; |
1215 | #endif | 1217 | #endif |
1216 | } | 1218 | } |
@@ -1327,9 +1329,9 @@ GNUNET_NETWORK_fdset_handle_set (struct GNUNET_NETWORK_FDSet *fds, | |||
1327 | int fd; | 1329 | int fd; |
1328 | 1330 | ||
1329 | GNUNET_assert (GNUNET_OK == | 1331 | GNUNET_assert (GNUNET_OK == |
1330 | GNUNET_DISK_internal_file_handle_ (h, | 1332 | GNUNET_DISK_internal_file_handle_ (h, |
1331 | &fd, | 1333 | &fd, |
1332 | sizeof (int))); | 1334 | sizeof (int))); |
1333 | FD_SET (fd, | 1335 | FD_SET (fd, |
1334 | &fds->sds); | 1336 | &fds->sds); |
1335 | fds->nsds = GNUNET_MAX (fd + 1, | 1337 | fds->nsds = GNUNET_MAX (fd + 1, |
@@ -1707,7 +1709,7 @@ initialize_select_thread () | |||
1707 | */ | 1709 | */ |
1708 | int | 1710 | int |
1709 | GNUNET_NETWORK_test_port_free (int ipproto, | 1711 | GNUNET_NETWORK_test_port_free (int ipproto, |
1710 | uint16_t port) | 1712 | uint16_t port) |
1711 | { | 1713 | { |
1712 | struct GNUNET_NETWORK_Handle *socket; | 1714 | struct GNUNET_NETWORK_Handle *socket; |
1713 | int bind_status; | 1715 | int bind_status; |
@@ -1718,37 +1720,35 @@ GNUNET_NETWORK_test_port_free (int ipproto, | |||
1718 | struct addrinfo *ai; | 1720 | struct addrinfo *ai; |
1719 | 1721 | ||
1720 | GNUNET_snprintf (open_port_str, | 1722 | GNUNET_snprintf (open_port_str, |
1721 | sizeof (open_port_str), | 1723 | sizeof (open_port_str), |
1722 | "%u", | 1724 | "%u", |
1723 | (unsigned int) port); | 1725 | (unsigned int) port); |
1724 | socktype = (IPPROTO_TCP == ipproto) | 1726 | socktype = (IPPROTO_TCP == ipproto) ? SOCK_STREAM : SOCK_DGRAM; |
1725 | ? SOCK_STREAM | ||
1726 | : SOCK_DGRAM; | ||
1727 | ret = NULL; | 1727 | ret = NULL; |
1728 | memset (&hint, 0, sizeof (hint)); | 1728 | memset (&hint, 0, sizeof (hint)); |
1729 | hint.ai_family = AF_UNSPEC; /* IPv4 and IPv6 */ | 1729 | hint.ai_family = AF_UNSPEC; /* IPv4 and IPv6 */ |
1730 | hint.ai_socktype = socktype; | 1730 | hint.ai_socktype = socktype; |
1731 | hint.ai_protocol = ipproto; | 1731 | hint.ai_protocol = ipproto; |
1732 | hint.ai_addrlen = 0; | 1732 | hint.ai_addrlen = 0; |
1733 | hint.ai_addr = NULL; | 1733 | hint.ai_addr = NULL; |
1734 | hint.ai_canonname = NULL; | 1734 | hint.ai_canonname = NULL; |
1735 | hint.ai_next = NULL; | 1735 | hint.ai_next = NULL; |
1736 | hint.ai_flags = AI_PASSIVE | AI_NUMERICSERV; /* Wild card address */ | 1736 | hint.ai_flags = AI_PASSIVE | AI_NUMERICSERV; /* Wild card address */ |
1737 | GNUNET_assert (0 == getaddrinfo (NULL, | 1737 | GNUNET_assert (0 == getaddrinfo (NULL, |
1738 | open_port_str, | 1738 | open_port_str, |
1739 | &hint, | 1739 | &hint, |
1740 | &ret)); | 1740 | &ret)); |
1741 | bind_status = GNUNET_NO; | 1741 | bind_status = GNUNET_NO; |
1742 | for (ai = ret; NULL != ai; ai = ai->ai_next) | 1742 | for (ai = ret; NULL != ai; ai = ai->ai_next) |
1743 | { | 1743 | { |
1744 | socket = GNUNET_NETWORK_socket_create (ai->ai_family, | 1744 | socket = GNUNET_NETWORK_socket_create (ai->ai_family, |
1745 | ai->ai_socktype, | 1745 | ai->ai_socktype, |
1746 | ai->ai_protocol); | 1746 | ai->ai_protocol); |
1747 | if (NULL == socket) | 1747 | if (NULL == socket) |
1748 | continue; | 1748 | continue; |
1749 | bind_status = GNUNET_NETWORK_socket_bind (socket, | 1749 | bind_status = GNUNET_NETWORK_socket_bind (socket, |
1750 | ai->ai_addr, | 1750 | ai->ai_addr, |
1751 | ai->ai_addrlen); | 1751 | ai->ai_addrlen); |
1752 | GNUNET_NETWORK_socket_close (socket); | 1752 | GNUNET_NETWORK_socket_close (socket); |
1753 | if (GNUNET_OK != bind_status) | 1753 | if (GNUNET_OK != bind_status) |
1754 | break; | 1754 | break; |
@@ -1808,7 +1808,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1808 | (tv.tv_sec * GNUNET_TIME_UNIT_SECONDS.rel_value_us)); | 1808 | (tv.tv_sec * GNUNET_TIME_UNIT_SECONDS.rel_value_us)); |
1809 | } | 1809 | } |
1810 | return select (nfds, | 1810 | return select (nfds, |
1811 | (NULL != rfds) ? &rfds->sds : NULL, | 1811 | (NULL != rfds) ? &rfds->sds : NULL, |
1812 | (NULL != wfds) ? &wfds->sds : NULL, | 1812 | (NULL != wfds) ? &wfds->sds : NULL, |
1813 | (NULL != efds) ? &efds->sds : NULL, | 1813 | (NULL != efds) ? &efds->sds : NULL, |
1814 | (timeout.rel_value_us == | 1814 | (timeout.rel_value_us == |
@@ -2178,7 +2178,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
2178 | { | 2178 | { |
2179 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2179 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2180 | "Adding the socket event to the array as %d\n", | 2180 | "Adding the socket event to the array as %d\n", |
2181 | nhandles); | 2181 | nhandles); |
2182 | handle_array[nhandles++] = select_finished_event; | 2182 | handle_array[nhandles++] = select_finished_event; |
2183 | if (timeout.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us) | 2183 | if (timeout.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us) |
2184 | { | 2184 | { |
diff --git a/src/util/scheduler.c b/src/util/scheduler.c index fecbc0de5..9d37231e7 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c | |||
@@ -756,8 +756,9 @@ init_fd_info (struct GNUNET_SCHEDULER_Task *t, | |||
756 | t->fds = fdi; | 756 | t->fds = fdi; |
757 | if (1 == read_nh_len) | 757 | if (1 == read_nh_len) |
758 | { | 758 | { |
759 | GNUNET_assert (NULL != read_nh); | ||
760 | GNUNET_assert (NULL != *read_nh); | ||
759 | fdi->fd = *read_nh; | 761 | fdi->fd = *read_nh; |
760 | GNUNET_assert (NULL != fdi->fd); | ||
761 | fdi->et = GNUNET_SCHEDULER_ET_IN; | 762 | fdi->et = GNUNET_SCHEDULER_ET_IN; |
762 | fdi->sock = GNUNET_NETWORK_get_fd (*read_nh); | 763 | fdi->sock = GNUNET_NETWORK_get_fd (*read_nh); |
763 | t->read_fd = fdi->sock; | 764 | t->read_fd = fdi->sock; |
@@ -765,8 +766,9 @@ init_fd_info (struct GNUNET_SCHEDULER_Task *t, | |||
765 | } | 766 | } |
766 | else if (1 == write_nh_len) | 767 | else if (1 == write_nh_len) |
767 | { | 768 | { |
769 | GNUNET_assert (NULL != write_nh); | ||
770 | GNUNET_assert (NULL != *write_nh); | ||
768 | fdi->fd = *write_nh; | 771 | fdi->fd = *write_nh; |
769 | GNUNET_assert (NULL != fdi->fd); | ||
770 | fdi->et = GNUNET_SCHEDULER_ET_OUT; | 772 | fdi->et = GNUNET_SCHEDULER_ET_OUT; |
771 | fdi->sock = GNUNET_NETWORK_get_fd (*write_nh); | 773 | fdi->sock = GNUNET_NETWORK_get_fd (*write_nh); |
772 | t->read_fd = -1; | 774 | t->read_fd = -1; |
@@ -774,8 +776,9 @@ init_fd_info (struct GNUNET_SCHEDULER_Task *t, | |||
774 | } | 776 | } |
775 | else if (1 == read_fh_len) | 777 | else if (1 == read_fh_len) |
776 | { | 778 | { |
779 | GNUNET_assert (NULL != read_fh); | ||
780 | GNUNET_assert (NULL != *read_fh); | ||
777 | fdi->fh = *read_fh; | 781 | fdi->fh = *read_fh; |
778 | GNUNET_assert (NULL != fdi->fh); | ||
779 | fdi->et = GNUNET_SCHEDULER_ET_IN; | 782 | fdi->et = GNUNET_SCHEDULER_ET_IN; |
780 | fdi->sock = (*read_fh)->fd; // FIXME: does not work under WIN32 | 783 | fdi->sock = (*read_fh)->fd; // FIXME: does not work under WIN32 |
781 | t->read_fd = fdi->sock; | 784 | t->read_fd = fdi->sock; |
@@ -783,8 +786,9 @@ init_fd_info (struct GNUNET_SCHEDULER_Task *t, | |||
783 | } | 786 | } |
784 | else | 787 | else |
785 | { | 788 | { |
789 | GNUNET_assert (NULL != write_fh); | ||
790 | GNUNET_assert (NULL != *write_fh); | ||
786 | fdi->fh = *write_fh; | 791 | fdi->fh = *write_fh; |
787 | GNUNET_assert (NULL != fdi->fh); | ||
788 | fdi->et = GNUNET_SCHEDULER_ET_OUT; | 792 | fdi->et = GNUNET_SCHEDULER_ET_OUT; |
789 | fdi->sock = (*write_fh)->fd; // FIXME: does not work under WIN32 | 793 | fdi->sock = (*write_fh)->fd; // FIXME: does not work under WIN32 |
790 | t->read_fd = -1; | 794 | t->read_fd = -1; |
@@ -1750,8 +1754,11 @@ GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, | |||
1750 | const struct GNUNET_DISK_FileHandle **write_fhandles; | 1754 | const struct GNUNET_DISK_FileHandle **write_fhandles; |
1751 | unsigned int read_nhandles_len, write_nhandles_len, | 1755 | unsigned int read_nhandles_len, write_nhandles_len, |
1752 | read_fhandles_len, write_fhandles_len; | 1756 | read_fhandles_len, write_fhandles_len; |
1757 | int no_fdsets = (NULL == rs) && (NULL == ws); | ||
1758 | int no_socket_descriptors = | ||
1759 | ((NULL != rs) && (0 == rs->nsds)) && ((NULL != ws) && (0 == ws->nsds)); | ||
1753 | 1760 | ||
1754 | if (((NULL == rs) && (NULL == ws)) || ((0 == rs->nsds) && (0 == ws->nsds))) | 1761 | if (no_fdsets || no_socket_descriptors) |
1755 | return GNUNET_SCHEDULER_add_delayed_with_priority (delay, | 1762 | return GNUNET_SCHEDULER_add_delayed_with_priority (delay, |
1756 | prio, | 1763 | prio, |
1757 | task, | 1764 | task, |