aboutsummaryrefslogtreecommitdiff
path: root/src/psycstore
diff options
context:
space:
mode:
authorChristophe Genevey Metat <genevey.christophe@gmail.com>2016-07-29 08:11:28 +0000
committerChristophe Genevey Metat <genevey.christophe@gmail.com>2016-07-29 08:11:28 +0000
commitd0952436974f4618d0f3d644c71ac096879fa4c7 (patch)
tree283c5c118ef10255a014fe8372c060d81f7a5f00 /src/psycstore
parentc944678c3cc79704d6e16a0790e3044c0fb334a2 (diff)
downloadgnunet-d0952436974f4618d0f3d644c71ac096879fa4c7.tar.gz
gnunet-d0952436974f4618d0f3d644c71ac096879fa4c7.zip
fix fragment_get function
Diffstat (limited to 'src/psycstore')
-rw-r--r--src/psycstore/plugin_psycstore_mysql.c60
1 files changed, 29 insertions, 31 deletions
diff --git a/src/psycstore/plugin_psycstore_mysql.c b/src/psycstore/plugin_psycstore_mysql.c
index 4c28b00b0..dfdb1cd67 100644
--- a/src/psycstore/plugin_psycstore_mysql.c
+++ b/src/psycstore/plugin_psycstore_mysql.c
@@ -330,9 +330,9 @@ database_setup (struct Plugin *plugin)
330 " channel_id INT NOT NULL REFERENCES channels(id),\n" 330 " channel_id INT NOT NULL REFERENCES channels(id),\n"
331 " slave_id INT NOT NULL REFERENCES slaves(id),\n" 331 " slave_id INT NOT NULL REFERENCES slaves(id),\n"
332 " did_join INT NOT NULL,\n" 332 " did_join INT NOT NULL,\n"
333 " announced_at INT NOT NULL,\n" 333 " announced_at BIGINT UNSIGNED NOT NULL,\n"
334 " effective_since INT NOT NULL,\n" 334 " effective_since BIGINT UNSIGNED NOT NULL,\n"
335 " group_generation INT NOT NULL\n" 335 " group_generation BIGINT UNSIGNED NOT NULL\n"
336 ");"); 336 ");");
337 337
338/*** FIX because IF NOT EXISTS doesn't work ***/ 338/*** FIX because IF NOT EXISTS doesn't work ***/
@@ -344,15 +344,15 @@ database_setup (struct Plugin *plugin)
344 GNUNET_MYSQL_statement_run (plugin->mc, 344 GNUNET_MYSQL_statement_run (plugin->mc,
345 "CREATE TABLE IF NOT EXISTS messages (\n" 345 "CREATE TABLE IF NOT EXISTS messages (\n"
346 " channel_id INT NOT NULL REFERENCES channels(id),\n" 346 " channel_id INT NOT NULL REFERENCES channels(id),\n"
347 " hop_counter INT NOT NULL,\n" 347 " hop_counter BIGINT UNSIGNED NOT NULL,\n"
348 " signature BLOB,\n" 348 " signature BLOB,\n"
349 " purpose BLOB,\n" 349 " purpose BLOB,\n"
350 " fragment_id INT NOT NULL,\n" 350 " fragment_id BIGINT UNSIGNED NOT NULL,\n"
351 " fragment_offset INT NOT NULL,\n" 351 " fragment_offset BIGINT UNSIGNED NOT NULL,\n"
352 " message_id INT NOT NULL,\n" 352 " message_id BIGINT UNSIGNED NOT NULL,\n"
353 " group_generation INT NOT NULL,\n" 353 " group_generation BIGINT UNSIGNED NOT NULL,\n"
354 " multicast_flags INT NOT NULL,\n" 354 " multicast_flags BIGINT UNSIGNED NOT NULL,\n"
355 " psycstore_flags INT NOT NULL,\n" 355 " psycstore_flags BIGINT UNSIGNED NOT NULL,\n"
356 " data BLOB,\n" 356 " data BLOB,\n"
357 " PRIMARY KEY (channel_id, fragment_id),\n" 357 " PRIMARY KEY (channel_id, fragment_id),\n"
358 " UNIQUE KEY(channel_id, message_id, fragment_offset)\n" 358 " UNIQUE KEY(channel_id, message_id, fragment_offset)\n"
@@ -952,6 +952,7 @@ fragment_store (void *cls,
952 GNUNET_assert (TRANSACTION_NONE == plugin->transaction); 952 GNUNET_assert (TRANSACTION_NONE == plugin->transaction);
953 953
954 uint64_t fragment_id = GNUNET_ntohll (msg->fragment_id); 954 uint64_t fragment_id = GNUNET_ntohll (msg->fragment_id);
955
955 uint64_t fragment_offset = GNUNET_ntohll (msg->fragment_offset); 956 uint64_t fragment_offset = GNUNET_ntohll (msg->fragment_offset);
956 uint64_t message_id = GNUNET_ntohll (msg->message_id); 957 uint64_t message_id = GNUNET_ntohll (msg->message_id);
957 uint64_t group_generation = GNUNET_ntohll (msg->group_generation); 958 uint64_t group_generation = GNUNET_ntohll (msg->group_generation);
@@ -978,8 +979,6 @@ fragment_store (void *cls,
978 GNUNET_MY_query_param_uint64 (&hop_counter), 979 GNUNET_MY_query_param_uint64 (&hop_counter),
979 GNUNET_MY_query_param_auto_from_type (&msg->signature), 980 GNUNET_MY_query_param_auto_from_type (&msg->signature),
980 GNUNET_MY_query_param_auto_from_type (&msg->purpose), 981 GNUNET_MY_query_param_auto_from_type (&msg->purpose),
981 //GNUNET_MY_query_param_fixed_size (&msg->signature, sizeof (msg->signature)),
982 //GNUNET_MY_query_param_fixed_size (&msg->purpose, sizeof (msg->purpose)),
983 GNUNET_MY_query_param_uint64 (&fragment_id), 982 GNUNET_MY_query_param_uint64 (&fragment_id),
984 GNUNET_MY_query_param_uint64 (&fragment_offset), 983 GNUNET_MY_query_param_uint64 (&fragment_offset),
985 GNUNET_MY_query_param_uint64 (&message_id), 984 GNUNET_MY_query_param_uint64 (&message_id),
@@ -1062,25 +1061,24 @@ fragment_row (struct GNUNET_MYSQL_StatementHandle *stmt,
1062 void *cb_cls) 1061 void *cb_cls)
1063{ 1062{
1064 1063
1064 uint32_t hop_counter;
1065 void *signature = NULL;
1066 void *purpose = NULL;
1067 size_t signature_size;
1068 size_t purpose_size;
1069
1065 uint64_t fragment_id; 1070 uint64_t fragment_id;
1066 uint64_t fragment_offset; 1071 uint64_t fragment_offset;
1067 uint64_t message_id; 1072 uint64_t message_id;
1068 uint64_t group_generation; 1073 uint64_t group_generation;
1074 uint64_t flags;
1069 void *buf; 1075 void *buf;
1070 size_t buf_size; 1076 size_t buf_size;
1071 int ret = GNUNET_SYSERR; 1077 int ret = GNUNET_SYSERR;
1072 int sql_ret; 1078 int sql_ret;
1073 uint64_t flags;
1074 struct GNUNET_MULTICAST_MessageHeader msg;
1075 struct GNUNET_MULTICAST_MessageHeader *mp; 1079 struct GNUNET_MULTICAST_MessageHeader *mp;
1076 1080
1077 1081 uint64_t msg_flags;
1078 uint32_t hop_counter;
1079 void *signature = NULL;
1080 void *purpose = NULL;
1081 size_t signature_size;
1082 size_t purpose_size;
1083 uint32_t msg_flags;
1084 1082
1085 1083
1086 struct GNUNET_MY_ResultSpec results[] = { 1084 struct GNUNET_MY_ResultSpec results[] = {
@@ -1091,7 +1089,7 @@ fragment_row (struct GNUNET_MYSQL_StatementHandle *stmt,
1091 GNUNET_MY_result_spec_uint64 (&fragment_offset), 1089 GNUNET_MY_result_spec_uint64 (&fragment_offset),
1092 GNUNET_MY_result_spec_uint64 (&message_id), 1090 GNUNET_MY_result_spec_uint64 (&message_id),
1093 GNUNET_MY_result_spec_uint64 (&group_generation), 1091 GNUNET_MY_result_spec_uint64 (&group_generation),
1094 GNUNET_MY_result_spec_uint32 (&msg_flags), 1092 GNUNET_MY_result_spec_uint64 (&msg_flags),
1095 GNUNET_MY_result_spec_uint64 (&flags), 1093 GNUNET_MY_result_spec_uint64 (&flags),
1096 GNUNET_MY_result_spec_variable_size (&buf, 1094 GNUNET_MY_result_spec_variable_size (&buf,
1097 &buf_size), 1095 &buf_size),
@@ -1108,9 +1106,11 @@ fragment_row (struct GNUNET_MYSQL_StatementHandle *stmt,
1108 break; 1106 break;
1109 case GNUNET_OK: 1107 case GNUNET_OK:
1110 1108
1111 mp = GNUNET_malloc (sizeof (msg) + buf_size); 1109 mp = GNUNET_malloc (sizeof (*mp) + buf_size);
1112 *mp = msg; 1110
1113 mp->hop_counter = hop_counter; 1111 mp->header.size = htons (sizeof (*mp) + buf_size);
1112 mp->header.type = htons (GNUNET_MESSAGE_TYPE_MULTICAST_MESSAGE);
1113 mp->hop_counter = htonl (hop_counter);
1114 GNUNET_memcpy (&mp->signature, 1114 GNUNET_memcpy (&mp->signature,
1115 signature, 1115 signature,
1116 signature_size); 1116 signature_size);
@@ -1121,7 +1121,7 @@ fragment_row (struct GNUNET_MYSQL_StatementHandle *stmt,
1121 mp->fragment_offset = GNUNET_htonll (fragment_offset); 1121 mp->fragment_offset = GNUNET_htonll (fragment_offset);
1122 mp->message_id = GNUNET_htonll (message_id); 1122 mp->message_id = GNUNET_htonll (message_id);
1123 mp->group_generation = GNUNET_htonll (group_generation); 1123 mp->group_generation = GNUNET_htonll (group_generation);
1124 mp->flags = msg_flags; 1124 mp->flags = htonl(msg_flags);
1125 1125
1126 GNUNET_memcpy (&mp[1], 1126 GNUNET_memcpy (&mp[1],
1127 buf, 1127 buf,
@@ -1129,17 +1129,15 @@ fragment_row (struct GNUNET_MYSQL_StatementHandle *stmt,
1129 ret = cb (cb_cls, 1129 ret = cb (cb_cls,
1130 mp, 1130 mp,
1131 (enum GNUNET_PSYCSTORE_MessageFlags) flags); 1131 (enum GNUNET_PSYCSTORE_MessageFlags) flags);
1132 if (ret != GNUNET_YES) 1132
1133 sql_ret = GNUNET_NO; 1133 GNUNET_MY_cleanup_result (results);
1134 GNUNET_free (mp); 1134
1135 break; 1135 break;
1136 default: 1136 default:
1137 LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 1137 LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
1138 "mysql extract_result", stmt); 1138 "mysql extract_result", stmt);
1139 } 1139 }
1140 1140
1141// GNUNET_MY_cleanup_result (results);
1142
1143 return ret; 1141 return ret;
1144} 1142}
1145 1143