gnunet

Main GNUnet Logic
Log | Files | Refs | Submodules | README | LICENSE

commit 52b6b0d7ba7d50f04da21fc5a1a13166a8a40954
parent ff52ef4afeee5f47033ada8132925afcec9bcf37
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date:   Mon, 13 Oct 2025 17:52:34 +0200

{name,data}{store,cache},messenger,regex: fix various compiler warnings; clang some with significant impact wrt uninitialized variables (aka bugs)

Diffstat:
Msrc/include/gnunet_core_service.h | 2+-
Msrc/include/gnunet_testing_core_lib.h | 10++++++----
Msrc/lib/util/crypto_hpke.c | 2+-
Msrc/plugin/datacache/plugin_datacache_postgres.c | 64++++++++++++++++++++++++++++++++++++----------------------------
Msrc/plugin/datacache/plugin_datacache_sqlite.c | 469+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Msrc/plugin/datastore/plugin_datastore_postgres.c | 39+++++++++++++++++++++------------------
Msrc/plugin/datastore/plugin_datastore_sqlite.c | 101+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Msrc/plugin/namecache/plugin_namecache_postgres.c | 33+++++++++++++++++++--------------
Msrc/plugin/namecache/plugin_namecache_sqlite.c | 70++++++++++++++++++++++++++++++++++++++--------------------------------
Msrc/service/core/core_api.c | 2+-
Msrc/service/core/gnunet_core_underlay_dummy.c | 370++++++++++++++++++++++++++++++++++++++++---------------------------------------
Msrc/service/core/testing_core_cmd_recv.c | 2+-
Msrc/service/core/testing_core_cmd_send.c | 8++++----
Msrc/service/messenger/gnunet-service-messenger_message_send.c | 2+-
Msrc/service/regex/regex_internal.c | 2+-
Msrc/service/rest/oidc_helper.c | 6------
16 files changed, 613 insertions(+), 569 deletions(-)

diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h @@ -527,7 +527,7 @@ GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CORE_ConnectEventHandler connects, GNUNET_CORE_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers, - struct GNUNET_CORE_ServiceInfo *service_info); + const struct GNUNET_CORE_ServiceInfo *service_info); /** diff --git a/src/include/gnunet_testing_core_lib.h b/src/include/gnunet_testing_core_lib.h @@ -145,7 +145,7 @@ struct GNUNET_TESTING_CORE_Message // The following will be used for debugging uint64_t id; // id of the message uint64_t batch; // first batch of that peer (for this test 0 or 1) - //uint64_t peer; // number of sending peer (for this test 0 or 1) + // uint64_t peer; // number of sending peer (for this test 0 or 1) char node_id[NODE_ID_LEN]; }; @@ -174,7 +174,9 @@ typedef void struct GNUNET_TESTING_CORE_ConnectState { struct GNUNET_CORE_Handle *h; - const char* node_id; + + // FIXME why is this const? Borrowed pointer?! + const char*node_id; struct GNUNET_PeerIdentity peer_id; char *arm_service_label; const struct GNUNET_CONFIGURATION_Handle *cfg; @@ -227,7 +229,7 @@ GNUNET_CORE_cmd_connect_peers ( const struct GNUNET_TESTING_Command GNUNET_TESTING_CORE_cmd_connect ( const char *label, - const char* node_id, + const char*node_id, char *arm_service_label); @@ -250,7 +252,7 @@ GNUNET_TESTING_CORE_cmd_send ( #define GNUNET_CORE_TESTING_SIMPLE_TRAITS(op, prefix) \ op (prefix, connect_peer_state, const struct \ GNUNET_TESTING_ConnectPeersState) \ - op (prefix, connect, const struct \ + op (prefix, connect, struct \ GNUNET_TESTING_CORE_ConnectState) GNUNET_CORE_TESTING_SIMPLE_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT, diff --git a/src/lib/util/crypto_hpke.c b/src/lib/util/crypto_hpke.c @@ -431,7 +431,7 @@ key_schedule (enum GNUNET_CRYPTO_HpkeRole role, struct GNUNET_ShortHashCode info_hash; struct GNUNET_ShortHashCode secret; uint8_t key_schedule_context[1 + sizeof info_hash * 2]; - uint8_t suite_id[strlen ("HPKE") + 6]; + uint8_t suite_id[4 + 3 * 2]; uint16_t kem_id = htons (32); // FIXME hardcode as constant uint16_t kdf_id = htons (1); // HKDF-256 FIXME hardcode as constant uint16_t aead_id = htons (3); // ChaCha20Poly1305 FIXME hardcode as constant diff --git a/src/plugin/datacache/plugin_datacache_postgres.c b/src/plugin/datacache/plugin_datacache_postgres.c @@ -349,21 +349,19 @@ postgres_plugin_del (void *cls) GNUNET_PQ_result_spec_end }; enum GNUNET_DB_QueryStatus res; - struct GNUNET_PQ_QueryParam dparam[] = { - GNUNET_PQ_query_param_uint64 (&oid), - GNUNET_PQ_query_param_end - }; struct GNUNET_TIME_Absolute now; - struct GNUNET_PQ_QueryParam xparam[] = { - GNUNET_PQ_query_param_absolute_time (&now), - GNUNET_PQ_query_param_end - }; - now = GNUNET_TIME_absolute_get (); - res = GNUNET_PQ_eval_prepared_singleton_select (plugin->dbh, - "getex", - xparam, - rs); + { + struct GNUNET_PQ_QueryParam xparam[] = { + GNUNET_PQ_query_param_absolute_time (&now), + GNUNET_PQ_query_param_end + }; + + res = GNUNET_PQ_eval_prepared_singleton_select (plugin->dbh, + "getex", + xparam, + rs); + } if (0 >= res) res = GNUNET_PQ_eval_prepared_singleton_select (plugin->dbh, "getm", @@ -378,9 +376,15 @@ postgres_plugin_del (void *cls) "Ending iteration (no more results)\n"); return 0; } - res = GNUNET_PQ_eval_prepared_non_select (plugin->dbh, - "delrow", - dparam); + { + struct GNUNET_PQ_QueryParam dparam[] = { + GNUNET_PQ_query_param_uint64 (&oid), + GNUNET_PQ_query_param_end + }; + res = GNUNET_PQ_eval_prepared_non_select (plugin->dbh, + "delrow", + dparam); + } if (0 > res) { GNUNET_PQ_cleanup_result (rs); @@ -522,24 +526,26 @@ postgres_plugin_get_closest (void *cls, uint32_t num_results32 = (uint32_t) num_results; uint32_t type32 = (uint32_t) type; struct GNUNET_TIME_Absolute now; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_auto_from_type (key), - GNUNET_PQ_query_param_absolute_time (&now), - GNUNET_PQ_query_param_uint32 (&type32), - GNUNET_PQ_query_param_uint32 (&num_results32), - GNUNET_PQ_query_param_end - }; enum GNUNET_DB_QueryStatus res; struct ExtractResultContext erc; erc.iter = iter; erc.iter_cls = iter_cls; now = GNUNET_TIME_absolute_get (); - res = GNUNET_PQ_eval_prepared_multi_select (plugin->dbh, - "get_closest", - params, - &extract_result_cb, - &erc); + { + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_auto_from_type (key), + GNUNET_PQ_query_param_absolute_time (&now), + GNUNET_PQ_query_param_uint32 (&type32), + GNUNET_PQ_query_param_uint32 (&num_results32), + GNUNET_PQ_query_param_end + }; + res = GNUNET_PQ_eval_prepared_multi_select (plugin->dbh, + "get_closest", + params, + &extract_result_cb, + &erc); + } if (0 > res) { LOG (GNUNET_ERROR_TYPE_DEBUG, @@ -556,6 +562,7 @@ postgres_plugin_get_closest (void *cls, return res; } + void * libgnunet_plugin_datacache_postgres_init (void *cls); @@ -592,6 +599,7 @@ libgnunet_plugin_datacache_postgres_init (void *cls) return api; } + void * libgnunet_plugin_datacache_postgres_done (void *cls); diff --git a/src/plugin/datacache/plugin_datacache_sqlite.c b/src/plugin/datacache/plugin_datacache_sqlite.c @@ -32,7 +32,7 @@ #define LOG(kind, ...) GNUNET_log_from (kind, "datacache-sqlite", __VA_ARGS__) #define LOG_STRERROR_FILE(kind, op, fn) \ - GNUNET_log_from_strerror_file (kind, "datacache-sqlite", op, fn) + GNUNET_log_from_strerror_file (kind, "datacache-sqlite", op, fn) /** @@ -122,15 +122,15 @@ struct Plugin * @param cmd failed command */ #define LOG_SQLITE(db, level, cmd) \ - do \ - { \ - LOG (level, \ - _ ("`%s' failed at %s:%d with error: %s\n"), \ - cmd, \ - __FILE__, \ - __LINE__, \ - sqlite3_errmsg (db)); \ - } while (0) + do \ + { \ + LOG (level, \ + _ ("`%s' failed at %s:%d with error: %s\n"), \ + cmd, \ + __FILE__, \ + __LINE__, \ + sqlite3_errmsg (db)); \ + } while (0) /** @@ -140,21 +140,21 @@ struct Plugin * @param cmd SQL command to execute */ #define SQLITE3_EXEC(db, cmd) \ - do \ - { \ - emsg = NULL; \ - if (SQLITE_OK != \ - sqlite3_exec (db, cmd, NULL, NULL, &emsg)) \ - { \ - LOG (GNUNET_ERROR_TYPE_ERROR, \ - _ ("`%s' failed at %s:%d with error: %s\n"), \ - "sqlite3_exec", \ - __FILE__, \ - __LINE__, \ - emsg); \ - sqlite3_free (emsg); \ - } \ - } while (0) + do \ + { \ + emsg = NULL; \ + if (SQLITE_OK != \ + sqlite3_exec (db, cmd, NULL, NULL, &emsg)) \ + { \ + LOG (GNUNET_ERROR_TYPE_ERROR, \ + _ ("`%s' failed at %s:%d with error: %s\n"), \ + "sqlite3_exec", \ + __FILE__, \ + __LINE__, \ + emsg); \ + sqlite3_free (emsg); \ + } \ + } while (0) /** @@ -274,133 +274,138 @@ get_any (void *cls, void *path; void *data; size_t path_size; - struct GNUNET_SQ_QueryParam params_count[] = { - GNUNET_SQ_query_param_auto_from_type (key), - GNUNET_SQ_query_param_absolute_time (&now), - GNUNET_SQ_query_param_end - }; - struct GNUNET_SQ_QueryParam params_select[] = { - GNUNET_SQ_query_param_auto_from_type (key), - GNUNET_SQ_query_param_absolute_time (&now), - GNUNET_SQ_query_param_uint32 (&off), - GNUNET_SQ_query_param_end - }; - struct GNUNET_SQ_ResultSpec rs[] = { - GNUNET_SQ_result_spec_variable_size (&data, - &block.data_size), - GNUNET_SQ_result_spec_absolute_time (&block.expiration_time), - GNUNET_SQ_result_spec_variable_size (&path, - &path_size), - GNUNET_SQ_result_spec_auto_from_type (&block.trunc_peer), - GNUNET_SQ_result_spec_uint32 (&btype32), - GNUNET_SQ_result_spec_uint32 (&bro32), - GNUNET_SQ_result_spec_end - }; now = GNUNET_TIME_absolute_get (); - LOG (GNUNET_ERROR_TYPE_DEBUG, - "Processing GET for key `%s'\n", - GNUNET_h2s (key)); - - if (GNUNET_OK != - GNUNET_SQ_bind (plugin->get_count_any_stmt, - params_count)) { - LOG_SQLITE (plugin->dbh, - GNUNET_ERROR_TYPE_ERROR, - "sqlite3_bind_xxx"); - GNUNET_SQ_reset (plugin->dbh, - plugin->get_count_any_stmt); - return 0; - } - if (SQLITE_ROW != - sqlite3_step (plugin->get_count_any_stmt)) - { - LOG_SQLITE (plugin->dbh, - GNUNET_ERROR_TYPE_ERROR, - "sqlite_step"); - GNUNET_SQ_reset (plugin->dbh, - plugin->get_count_any_stmt); + struct GNUNET_SQ_QueryParam params_count[] = { + GNUNET_SQ_query_param_auto_from_type (key), + GNUNET_SQ_query_param_absolute_time (&now), + GNUNET_SQ_query_param_end + }; LOG (GNUNET_ERROR_TYPE_DEBUG, - "No content found when processing GET for key `%s'\n", + "Processing GET for key `%s'\n", GNUNET_h2s (key)); - return 0; - } - total = sqlite3_column_int (plugin->get_count_any_stmt, - 0); - GNUNET_SQ_reset (plugin->dbh, - plugin->get_count_any_stmt); - if ( (0 == total) || - (NULL == iter) ) - { - if (0 == total) - LOG (GNUNET_ERROR_TYPE_DEBUG, - "No content found when processing GET for key `%s'\n", - GNUNET_h2s (key)); - return total; - } - cnt = 0; - block.key = *key; - off = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - total); - while (cnt < total) - { - off = (off + 1) % total; if (GNUNET_OK != - GNUNET_SQ_bind (plugin->get_any_stmt, - params_select)) + GNUNET_SQ_bind (plugin->get_count_any_stmt, + params_count)) { LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR, "sqlite3_bind_xxx"); GNUNET_SQ_reset (plugin->dbh, - plugin->get_any_stmt); - return cnt; + plugin->get_count_any_stmt); + return 0; } if (SQLITE_ROW != - sqlite3_step (plugin->get_any_stmt)) - break; - if (GNUNET_OK != - GNUNET_SQ_extract_result (plugin->get_any_stmt, - rs)) + sqlite3_step (plugin->get_count_any_stmt)) { - GNUNET_break (0); + LOG_SQLITE (plugin->dbh, + GNUNET_ERROR_TYPE_ERROR, + "sqlite_step"); GNUNET_SQ_reset (plugin->dbh, - plugin->get_any_stmt); - break; + plugin->get_count_any_stmt); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "No content found when processing GET for key `%s'\n", + GNUNET_h2s (key)); + return 0; } - if (0 != path_size % sizeof(struct GNUNET_DHT_PathElement)) + total = sqlite3_column_int (plugin->get_count_any_stmt, + 0); + GNUNET_SQ_reset (plugin->dbh, + plugin->get_count_any_stmt); + if ( (0 == total) || + (NULL == iter) ) { - GNUNET_break (0); - path_size = 0; - path = NULL; + if (0 == total) + LOG (GNUNET_ERROR_TYPE_DEBUG, + "No content found when processing GET for key `%s'\n", + GNUNET_h2s (key)); + return total; } - block.data = data; - block.put_path = path; - block.put_path_length = path_size / sizeof(struct GNUNET_DHT_PathElement); - block.type = (enum GNUNET_BLOCK_Type) btype32; - block.ro = (enum GNUNET_DHT_RouteOption) bro32; - cnt++; - LOG (GNUNET_ERROR_TYPE_DEBUG, - "Found %u-byte result when processing GET for key `%s'\n", - (unsigned int) block.data_size, - GNUNET_h2s (&block.key)); - if (GNUNET_OK != - iter (iter_cls, - &block)) + } + cnt = 0; + block.key = *key; + off = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, + total); + { + struct GNUNET_SQ_QueryParam params_select[] = { + GNUNET_SQ_query_param_auto_from_type (key), + GNUNET_SQ_query_param_absolute_time (&now), + GNUNET_SQ_query_param_uint32 (&off), + GNUNET_SQ_query_param_end + }; + struct GNUNET_SQ_ResultSpec rs[] = { + GNUNET_SQ_result_spec_variable_size (&data, + &block.data_size), + GNUNET_SQ_result_spec_absolute_time (&block.expiration_time), + GNUNET_SQ_result_spec_variable_size (&path, + &path_size), + GNUNET_SQ_result_spec_auto_from_type (&block.trunc_peer), + GNUNET_SQ_result_spec_uint32 (&btype32), + GNUNET_SQ_result_spec_uint32 (&bro32), + GNUNET_SQ_result_spec_end + }; + + while (cnt < total) { + off = (off + 1) % total; + if (GNUNET_OK != + GNUNET_SQ_bind (plugin->get_any_stmt, + params_select)) + { + LOG_SQLITE (plugin->dbh, + GNUNET_ERROR_TYPE_ERROR, + "sqlite3_bind_xxx"); + GNUNET_SQ_reset (plugin->dbh, + plugin->get_any_stmt); + return cnt; + } + if (SQLITE_ROW != + sqlite3_step (plugin->get_any_stmt)) + break; + if (GNUNET_OK != + GNUNET_SQ_extract_result (plugin->get_any_stmt, + rs)) + { + GNUNET_break (0); + GNUNET_SQ_reset (plugin->dbh, + plugin->get_any_stmt); + break; + } + if (0 != path_size % sizeof(struct GNUNET_DHT_PathElement)) + { + GNUNET_break (0); + path_size = 0; + path = NULL; + } + block.data = data; + block.put_path = path; + block.put_path_length = path_size / sizeof(struct GNUNET_DHT_PathElement); + block.type = (enum GNUNET_BLOCK_Type) btype32; + block.ro = (enum GNUNET_DHT_RouteOption) bro32; + cnt++; + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Found %u-byte result when processing GET for key `%s'\n", + (unsigned int) block.data_size, + GNUNET_h2s (&block.key)); + if (GNUNET_OK != + iter (iter_cls, + &block)) + { + GNUNET_SQ_cleanup_result (rs); + GNUNET_SQ_reset (plugin->dbh, + plugin->get_any_stmt); + break; + } GNUNET_SQ_cleanup_result (rs); GNUNET_SQ_reset (plugin->dbh, plugin->get_any_stmt); - break; } - GNUNET_SQ_cleanup_result (rs); GNUNET_SQ_reset (plugin->dbh, plugin->get_any_stmt); } - GNUNET_SQ_reset (plugin->dbh, - plugin->get_any_stmt); + return cnt; } @@ -434,19 +439,6 @@ get_typed (void *cls, void *path; void *data; size_t path_size; - struct GNUNET_SQ_QueryParam params_count[] = { - GNUNET_SQ_query_param_auto_from_type (key), - GNUNET_SQ_query_param_uint32 (&type32), - GNUNET_SQ_query_param_absolute_time (&now), - GNUNET_SQ_query_param_end - }; - struct GNUNET_SQ_QueryParam params_select[] = { - GNUNET_SQ_query_param_auto_from_type (key), - GNUNET_SQ_query_param_uint32 (&type32), - GNUNET_SQ_query_param_absolute_time (&now), - GNUNET_SQ_query_param_uint32 (&off), - GNUNET_SQ_query_param_end - }; struct GNUNET_SQ_ResultSpec rs[] = { GNUNET_SQ_result_spec_variable_size (&data, &block.data_size), @@ -462,17 +454,25 @@ get_typed (void *cls, LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing GET for key `%s'\n", GNUNET_h2s (key)); - - if (GNUNET_OK != - GNUNET_SQ_bind (plugin->get_count_stmt, - params_count)) { - LOG_SQLITE (plugin->dbh, - GNUNET_ERROR_TYPE_ERROR, - "sqlite3_bind_xxx"); - GNUNET_SQ_reset (plugin->dbh, - plugin->get_count_stmt); - return 0; + struct GNUNET_SQ_QueryParam params_count[] = { + GNUNET_SQ_query_param_auto_from_type (key), + GNUNET_SQ_query_param_uint32 (&type32), + GNUNET_SQ_query_param_absolute_time (&now), + GNUNET_SQ_query_param_end + }; + + if (GNUNET_OK != + GNUNET_SQ_bind (plugin->get_count_stmt, + params_count)) + { + LOG_SQLITE (plugin->dbh, + GNUNET_ERROR_TYPE_ERROR, + "sqlite3_bind_xxx"); + GNUNET_SQ_reset (plugin->dbh, + plugin->get_count_stmt); + return 0; + } } if (SQLITE_ROW != sqlite3_step (plugin->get_count_stmt)) @@ -505,64 +505,73 @@ get_typed (void *cls, block.key = *key; off = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, total); - while (cnt < total) { - off = (off + 1) % total; - if (GNUNET_OK != - GNUNET_SQ_bind (plugin->get_stmt, - params_select)) - { - LOG_SQLITE (plugin->dbh, - GNUNET_ERROR_TYPE_ERROR, - "sqlite3_bind_xxx"); - GNUNET_SQ_reset (plugin->dbh, - plugin->get_stmt); - return cnt; - } - if (SQLITE_ROW != - sqlite3_step (plugin->get_stmt)) - break; - if (GNUNET_OK != - GNUNET_SQ_extract_result (plugin->get_stmt, - rs)) - { - GNUNET_break (0); - GNUNET_SQ_reset (plugin->dbh, - plugin->get_stmt); - break; - } - if (0 != path_size % sizeof(struct GNUNET_DHT_PathElement)) - { - GNUNET_break (0); - path_size = 0; - path = NULL; - } - block.data = data; - block.put_path = path; - block.put_path_length = path_size / sizeof(struct GNUNET_DHT_PathElement); - block.type = type; - block.ro = (enum GNUNET_DHT_RouteOption) bro32; - cnt++; - LOG (GNUNET_ERROR_TYPE_DEBUG, - "Found %u-byte result when processing GET for key `%s'\n", - (unsigned int) block.data_size, - GNUNET_h2s (&block.key)); - if ( (NULL != iter) && - (GNUNET_OK != - iter (iter_cls, - &block)) ) + struct GNUNET_SQ_QueryParam params_select[] = { + GNUNET_SQ_query_param_auto_from_type (key), + GNUNET_SQ_query_param_uint32 (&type32), + GNUNET_SQ_query_param_absolute_time (&now), + GNUNET_SQ_query_param_uint32 (&off), + GNUNET_SQ_query_param_end + }; + while (cnt < total) { + off = (off + 1) % total; + if (GNUNET_OK != + GNUNET_SQ_bind (plugin->get_stmt, + params_select)) + { + LOG_SQLITE (plugin->dbh, + GNUNET_ERROR_TYPE_ERROR, + "sqlite3_bind_xxx"); + GNUNET_SQ_reset (plugin->dbh, + plugin->get_stmt); + return cnt; + } + if (SQLITE_ROW != + sqlite3_step (plugin->get_stmt)) + break; + if (GNUNET_OK != + GNUNET_SQ_extract_result (plugin->get_stmt, + rs)) + { + GNUNET_break (0); + GNUNET_SQ_reset (plugin->dbh, + plugin->get_stmt); + break; + } + if (0 != path_size % sizeof(struct GNUNET_DHT_PathElement)) + { + GNUNET_break (0); + path_size = 0; + path = NULL; + } + block.data = data; + block.put_path = path; + block.put_path_length = path_size / sizeof(struct GNUNET_DHT_PathElement); + block.type = type; + block.ro = (enum GNUNET_DHT_RouteOption) bro32; + cnt++; + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Found %u-byte result when processing GET for key `%s'\n", + (unsigned int) block.data_size, + GNUNET_h2s (&block.key)); + if ( (NULL != iter) && + (GNUNET_OK != + iter (iter_cls, + &block)) ) + { + GNUNET_SQ_cleanup_result (rs); + GNUNET_SQ_reset (plugin->dbh, + plugin->get_stmt); + break; + } GNUNET_SQ_cleanup_result (rs); GNUNET_SQ_reset (plugin->dbh, plugin->get_stmt); - break; } - GNUNET_SQ_cleanup_result (rs); GNUNET_SQ_reset (plugin->dbh, plugin->get_stmt); } - GNUNET_SQ_reset (plugin->dbh, - plugin->get_stmt); return cnt; } @@ -625,24 +634,26 @@ sqlite_plugin_del (void *cls) GNUNET_SQ_query_param_uint64 (&rowid), GNUNET_SQ_query_param_end }; - struct GNUNET_SQ_QueryParam time_params[] = { - GNUNET_SQ_query_param_absolute_time (&now), - GNUNET_SQ_query_param_end - }; - LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing DEL\n"); now = GNUNET_TIME_absolute_get (); - if (GNUNET_OK != - GNUNET_SQ_bind (plugin->del_expired_stmt, - time_params)) { - LOG_SQLITE (plugin->dbh, - GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, - "sqlite3_bind"); - GNUNET_SQ_reset (plugin->dbh, - plugin->del_expired_stmt); - return GNUNET_SYSERR; + struct GNUNET_SQ_QueryParam time_params[] = { + GNUNET_SQ_query_param_absolute_time (&now), + GNUNET_SQ_query_param_end + }; + + if (GNUNET_OK != + GNUNET_SQ_bind (plugin->del_expired_stmt, + time_params)) + { + LOG_SQLITE (plugin->dbh, + GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "sqlite3_bind"); + GNUNET_SQ_reset (plugin->dbh, + plugin->del_expired_stmt); + return GNUNET_SYSERR; + } } if ( (SQLITE_ROW != sqlite3_step (plugin->del_expired_stmt)) || @@ -739,13 +750,6 @@ sqlite_plugin_get_closest (void *cls, uint32_t bro32; struct GNUNET_DATACACHE_Block block; uint32_t rtype32; - struct GNUNET_SQ_QueryParam params[] = { - GNUNET_SQ_query_param_auto_from_type (key), - GNUNET_SQ_query_param_absolute_time (&now), - GNUNET_SQ_query_param_uint32 (&type32), - GNUNET_SQ_query_param_uint32 (&num_results32), - GNUNET_SQ_query_param_end - }; struct GNUNET_SQ_ResultSpec rs[] = { GNUNET_SQ_result_spec_variable_size (&data, &block.data_size), @@ -763,16 +767,25 @@ sqlite_plugin_get_closest (void *cls, LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing GET_CLOSEST for key `%s'\n", GNUNET_h2s (key)); - if (GNUNET_OK != - GNUNET_SQ_bind (plugin->get_closest_stmt, - params)) { - LOG_SQLITE (plugin->dbh, - GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, - "sqlite3_bind_xxx"); - GNUNET_SQ_reset (plugin->dbh, - plugin->get_closest_stmt); - return 0; + struct GNUNET_SQ_QueryParam params[] = { + GNUNET_SQ_query_param_auto_from_type (key), + GNUNET_SQ_query_param_absolute_time (&now), + GNUNET_SQ_query_param_uint32 (&type32), + GNUNET_SQ_query_param_uint32 (&num_results32), + GNUNET_SQ_query_param_end + }; + if (GNUNET_OK != + GNUNET_SQ_bind (plugin->get_closest_stmt, + params)) + { + LOG_SQLITE (plugin->dbh, + GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "sqlite3_bind_xxx"); + GNUNET_SQ_reset (plugin->dbh, + plugin->get_closest_stmt); + return 0; + } } cnt = 0; while (SQLITE_ROW == @@ -817,6 +830,7 @@ sqlite_plugin_get_closest (void *cls, return cnt; } + void * libgnunet_plugin_datacache_sqlite_init (void *cls); @@ -993,6 +1007,7 @@ libgnunet_plugin_datacache_sqlite_init (void *cls) return api; } + void * libgnunet_plugin_datacache_sqlite_done (void *cls); diff --git a/src/plugin/datastore/plugin_datastore_postgres.c b/src/plugin/datastore/plugin_datastore_postgres.c @@ -460,16 +460,6 @@ postgres_plugin_get_key (void *cls, uint16_t use_key = NULL != key; uint16_t use_type = GNUNET_BLOCK_TYPE_ANY != type; uint64_t rvalue; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&next_uid), - GNUNET_PQ_query_param_uint64 (&rvalue), - GNUNET_PQ_query_param_uint16 (&use_rvalue), - GNUNET_PQ_query_param_auto_from_type (key), - GNUNET_PQ_query_param_uint16 (&use_key), - GNUNET_PQ_query_param_uint32 (&utype), - GNUNET_PQ_query_param_uint16 (&use_type), - GNUNET_PQ_query_param_end - }; struct ProcessResultContext prc; enum GNUNET_DB_QueryStatus res; @@ -483,15 +473,28 @@ postgres_plugin_get_key (void *cls, { rvalue = 0; } - prc.plugin = plugin; - prc.proc = proc; - prc.proc_cls = proc_cls; - res = GNUNET_PQ_eval_prepared_multi_select (plugin->dbh, - "get", - params, - &process_result, - &prc); + { + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&next_uid), + GNUNET_PQ_query_param_uint64 (&rvalue), + GNUNET_PQ_query_param_uint16 (&use_rvalue), + GNUNET_PQ_query_param_auto_from_type (key), + GNUNET_PQ_query_param_uint16 (&use_key), + GNUNET_PQ_query_param_uint32 (&utype), + GNUNET_PQ_query_param_uint16 (&use_type), + GNUNET_PQ_query_param_end + }; + prc.plugin = plugin; + prc.proc = proc; + prc.proc_cls = proc_cls; + + res = GNUNET_PQ_eval_prepared_multi_select (plugin->dbh, + "get", + params, + &process_result, + &prc); + } if (0 > res) proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); diff --git a/src/plugin/datastore/plugin_datastore_sqlite.c b/src/plugin/datastore/plugin_datastore_sqlite.c @@ -659,17 +659,6 @@ sqlite_plugin_put (void *cls, // FIXME Refactor? uint64_t rvalue; uint32_t type32 = (uint32_t) type; - struct GNUNET_SQ_QueryParam params[] = - { GNUNET_SQ_query_param_uint32 (&replication), - GNUNET_SQ_query_param_uint32 (&type32), - GNUNET_SQ_query_param_uint32 (&priority), - GNUNET_SQ_query_param_uint32 (&anonymity), - GNUNET_SQ_query_param_absolute_time (&expiration), - GNUNET_SQ_query_param_uint64 (&rvalue), - GNUNET_SQ_query_param_auto_from_type (key), - GNUNET_SQ_query_param_auto_from_type (&vhash), - GNUNET_SQ_query_param_fixed_size (data, size), - GNUNET_SQ_query_param_end }; int n; int ret; sqlite3_stmt *stmt; @@ -693,10 +682,23 @@ sqlite_plugin_put (void *cls, GNUNET_STRINGS_absolute_time_to_string (expiration)); stmt = plugin->insertContent; rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); - if (GNUNET_OK != GNUNET_SQ_bind (stmt, params)) { - cont (cont_cls, key, size, GNUNET_SYSERR, NULL); - return; + struct GNUNET_SQ_QueryParam params[] = + { GNUNET_SQ_query_param_uint32 (&replication), + GNUNET_SQ_query_param_uint32 (&type32), + GNUNET_SQ_query_param_uint32 (&priority), + GNUNET_SQ_query_param_uint32 (&anonymity), + GNUNET_SQ_query_param_absolute_time (&expiration), + GNUNET_SQ_query_param_uint64 (&rvalue), + GNUNET_SQ_query_param_auto_from_type (key), + GNUNET_SQ_query_param_auto_from_type (&vhash), + GNUNET_SQ_query_param_fixed_size (data, size), + GNUNET_SQ_query_param_end }; + if (GNUNET_OK != GNUNET_SQ_bind (stmt, params)) + { + cont (cont_cls, key, size, GNUNET_SYSERR, NULL); + return; + } } n = sqlite3_step (stmt); switch (n) @@ -900,26 +902,6 @@ sqlite_plugin_get_key (void *cls, int use_type = GNUNET_BLOCK_TYPE_ANY != type; int use_key = NULL != key; sqlite3_stmt *stmt = plugin->get[use_rvalue * 4 + use_key * 2 + use_type]; - struct GNUNET_SQ_QueryParam params[] = - { GNUNET_SQ_query_param_uint64 (&next_uid), - GNUNET_SQ_query_param_uint64 (&rvalue), - GNUNET_SQ_query_param_auto_from_type (key), - GNUNET_SQ_query_param_uint32 (&type32), - GNUNET_SQ_query_param_end }; - - /* SQLite doesn't like it when you try to bind a parameter greater than the - * last numbered parameter, but unused parameters in the middle are OK. - */ - if (! use_type) - { - params[3] = (struct GNUNET_SQ_QueryParam) GNUNET_SQ_query_param_end; - if (! use_key) - { - params[2] = (struct GNUNET_SQ_QueryParam) GNUNET_SQ_query_param_end; - if (! use_rvalue) - params[1] = (struct GNUNET_SQ_QueryParam) GNUNET_SQ_query_param_end; - } - } if (random) { rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); @@ -927,11 +909,32 @@ sqlite_plugin_get_key (void *cls, } else rvalue = 0; - - if (GNUNET_OK != GNUNET_SQ_bind (stmt, params)) - { - proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); - return; + { struct GNUNET_SQ_QueryParam params[] = + { GNUNET_SQ_query_param_uint64 (&next_uid), + GNUNET_SQ_query_param_uint64 (&rvalue), + GNUNET_SQ_query_param_auto_from_type (key), + GNUNET_SQ_query_param_uint32 (&type32), + GNUNET_SQ_query_param_end }; + + /* SQLite doesn't like it when you try to bind a parameter greater than the + * last numbered parameter, but unused parameters in the middle are OK. + */ + if (! use_type) + { + params[3] = (struct GNUNET_SQ_QueryParam) GNUNET_SQ_query_param_end; + if (! use_key) + { + params[2] = (struct GNUNET_SQ_QueryParam) GNUNET_SQ_query_param_end; + if (! use_rvalue) + params[1] = (struct GNUNET_SQ_QueryParam) GNUNET_SQ_query_param_end; + } + } + + if (GNUNET_OK != GNUNET_SQ_bind (stmt, params)) + { + proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); + return; + } } execute_get (plugin, stmt, proc, proc_cls); } @@ -1038,10 +1041,6 @@ sqlite_plugin_get_replication (void *cls, struct ReplCtx rc; uint64_t rvalue = 0; uint32_t repl; - struct GNUNET_SQ_QueryParam params_sel_repl[] = - { GNUNET_SQ_query_param_uint64 (&rvalue), - GNUNET_SQ_query_param_uint32 (&repl), - GNUNET_SQ_query_param_end }; struct GNUNET_SQ_QueryParam params_upd_repl[] = { GNUNET_SQ_query_param_uint64 (&rc.uid), GNUNET_SQ_query_param_end }; @@ -1056,12 +1055,18 @@ sqlite_plugin_get_replication (void *cls, return; } repl = sqlite3_column_int (plugin->maxRepl, 0); - GNUNET_SQ_reset (plugin->dbh, plugin->maxRepl); - rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); - if (GNUNET_OK != GNUNET_SQ_bind (plugin->selRepl, params_sel_repl)) { - proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); - return; + struct GNUNET_SQ_QueryParam params_sel_repl[] = + { GNUNET_SQ_query_param_uint64 (&rvalue), + GNUNET_SQ_query_param_uint32 (&repl), + GNUNET_SQ_query_param_end }; + GNUNET_SQ_reset (plugin->dbh, plugin->maxRepl); + rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); + if (GNUNET_OK != GNUNET_SQ_bind (plugin->selRepl, params_sel_repl)) + { + proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); + return; + } } rc.have_uid = GNUNET_SYSERR; rc.proc = proc; diff --git a/src/plugin/namecache/plugin_namecache_postgres.c b/src/plugin/namecache/plugin_namecache_postgres.c @@ -150,13 +150,8 @@ namecache_postgres_cache_block (void *cls, struct Plugin *plugin = cls; struct GNUNET_HashCode query; size_t block_size = GNUNET_GNSRECORD_block_get_size (block); - struct GNUNET_TIME_Absolute exp = GNUNET_GNSRECORD_block_get_expiration (block); - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_auto_from_type (&query), - GNUNET_PQ_query_param_fixed_size (block, block_size), - GNUNET_PQ_query_param_absolute_time (&exp), - GNUNET_PQ_query_param_end - }; + struct GNUNET_TIME_Absolute exp = GNUNET_GNSRECORD_block_get_expiration (block + ); enum GNUNET_DB_QueryStatus res; namecache_postgres_expire_blocks (plugin); @@ -167,13 +162,21 @@ namecache_postgres_cache_block (void *cls, GNUNET_break (0); return GNUNET_SYSERR; } - delete_old_block (plugin, - &query, - exp); - - res = GNUNET_PQ_eval_prepared_non_select (plugin->dbh, - "cache_block", - params); + { + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_auto_from_type (&query), + GNUNET_PQ_query_param_fixed_size (block, block_size), + GNUNET_PQ_query_param_absolute_time (&exp), + GNUNET_PQ_query_param_end + }; + delete_old_block (plugin, + &query, + exp); + + res = GNUNET_PQ_eval_prepared_non_select (plugin->dbh, + "cache_block", + params); + } if (0 > res) return GNUNET_SYSERR; return GNUNET_OK; @@ -256,6 +259,7 @@ database_shutdown (struct Plugin *plugin) plugin->dbh = NULL; } + void * libgnunet_plugin_namecache_postgres_init (void *cls); @@ -290,6 +294,7 @@ libgnunet_plugin_namecache_postgres_init (void *cls) return api; } + void * libgnunet_plugin_namecache_postgres_done (void *cls); diff --git a/src/plugin/namecache/plugin_namecache_sqlite.c b/src/plugin/namecache/plugin_namecache_sqlite.c @@ -330,18 +330,6 @@ namecache_sqlite_cache_block (void *cls, struct GNUNET_HashCode query; struct GNUNET_TIME_Absolute expiration; size_t block_size = GNUNET_GNSRECORD_block_get_size (block); - struct GNUNET_SQ_QueryParam del_params[] = { - GNUNET_SQ_query_param_auto_from_type (&query), - GNUNET_SQ_query_param_absolute_time (&expiration), - GNUNET_SQ_query_param_end - }; - struct GNUNET_SQ_QueryParam ins_params[] = { - GNUNET_SQ_query_param_auto_from_type (&query), - GNUNET_SQ_query_param_fixed_size (block, - block_size), - GNUNET_SQ_query_param_absolute_time (&expiration), - GNUNET_SQ_query_param_end - }; int n; /* run expiration of old cache entries once per hour */ @@ -364,16 +352,23 @@ namecache_sqlite_cache_block (void *cls, return GNUNET_SYSERR; } - /* delete old version of the block */ - if (GNUNET_OK != - GNUNET_SQ_bind (plugin->delete_block, - del_params)) { - LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, - "sqlite3_bind_XXXX"); - GNUNET_SQ_reset (plugin->dbh, - plugin->delete_block); - return GNUNET_SYSERR; + struct GNUNET_SQ_QueryParam del_params[] = { + GNUNET_SQ_query_param_auto_from_type (&query), + GNUNET_SQ_query_param_absolute_time (&expiration), + GNUNET_SQ_query_param_end + }; + /* delete old version of the block */ + if (GNUNET_OK != + GNUNET_SQ_bind (plugin->delete_block, + del_params)) + { + LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "sqlite3_bind_XXXX"); + GNUNET_SQ_reset (plugin->dbh, + plugin->delete_block); + return GNUNET_SYSERR; + } } n = sqlite3_step (plugin->delete_block); switch (n) @@ -398,18 +393,27 @@ namecache_sqlite_cache_block (void *cls, } GNUNET_SQ_reset (plugin->dbh, plugin->delete_block); - - /* insert new version of the block */ - if (GNUNET_OK != - GNUNET_SQ_bind (plugin->cache_block, - ins_params)) { - LOG_SQLITE (plugin, - GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, - "sqlite3_bind_XXXX"); - GNUNET_SQ_reset (plugin->dbh, - plugin->cache_block); - return GNUNET_SYSERR; + struct GNUNET_SQ_QueryParam ins_params[] = { + GNUNET_SQ_query_param_auto_from_type (&query), + GNUNET_SQ_query_param_fixed_size (block, + block_size), + GNUNET_SQ_query_param_absolute_time (&expiration), + GNUNET_SQ_query_param_end + }; + + /* insert new version of the block */ + if (GNUNET_OK != + GNUNET_SQ_bind (plugin->cache_block, + ins_params)) + { + LOG_SQLITE (plugin, + GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "sqlite3_bind_XXXX"); + GNUNET_SQ_reset (plugin->dbh, + plugin->cache_block); + return GNUNET_SYSERR; + } } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Caching block under derived key `%s'\n", @@ -530,6 +534,7 @@ namecache_sqlite_lookup_block (void *cls, return ret; } + void * libgnunet_plugin_namecache_sqlite_init (void *cls); @@ -564,6 +569,7 @@ libgnunet_plugin_namecache_sqlite_init (void *cls) return api; } + void * libgnunet_plugin_namecache_sqlite_done (void *cls); diff --git a/src/service/core/core_api.c b/src/service/core/core_api.c @@ -705,7 +705,7 @@ GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, * currently don't think so. I guess pils might be the * responsible service? */ const struct GNUNET_MQ_MessageHandler *handlers, - struct GNUNET_CORE_ServiceInfo *service_info) + const struct GNUNET_CORE_ServiceInfo *service_info) { struct GNUNET_CORE_Handle *h; diff --git a/src/service/core/gnunet_core_underlay_dummy.c b/src/service/core/gnunet_core_underlay_dummy.c @@ -52,7 +52,8 @@ extern "C" { #include "gnunet_util_lib.h" #include "gnunet_scheduler_lib.h" -#define LOG(kind, ...) GNUNET_log_from (kind, "core-underlay-dummy", __VA_ARGS__) +#define LOG(kind, ...) GNUNET_log_from (kind, "core-underlay-dummy", __VA_ARGS__ \ + ) #define SOCK_NAME_BASE "/tmp/gnunet-core-underlay-dummy-socket" #define SOCK_EXTENSION ".sock" @@ -316,21 +317,21 @@ status2string (enum ConnectionStatus status) { switch (status) { - case CONNECTION_INITIALIZING: - return "C_INITIALIZING"; - break; - case CONNECTION_INITIALIZING_SEND: - return "C_INITIALIZING_SEND"; - break; - case CONNECTION_INITIALIZING_RECV: - return "C_INITIALIZING_RECV"; - break; - case CONNECTION_LIVE: - return "C_LIVE"; - break; - case CONNECTION_DESTROY: - return "C_DESTROY"; - break; + case CONNECTION_INITIALIZING: + return "C_INITIALIZING"; + break; + case CONNECTION_INITIALIZING_SEND: + return "C_INITIALIZING_SEND"; + break; + case CONNECTION_INITIALIZING_RECV: + return "C_INITIALIZING_RECV"; + break; + case CONNECTION_LIVE: + return "C_LIVE"; + break; + case CONNECTION_DESTROY: + return "C_DESTROY"; + break; } return ""; /* Make compiler happy */ } @@ -398,7 +399,8 @@ connection_destroy (struct Connection *connection) GNUNET_NETWORK_socket_close (connection->sock); } GNUNET_free (connection->peer_addr); - if (NULL != connection->handlers) GNUNET_free (connection->handlers); + if (NULL != connection->handlers) + GNUNET_free (connection->handlers); /* Don't free the cls_mq - we don't own it! */ GNUNET_CONTAINER_DLL_remove (connection->handle->connections_head, connection->handle->connections_tail, @@ -407,6 +409,7 @@ connection_destroy (struct Connection *connection) LOG (GNUNET_ERROR_TYPE_DEBUG, "connection_destroy - end\n"); } + /***************************************************************************** * Connection-related functions (end) * ****************************************************************************/ @@ -442,16 +445,16 @@ do_handle_message (void *cls) connection->handle_message_task = NULL; connection->client_ready_to_receive = GNUNET_NO; GNUNET_CONTAINER_DLL_remove ( - connection->queued_recv_messages_head, - connection->queued_recv_messages_tail, - q_msg); + connection->queued_recv_messages_head, + connection->queued_recv_messages_tail, + q_msg); GNUNET_free (q_msg); // FIXME check return value!!! GNUNET_MQ_handle_message ( - connection->handlers, - msg); - //GNUNET_free (msg); // TODO what do we do with this pointer? Who owns it? - // Who cleans it? + connection->handlers, + msg); + // GNUNET_free (msg); // TODO what do we do with this pointer? Who owns it? + // Who cleans it? } @@ -467,7 +470,8 @@ check_for_messages (struct Connection *connection) } else if (NULL == connection->recv_task) { - LOG (GNUNET_ERROR_TYPE_DEBUG, "no messages in the queue - receive more from socket\n"); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "no messages in the queue - receive more from socket\n"); connection->recv_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, connection->sock, @@ -500,11 +504,11 @@ do_notify_connect (void *cls) * connection-specific cls is the return value of notify_connect and given to * the handlers. */ cls_mq = - h->notify_connect(h->cls, - 1, - (const char **) &connection->peer_addr, - connection->mq, - NULL); /* peer_id */ + h->notify_connect (h->cls, + 1, + (const char **) &connection->peer_addr, + connection->mq, + NULL); /* peer_id */ /* The handlers are copied because the connection-specific closures can be * set. The global handlers remain the same - they are just called with the * connection specific closures. */ @@ -513,7 +517,7 @@ do_notify_connect (void *cls) if (NULL != cls_mq) { connection->cls_mq = cls_mq; - //GNUNET_MQ_set_handlers_closure (connection->mq, connection->cls_mq); + // GNUNET_MQ_set_handlers_closure (connection->mq, connection->cls_mq); /* Overwrite the closure set above with the cls_mq */ set_handlers_closure (connection->handlers, connection->cls_mq); } @@ -545,18 +549,19 @@ cancel_initiating_connections (struct GNUNET_CORE_UNDERLAY_DUMMY_Handle *h, char *peer_addr = connection->peer_addr; LOG (GNUNET_ERROR_TYPE_DEBUG, - "Going to cancel all initializing connections to %s\n", - peer_addr); - if (NULL == peer_addr) return; /* No sense in comparing to unknown address */ + "Going to cancel all initializing connections to %s\n", + peer_addr); + if (NULL == peer_addr) + return; /* No sense in comparing to unknown address */ for (struct Connection *c_iter = h->connections_head; NULL != c_iter; c_iter = c_iter_next) { c_iter_next = c_iter->next; LOG (GNUNET_ERROR_TYPE_DEBUG, - " %s :%s\n", - c_iter->peer_addr, - status2string (c_iter->status)); + " %s :%s\n", + c_iter->peer_addr, + status2string (c_iter->status)); if ((c_iter != connection) && /* Don't shut down current connection */ (NULL != c_iter->peer_addr) && /* No address - can't compare */ (0 == strcmp (c_iter->peer_addr, peer_addr)) && @@ -566,7 +571,7 @@ cancel_initiating_connections (struct GNUNET_CORE_UNDERLAY_DUMMY_Handle *h, (CONNECTION_INITIALIZING_RECV == c_iter->status))) { LOG (GNUNET_ERROR_TYPE_DEBUG, - " -> Cancelling connection - MQ_destroy()\n"); + " -> Cancelling connection - MQ_destroy()\n"); GNUNET_MQ_destroy (c_iter->mq); } } @@ -589,9 +594,9 @@ do_read (void *cls) struct GNUNET_MessageHeader *msg; LOG (GNUNET_ERROR_TYPE_DEBUG, - "do_read(): receiving bytes from %s :%s\n", - connection->peer_addr, - status2string (connection->status)); + "do_read(): receiving bytes from %s :%s\n", + connection->peer_addr, + status2string (connection->status)); connection->recv_task = NULL; GNUNET_assert (NULL != connection->sock); ret = GNUNET_NETWORK_socket_recv (connection->sock, @@ -606,7 +611,8 @@ do_read (void *cls) } if (0 == ret) { - LOG (GNUNET_ERROR_TYPE_INFO, "Other peer closed connection - MQ_destroy()\n"); + LOG (GNUNET_ERROR_TYPE_INFO, + "Other peer closed connection - MQ_destroy()\n"); connection->status = CONNECTION_DESTROY; GNUNET_MQ_destroy (connection->mq); // This triggers mq_destroy_impl() return; @@ -627,8 +633,10 @@ do_read (void *cls) while (0 < ret_remain) { msg_iter = (struct GNUNET_MessageHeader *) buf_iter; - LOG (GNUNET_ERROR_TYPE_DEBUG, "Length of message: %d bytes\n", ntohs (msg_iter->size)); - LOG (GNUNET_ERROR_TYPE_DEBUG, "Remaining bytes of buffer: %ld\n", ret_remain); + LOG (GNUNET_ERROR_TYPE_DEBUG, "Length of message: %d bytes\n", ntohs ( + msg_iter->size)); + LOG (GNUNET_ERROR_TYPE_DEBUG, "Remaining bytes of buffer: %ld\n", + ret_remain); { // XXX only for debugging purposes @@ -640,22 +648,22 @@ do_read (void *cls) // The following will be used for debugging uint64_t id; // id of the message uint64_t batch; // first batch of that peer (for this test 0 or 1) - //uint64_t peer; // number of sending peer (for this test 0 or 1) + // uint64_t peer; // number of sending peer (for this test 0 or 1) }; - struct GNUNET_UNDERLAY_DUMMY_Message *msg_dbg = (struct GNUNET_UNDERLAY_DUMMY_Message *) msg_iter; - //LOG (GNUNET_ERROR_TYPE_DEBUG, "do_read - id: %u, batch: %u, peer: %u\n", - LOG (GNUNET_ERROR_TYPE_DEBUG, "do_read - id: %" PRIu64 ", batch: %" PRIu64 "\n", + // LOG (GNUNET_ERROR_TYPE_DEBUG, "do_read - id: %u, batch: %u, peer: %u\n", + LOG (GNUNET_ERROR_TYPE_DEBUG, "do_read - id: %" PRIu64 + ", batch: %" PRIu64 "\n", GNUNET_ntohll (msg_dbg->id), GNUNET_ntohll (msg_dbg->batch)); - //LOG (GNUNET_ERROR_TYPE_DEBUG, "do_read - size: %u\n", + // LOG (GNUNET_ERROR_TYPE_DEBUG, "do_read - size: %u\n", // ntohs (msg_dbg->size)); - //LOG (GNUNET_ERROR_TYPE_DEBUG, "do_read - (sanity) size msghdr: %u\n", + // LOG (GNUNET_ERROR_TYPE_DEBUG, "do_read - (sanity) size msghdr: %u\n", // sizeof (struct GNUNET_MessageHeader)); - //LOG (GNUNET_ERROR_TYPE_DEBUG, "do_read - (sanity) size msg field: %u\n", + // LOG (GNUNET_ERROR_TYPE_DEBUG, "do_read - (sanity) size msg field: %u\n", // sizeof (msg_dbg->id)); } buf_iter = buf_iter + ntohs (msg_iter->size); @@ -693,40 +701,40 @@ do_read (void *cls) // FIXME is it really meaningful to send multiple addresses? probably just // send the address that's used to open the connection LOG (GNUNET_ERROR_TYPE_DEBUG, - "Init-message: %s\n", - peer_addr_sent); + "Init-message: %s\n", + peer_addr_sent); if ((NULL != connection->peer_addr) && (0 != strcmp (peer_addr_sent, connection->peer_addr))) { LOG (GNUNET_ERROR_TYPE_ERROR, - "Peer sent us an Init-message with an address different from the one we already know. -> MQ_destroy()\n"); + "Peer sent us an Init-message with an address different from the one we already know. -> MQ_destroy()\n"); LOG (GNUNET_ERROR_TYPE_DEBUG, - "sent address: %s\n", - peer_addr_sent); + "sent address: %s\n", + peer_addr_sent); LOG (GNUNET_ERROR_TYPE_DEBUG, - "old address: %s\n", - connection->peer_addr); + "old address: %s\n", + connection->peer_addr); GNUNET_MQ_destroy (connection->mq); GNUNET_break_op (0); return; } switch (connection->status) { - case CONNECTION_INITIALIZING_SEND: - connection->status = CONNECTION_LIVE; - break; - case CONNECTION_INITIALIZING: - connection->status = CONNECTION_INITIALIZING_RECV; - break; - case CONNECTION_DESTROY: - return; - default: - break; + case CONNECTION_INITIALIZING_SEND: + connection->status = CONNECTION_LIVE; + break; + case CONNECTION_INITIALIZING: + connection->status = CONNECTION_INITIALIZING_RECV; + break; + case CONNECTION_DESTROY: + return; + default: + break; } LOG (GNUNET_ERROR_TYPE_DEBUG, - "Connection to %s is now %s\n", - connection->peer_addr, - status2string (connection->status)); + "Connection to %s is now %s\n", + connection->peer_addr, + status2string (connection->status)); // else: we could skip ahead to end of if - we do already know the peer_addr /* Check whether we already got a connection to that address/peer */ LOG (GNUNET_ERROR_TYPE_DEBUG, "Init - checking other connections\n"); @@ -735,9 +743,9 @@ do_read (void *cls) c_iter = c_iter->next) { LOG (GNUNET_ERROR_TYPE_DEBUG, - " %s (%s)\n", - c_iter->peer_addr, - status2string (c_iter->status)); + " %s (%s)\n", + c_iter->peer_addr, + status2string (c_iter->status)); if ((NULL != c_iter->peer_addr) && /* we can't compare the addr */ (0 == strcmp (peer_addr_sent, c_iter->peer_addr)) && /* same peer */ (CONNECTION_LIVE == c_iter->status) && /* other connection is live*/ @@ -746,8 +754,8 @@ do_read (void *cls) /* We already got a connection with this peer - tear the current one * down. */ LOG (GNUNET_ERROR_TYPE_DEBUG, - "Init from other peer - already connected: %s - MQ_destroy()\n", - peer_addr_sent); + "Init from other peer - already connected: %s - MQ_destroy()\n", + peer_addr_sent); connection->status = CONNECTION_DESTROY; GNUNET_MQ_destroy (connection->mq); return; @@ -755,13 +763,13 @@ do_read (void *cls) } connection->peer_addr = strdup (peer_addr_sent); LOG (GNUNET_ERROR_TYPE_DEBUG, - "Init-Message - notifying caller (%s :%s)\n", - connection->peer_addr, - status2string (connection->status)); + "Init-Message - notifying caller (%s :%s)\n", + connection->peer_addr, + status2string (connection->status)); try_notify_connect (connection); LOG (GNUNET_ERROR_TYPE_DEBUG, - "Finished initializing - going to cancel all still initializing connections to this address\n"); + "Finished initializing - going to cancel all still initializing connections to this address\n"); cancel_initiating_connections (connection->handle, connection); /* We need to schedule the recv_task here because this is not a message @@ -808,7 +816,7 @@ do_read (void *cls) if (GNUNET_YES == connection->client_ready_to_receive) { // TODO maybe just call check_for_messages() instead? - //check_for_messages (connection); + // check_for_messages (connection); // FIXME for now the above gives only an unsuccessful test - check why connection->client_ready_to_receive = GNUNET_NO; // FIXME check return value!!! @@ -833,9 +841,9 @@ write_cb (void *cls) connection->write_task = NULL; GNUNET_assert (NULL != connection->sock); LOG (GNUNET_ERROR_TYPE_DEBUG, - "write_cb(): sending bytes to %s :%s\n", - connection->peer_addr, - status2string (connection->status)); + "write_cb(): sending bytes to %s :%s\n", + connection->peer_addr, + status2string (connection->status)); { // XXX only for debugging purposes // this shows everything works as expected @@ -846,33 +854,34 @@ write_cb (void *cls) // The following will be used for debugging uint64_t id; // id of the message uint64_t batch; // first batch of that peer (for this test 0 or 1) - //uint64_t peer; // number of sending peer (for this test 0 or 1) + // uint64_t peer; // number of sending peer (for this test 0 or 1) }; - struct GNUNET_UNDERLAY_DUMMY_Message *msg_dbg = (struct GNUNET_UNDERLAY_DUMMY_Message *) connection->message_to_send; - //LOG (GNUNET_ERROR_TYPE_DEBUG, "write_cb - id: %u, batch: %u, peer: %u\n", - LOG (GNUNET_ERROR_TYPE_DEBUG, "write_cb - id: %" PRIu64 ", batch: %" PRIu64"\n", + // LOG (GNUNET_ERROR_TYPE_DEBUG, "write_cb - id: %u, batch: %u, peer: %u\n", + LOG (GNUNET_ERROR_TYPE_DEBUG, "write_cb - id: %" PRIu64 ", batch: %" PRIu64 + "\n", GNUNET_ntohll (msg_dbg->id), GNUNET_ntohll (msg_dbg->batch)); - //LOG (GNUNET_ERROR_TYPE_DEBUG, "write_cb - size: %u\n", + // LOG (GNUNET_ERROR_TYPE_DEBUG, "write_cb - size: %u\n", // ntohs (msg_dbg->size)); - //LOG (GNUNET_ERROR_TYPE_DEBUG, "write_cb - (sanity) size msghdr: %u\n", + // LOG (GNUNET_ERROR_TYPE_DEBUG, "write_cb - (sanity) size msghdr: %u\n", // sizeof (struct GNUNET_MessageHeader)); - //LOG (GNUNET_ERROR_TYPE_DEBUG, "write_cb - (sanity) size msg field: %u\n", + // LOG (GNUNET_ERROR_TYPE_DEBUG, "write_cb - (sanity) size msg field: %u\n", // sizeof (msg_dbg->id)); } GNUNET_assert (NULL != connection->message_to_send); sent = GNUNET_NETWORK_socket_send ( - connection->sock, - connection->message_to_send, - ntohs (connection->message_to_send->size)); + connection->sock, + connection->message_to_send, + ntohs (connection->message_to_send->size)); if (GNUNET_SYSERR == sent) { - //LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to send message\n"); - LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to send message: %s\n", strerror(errno)); + // LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to send message\n"); + LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to send message: %s\n", strerror ( + errno)); if (EPIPE == errno) { /* Tear down the connection */ @@ -895,25 +904,25 @@ write_cb (void *cls) connection->message_to_send = NULL; switch (connection->status) { - case CONNECTION_INITIALIZING_RECV: - connection->status = CONNECTION_LIVE; - try_notify_connect (connection); - LOG (GNUNET_ERROR_TYPE_DEBUG, - "Finished initializing - going to cancel all still initializing connections to this address\n"); - cancel_initiating_connections (connection->handle, connection); - break; - case CONNECTION_INITIALIZING: - connection->status = CONNECTION_INITIALIZING_SEND; - break; - case CONNECTION_DESTROY: - return; - default: - break; + case CONNECTION_INITIALIZING_RECV: + connection->status = CONNECTION_LIVE; + try_notify_connect (connection); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Finished initializing - going to cancel all still initializing connections to this address\n"); + cancel_initiating_connections (connection->handle, connection); + break; + case CONNECTION_INITIALIZING: + connection->status = CONNECTION_INITIALIZING_SEND; + break; + case CONNECTION_DESTROY: + return; + default: + break; } LOG (GNUNET_ERROR_TYPE_DEBUG, - "Connection to %s is now %s\n", - connection->peer_addr, - status2string (connection->status)); + "Connection to %s is now %s\n", + connection->peer_addr, + status2string (connection->status)); GNUNET_MQ_impl_send_continue (connection->mq); } @@ -927,12 +936,12 @@ send_init (struct Connection *connection) GNUNET_assert (NULL != connection->handle->sock_name); LOG (GNUNET_ERROR_TYPE_DEBUG, - "Sending init: %s\n", - connection->handle->sock_name); + "Sending init: %s\n", + connection->handle->sock_name); peer_addr_len = strnlen (connection->handle->sock_name, 128) + 1; env = GNUNET_MQ_msg_header_extra (msg, // usually we wanted to keep the - peer_addr_len, // envelopes to potentially cancel the - 0); // message + peer_addr_len, // envelopes to potentially cancel the + 0); // message GNUNET_memcpy (&msg[1], connection->handle->sock_name, peer_addr_len); GNUNET_MQ_send (connection->mq, env); } @@ -964,7 +973,7 @@ mq_send_impl (struct GNUNET_MQ_Handle *mq, // The following will be used for debugging uint64_t id; // id of the message uint64_t batch; // first batch of that peer (for this test 0 or 1) - //uint64_t peer; // number of sending peer (for this test 0 or 1) + // uint64_t peer; // number of sending peer (for this test 0 or 1) }; struct GNUNET_UNDERLAY_DUMMY_Message *msg_dbg = @@ -1031,8 +1040,8 @@ static void mq_error_handler_impl (void *cls, enum GNUNET_MQ_Error error) { LOG (GNUNET_ERROR_TYPE_ERROR, - "mq_error_handler_impl: %u\n", - error); + "mq_error_handler_impl: %u\n", + error); } @@ -1067,14 +1076,14 @@ do_accept (void *cls) &addr_other_len); if (NULL == sock) { - //LOG(GNUNET_ERROR_TYPE_ERROR, "Error accepting incoming connection, %s", strerror(errno)); + // LOG(GNUNET_ERROR_TYPE_ERROR, "Error accepting incoming connection, %s", strerror(errno)); LOG (GNUNET_ERROR_TYPE_ERROR, "Error accepting incoming connection\n"); return; } if (GNUNET_OK != GNUNET_NETWORK_socket_set_blocking (sock, GNUNET_NO)) { LOG (GNUNET_ERROR_TYPE_ERROR, - "Failed setting socket of incoming connection to non-blocking\n"); + "Failed setting socket of incoming connection to non-blocking\n"); return; } connection = GNUNET_new (struct Connection); @@ -1151,18 +1160,20 @@ do_connect_to_peer (void *cls) } addr_other.sun_family = AF_UNIX; - //strcpy (addr_other.sun_path, pcc->sock_name); - GNUNET_memcpy (addr_other.sun_path, pcc->sock_name, strlen (pcc->sock_name)); + // strcpy (addr_other.sun_path, pcc->sock_name); + GNUNET_memcpy (addr_other.sun_path, pcc->sock_name, strlen (pcc->sock_name)) + ; if (GNUNET_OK != GNUNET_NETWORK_socket_connect (connection->sock, - (struct sockaddr *) &addr_other, + (struct sockaddr *) & + addr_other, sizeof(addr_other))) { LOG (GNUNET_ERROR_TYPE_ERROR, - "failed to connect to the socket: %u %s (closing socket)\n", - errno, strerror(errno)); + "failed to connect to the socket: %u %s (closing socket)\n", + errno, strerror (errno)); GNUNET_NETWORK_socket_close (connection->sock); GNUNET_free (connection); - //LOG (GNUNET_ERROR_TYPE_INFO, "Sanity check: %s\n", addr_other.sun_path); + // LOG (GNUNET_ERROR_TYPE_INFO, "Sanity check: %s\n", addr_other.sun_path); return; } connection->peer_addr = GNUNET_strdup (pcc->sock_name); @@ -1224,8 +1235,8 @@ try_connect (struct GNUNET_CORE_UNDERLAY_DUMMY_Handle *h, const char *address) return; } LOG (GNUNET_ERROR_TYPE_INFO, - "Discovered another peer with address `%s'\n", - address); + "Discovered another peer with address `%s'\n", + address); /** * Check whether we are already connected to this peer @@ -1238,14 +1249,15 @@ try_connect (struct GNUNET_CORE_UNDERLAY_DUMMY_Handle *h, const char *address) conn_iter = conn_iter->next) { LOG (GNUNET_ERROR_TYPE_DEBUG, - " %s (%s)\n", - conn_iter->peer_addr, - status2string (conn_iter->status)); + " %s (%s)\n", + conn_iter->peer_addr, + status2string (conn_iter->status)); if ((NULL != conn_iter->peer_addr) && (0 == strcmp (address, conn_iter->peer_addr)) && (CONNECTION_LIVE == conn_iter->status)) { - LOG (GNUNET_ERROR_TYPE_DEBUG, "Already connected to this peer - don't try to open another connection\n"); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Already connected to this peer - don't try to open another connection\n"); return; } } @@ -1256,7 +1268,8 @@ try_connect (struct GNUNET_CORE_UNDERLAY_DUMMY_Handle *h, const char *address) if (0 == strcmp (address, pcc_iter->sock_name)) { - LOG (GNUNET_ERROR_TYPE_DEBUG, "Already waiting to connect to this peer\n"); + LOG (GNUNET_ERROR_TYPE_DEBUG, "Already waiting to connect to this peer\n") + ; return; } } @@ -1321,13 +1334,14 @@ do_discover_peers (void *cls) h); if (0 > ret) { - LOG (GNUNET_ERROR_TYPE_WARNING, "Scanning for unix domain sockets failed\n"); + LOG (GNUNET_ERROR_TYPE_WARNING, "Scanning for unix domain sockets failed\n") + ; } h->peer_discovery_task = GNUNET_SCHEDULER_add_delayed ( - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100), - do_discover_peers, - h); + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100), + do_discover_peers, + h); } @@ -1350,14 +1364,14 @@ try_open_listening_socket (struct GNUNET_CORE_UNDERLAY_DUMMY_Handle *h, addr_un_len = sizeof (struct sockaddr_un); LOG (GNUNET_ERROR_TYPE_DEBUG, "Trying to bind to `%s'\n", addr_un->sun_path); ret = GNUNET_NETWORK_socket_bind (h->sock_listen, - (struct sockaddr *) addr_un, - addr_un_len); + (struct sockaddr *) addr_un, + addr_un_len); if ((GNUNET_OK != ret) && (98 != errno)) { /* Error different from Address already in use - cancel */ LOG (GNUNET_ERROR_TYPE_ERROR, - "Failed binding to socket: %u %s (closing socket)\n", - errno, strerror(errno)); + "Failed binding to socket: %u %s (closing socket)\n", + errno, strerror (errno)); GNUNET_NETWORK_socket_close (h->sock_listen); h->sock_listen = NULL; GNUNET_free (addr_un); @@ -1366,7 +1380,7 @@ try_open_listening_socket (struct GNUNET_CORE_UNDERLAY_DUMMY_Handle *h, else if (GNUNET_OK != ret) { LOG (GNUNET_ERROR_TYPE_DEBUG, - " -> something went wrong (address is probably in use)\n"); + " -> something went wrong (address is probably in use)\n"); GNUNET_NETWORK_socket_close (h->sock_listen); h->sock_listen = NULL; GNUNET_free (addr_un); @@ -1374,7 +1388,7 @@ try_open_listening_socket (struct GNUNET_CORE_UNDERLAY_DUMMY_Handle *h, else if (GNUNET_OK == ret) { LOG (GNUNET_ERROR_TYPE_DEBUG, - " -> succeeded! (binding to socket)\n"); + " -> succeeded! (binding to socket)\n"); h->sock_name = GNUNET_strdup (sock_name); } GNUNET_free (addr_un); @@ -1382,7 +1396,6 @@ try_open_listening_socket (struct GNUNET_CORE_UNDERLAY_DUMMY_Handle *h, } - /** * Opens UNIX domain socket. * @@ -1407,10 +1420,12 @@ do_open_listening_socket (void *cls, // TODO we might want to change this loop to schedule a new task do { GNUNET_asprintf (&sock_name, - SOCK_NAME_BASE "%" PRIu64 "" SOCK_EXTENSION "\0", sock_name_ctr++); + SOCK_NAME_BASE "%" PRIu64 "" SOCK_EXTENSION "\0", + sock_name_ctr++); ret = try_open_listening_socket (h, sock_name); GNUNET_free (sock_name); - if (GNUNET_SYSERR == ret) return; + if (GNUNET_SYSERR == ret) + return; } while (GNUNET_YES != ret); LOG (GNUNET_ERROR_TYPE_INFO, "Bound to `%s'\n", h->sock_name); h->sock_name_index_start = sock_name_ctr_start; @@ -1419,8 +1434,9 @@ do_open_listening_socket (void *cls, LOG (GNUNET_ERROR_TYPE_DEBUG, "Mark socket as accepting connections\n"); if (GNUNET_OK != GNUNET_NETWORK_socket_listen (h->sock_listen, BACKLOG)) { - //LOG (GNUNET_ERROR_TYPE_ERROR, "Failed listening to socket: %s", strerror(errno)); - LOG (GNUNET_ERROR_TYPE_ERROR, "Failed listening to socket (closing socket)\n"); + // LOG (GNUNET_ERROR_TYPE_ERROR, "Failed listening to socket: %s", strerror(errno)); + LOG (GNUNET_ERROR_TYPE_ERROR, + "Failed listening to socket (closing socket)\n"); GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (h->sock_listen)); h->sock_listen = NULL; GNUNET_free (h->sock_name); @@ -1437,9 +1453,9 @@ do_open_listening_socket (void *cls, LOG (GNUNET_ERROR_TYPE_DEBUG, "scheudle do_discover_peers()\n"); h->peer_discovery_task = GNUNET_SCHEDULER_add_delayed ( - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100), - do_discover_peers, - h); + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100), + do_discover_peers, + h); LOG (GNUNET_ERROR_TYPE_INFO, "Going to listen for connections\n"); h->listen_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, @@ -1509,18 +1525,6 @@ do_close_listening_socket (void *cls) } -static void -do_change_address (void *cls) -{ - struct GNUNET_CORE_UNDERLAY_DUMMY_Handle *h = cls; - GNUNET_CORE_UNDERLAY_DUMMY_change_address (h); - h->address_change_task = GNUNET_SCHEDULER_add_delayed ( - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), - do_change_address, - h); -} - - /** * Connect to the core underlay dummy service. Note that the connection may * complete (or fail) asynchronously. @@ -1538,12 +1542,12 @@ do_change_address (void *cls) */ struct GNUNET_CORE_UNDERLAY_DUMMY_Handle * GNUNET_CORE_UNDERLAY_DUMMY_connect ( - const struct GNUNET_CONFIGURATION_Handle *cfg, - const struct GNUNET_MQ_MessageHandler *handlers, - void *cls, - GNUNET_CORE_UNDERLAY_DUMMY_NotifyConnect nc, - GNUNET_CORE_UNDERLAY_DUMMY_NotifyDisconnect nd, - GNUNET_CORE_UNDERLAY_DUMMY_NotifyAddressChange na) + const struct GNUNET_CONFIGURATION_Handle *cfg, + const struct GNUNET_MQ_MessageHandler *handlers, + void *cls, + GNUNET_CORE_UNDERLAY_DUMMY_NotifyConnect nc, + GNUNET_CORE_UNDERLAY_DUMMY_NotifyDisconnect nd, + GNUNET_CORE_UNDERLAY_DUMMY_NotifyAddressChange na) { struct GNUNET_CORE_UNDERLAY_DUMMY_Handle *h; @@ -1551,12 +1555,13 @@ GNUNET_CORE_UNDERLAY_DUMMY_connect ( h->notify_connect = nc; h->notify_disconnect = nd; h->notify_address_change = na; - if (NULL != handlers) h->handlers = GNUNET_MQ_copy_handlers (handlers); + if (NULL != handlers) + h->handlers = GNUNET_MQ_copy_handlers (handlers); h->cls = cls; do_open_listening_socket (h, 0); - //h->address_change_task = GNUNET_SCHEDULER_add_delayed ( + // h->address_change_task = GNUNET_SCHEDULER_add_delayed ( // GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), // do_change_address, // h); @@ -1574,14 +1579,15 @@ GNUNET_CORE_UNDERLAY_DUMMY_connect ( */ void GNUNET_CORE_UNDERLAY_DUMMY_disconnect -(struct GNUNET_CORE_UNDERLAY_DUMMY_Handle *handle) + (struct GNUNET_CORE_UNDERLAY_DUMMY_Handle *handle) { LOG (GNUNET_ERROR_TYPE_INFO, "Core disconnects\n"); // TODO delete, free and close everything if (NULL != handle->address_change_task) GNUNET_SCHEDULER_cancel (handle->address_change_task); do_close_listening_socket (handle); - if (NULL != handle->handlers) GNUNET_free (handle->handlers); + if (NULL != handle->handlers) + GNUNET_free (handle->handlers); GNUNET_free (handle->sock_name); GNUNET_free (handle); LOG (GNUNET_ERROR_TYPE_INFO, " -> Disconnected\n"); @@ -1610,8 +1616,8 @@ GNUNET_CORE_UNDERLAY_DUMMY_disconnect */ void GNUNET_CORE_UNDERLAY_DUMMY_receive_continue ( - struct GNUNET_CORE_UNDERLAY_DUMMY_Handle *h, - struct GNUNET_MQ_Handle *mq) + struct GNUNET_CORE_UNDERLAY_DUMMY_Handle *h, + struct GNUNET_MQ_Handle *mq) { struct Connection *connection; @@ -1649,10 +1655,10 @@ GNUNET_CORE_UNDERLAY_DUMMY_receive_continue ( */ void GNUNET_CORE_UNDERLAY_DUMMY_connect_to_peer ( - struct GNUNET_CORE_UNDERLAY_DUMMY_Handle *h, - const char *peer_address, - enum GNUNET_MQ_PriorityPreferences pp, - struct GNUNET_BANDWIDTH_Value32NBO bw) + struct GNUNET_CORE_UNDERLAY_DUMMY_Handle *h, + const char *peer_address, + enum GNUNET_MQ_PriorityPreferences pp, + struct GNUNET_BANDWIDTH_Value32NBO bw) { // TODO PriorityPreferences // TODO BANDWIDTH_Value @@ -1665,7 +1671,7 @@ GNUNET_CORE_UNDERLAY_DUMMY_connect_to_peer ( */ void GNUNET_CORE_UNDERLAY_DUMMY_change_address ( - struct GNUNET_CORE_UNDERLAY_DUMMY_Handle *h) + struct GNUNET_CORE_UNDERLAY_DUMMY_Handle *h) { LOG (GNUNET_ERROR_TYPE_DEBUG, "Changing address!\n"); do_close_listening_socket (h); diff --git a/src/service/core/testing_core_cmd_recv.c b/src/service/core/testing_core_cmd_recv.c @@ -223,7 +223,7 @@ exec_recv_run (void *cls, struct GNUNET_TESTING_Interpreter *is) { struct RecvState *rs = cls; - const struct GNUNET_TESTING_CORE_ConnectState *connect_state; + struct GNUNET_TESTING_CORE_ConnectState *connect_state; if (GNUNET_OK != GNUNET_CORE_TESTING_get_trait_connect ( // TODO make the "connect" an input to the command diff --git a/src/service/core/testing_core_cmd_send.c b/src/service/core/testing_core_cmd_send.c @@ -46,7 +46,7 @@ connect_cb (void *cls, struct SendState { - const struct GNUNET_TESTING_CORE_ConnectState *connect_state; + struct GNUNET_TESTING_CORE_ConnectState *connect_state; uint64_t num_messages; enum GNUNET_GenericReturnValue await_new_connection; }; @@ -55,7 +55,7 @@ struct SendState static void cleanup_callbacks (struct SendState *send_state) { - const struct GNUNET_TESTING_CORE_ConnectState *connect_state = + struct GNUNET_TESTING_CORE_ConnectState *connect_state = send_state->connect_state; struct GNUNET_TESTING_CORE_ConnectCb *connect_cb_iter; @@ -152,7 +152,7 @@ exec_send_run (void *cls, struct GNUNET_TESTING_Interpreter *is) { struct SendState *send_state = cls; - const struct GNUNET_TESTING_CORE_ConnectState *connect_state; + struct GNUNET_TESTING_CORE_ConnectState *connect_state; // TODO make the "connect" label an input to the command if (GNUNET_OK != GNUNET_CORE_TESTING_get_trait_connect ( @@ -192,7 +192,7 @@ exec_send_run (void *cls, static void exec_send_cleanup (void *cls) { - struct GNUNET_TESTING_CORE_ConnectState *connect_state = cls; + // struct GNUNET_TESTING_CORE_ConnectState *connect_state = cls; } diff --git a/src/service/messenger/gnunet-service-messenger_message_send.c b/src/service/messenger/gnunet-service-messenger_message_send.c @@ -266,7 +266,7 @@ traverse_epoch_session_message (struct GNUNET_MESSENGER_MemberNotify *notify, if (! session) { struct GNUNET_MESSENGER_MemberStore *member_store; - struct GNUNET_MESSENGER_Member *member; + struct GNUNET_MESSENGER_Member *member = NULL; if (GNUNET_MESSENGER_KIND_MERGE == message->header.kind) goto skip_session; diff --git a/src/service/regex/regex_internal.c b/src/service/regex/regex_internal.c @@ -3394,7 +3394,7 @@ iterate_initial_edge (unsigned int min_len, "Start state at split edge `%s'-`%s` is %s\n", temp, edge[0].label, - GNUNET_h2s (&hash_new)); + GNUNET_h2s (&hash)); iterator (iterator_cls, &hash, temp, GNUNET_NO, 1, edge); GNUNET_free (temp); } diff --git a/src/service/rest/oidc_helper.c b/src/service/rest/oidc_helper.c @@ -175,12 +175,6 @@ generate_userinfo_json (const struct GNUNET_CRYPTO_PublicKey *sub_key, json_t *aggr_sources; json_t *aggr_sources_jwt; json_t *addr_claim = NULL; - int num_presentations = 0; - for (le = attrs->list_head; NULL != le; le = le->next) - { - if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->credential)) - num_presentations++; - } subject = GNUNET_STRINGS_data_to_string_alloc (sub_key,