diff options
Diffstat (limited to 'src/datacache/plugin_datacache_mysql.c')
-rw-r--r-- | src/datacache/plugin_datacache_mysql.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/src/datacache/plugin_datacache_mysql.c b/src/datacache/plugin_datacache_mysql.c index 810342908..1457eddfb 100644 --- a/src/datacache/plugin_datacache_mysql.c +++ b/src/datacache/plugin_datacache_mysql.c | |||
@@ -87,7 +87,7 @@ | |||
87 | /** | 87 | /** |
88 | * Estimate of the per-entry overhead (including indices). | 88 | * Estimate of the per-entry overhead (including indices). |
89 | */ | 89 | */ |
90 | #define OVERHEAD ((4*2+4*2+8*2+8*2+sizeof(GNUNET_HashCode)*5+8)) | 90 | #define OVERHEAD ((4*2+4*2+8*2+8*2+sizeof(struct GNUNET_HashCode)*5+8)) |
91 | 91 | ||
92 | /** | 92 | /** |
93 | * Die with an error message that indicates | 93 | * Die with an error message that indicates |
@@ -190,7 +190,7 @@ itable (struct Plugin *plugin) | |||
190 | * @return 0 on error, number of bytes used otherwise | 190 | * @return 0 on error, number of bytes used otherwise |
191 | */ | 191 | */ |
192 | static size_t | 192 | static size_t |
193 | mysql_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size, | 193 | mysql_plugin_put (void *cls, const struct GNUNET_HashCode * key, size_t size, |
194 | const char *data, enum GNUNET_BLOCK_Type type, | 194 | const char *data, enum GNUNET_BLOCK_Type type, |
195 | struct GNUNET_TIME_Absolute discard_time) | 195 | struct GNUNET_TIME_Absolute discard_time) |
196 | { | 196 | { |
@@ -202,7 +202,7 @@ mysql_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size, | |||
202 | unsigned long long v_now; | 202 | unsigned long long v_now; |
203 | unsigned long long v_discard_time; | 203 | unsigned long long v_discard_time; |
204 | unsigned int v_type; | 204 | unsigned int v_type; |
205 | GNUNET_HashCode vhash; | 205 | struct GNUNET_HashCode vhash; |
206 | int ret; | 206 | int ret; |
207 | 207 | ||
208 | if (size > GNUNET_SERVER_MAX_MESSAGE_SIZE) | 208 | if (size > GNUNET_SERVER_MAX_MESSAGE_SIZE) |
@@ -211,8 +211,8 @@ mysql_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size, | |||
211 | now = GNUNET_TIME_absolute_get (); | 211 | now = GNUNET_TIME_absolute_get (); |
212 | 212 | ||
213 | /* first try UPDATE */ | 213 | /* first try UPDATE */ |
214 | h_length = sizeof (GNUNET_HashCode); | 214 | h_length = sizeof (struct GNUNET_HashCode); |
215 | k_length = sizeof (GNUNET_HashCode); | 215 | k_length = sizeof (struct GNUNET_HashCode); |
216 | v_length = size; | 216 | v_length = size; |
217 | v_type = type; | 217 | v_type = type; |
218 | v_now = (unsigned long long) now.abs_value; | 218 | v_now = (unsigned long long) now.abs_value; |
@@ -221,15 +221,15 @@ mysql_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size, | |||
221 | GNUNET_MYSQL_statement_run_prepared (plugin->mc, plugin->update_value, NULL, | 221 | GNUNET_MYSQL_statement_run_prepared (plugin->mc, plugin->update_value, NULL, |
222 | MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES, | 222 | MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES, |
223 | MYSQL_TYPE_LONGLONG, &v_discard_time, GNUNET_YES, | 223 | MYSQL_TYPE_LONGLONG, &v_discard_time, GNUNET_YES, |
224 | MYSQL_TYPE_BLOB, key, sizeof (GNUNET_HashCode), | 224 | MYSQL_TYPE_BLOB, key, sizeof (struct GNUNET_HashCode), |
225 | &k_length, MYSQL_TYPE_BLOB, &vhash, | 225 | &k_length, MYSQL_TYPE_BLOB, &vhash, |
226 | sizeof (GNUNET_HashCode), &h_length, | 226 | sizeof (struct GNUNET_HashCode), &h_length, |
227 | MYSQL_TYPE_LONG, &v_type, GNUNET_YES, -1)) | 227 | MYSQL_TYPE_LONG, &v_type, GNUNET_YES, -1)) |
228 | return GNUNET_OK; | 228 | return GNUNET_OK; |
229 | 229 | ||
230 | /* now try INSERT */ | 230 | /* now try INSERT */ |
231 | h_length = sizeof (GNUNET_HashCode); | 231 | h_length = sizeof (struct GNUNET_HashCode); |
232 | k_length = sizeof (GNUNET_HashCode); | 232 | k_length = sizeof (struct GNUNET_HashCode); |
233 | v_length = size; | 233 | v_length = size; |
234 | if (GNUNET_OK != | 234 | if (GNUNET_OK != |
235 | (ret = | 235 | (ret = |
@@ -237,9 +237,9 @@ mysql_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size, | |||
237 | MYSQL_TYPE_LONG, &type, GNUNET_YES, | 237 | MYSQL_TYPE_LONG, &type, GNUNET_YES, |
238 | MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES, | 238 | MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES, |
239 | MYSQL_TYPE_LONGLONG, &v_discard_time, GNUNET_YES, | 239 | MYSQL_TYPE_LONGLONG, &v_discard_time, GNUNET_YES, |
240 | MYSQL_TYPE_BLOB, key, sizeof (GNUNET_HashCode), | 240 | MYSQL_TYPE_BLOB, key, sizeof (struct GNUNET_HashCode), |
241 | &k_length, MYSQL_TYPE_BLOB, &vhash, | 241 | &k_length, MYSQL_TYPE_BLOB, &vhash, |
242 | sizeof (GNUNET_HashCode), &h_length, | 242 | sizeof (struct GNUNET_HashCode), &h_length, |
243 | MYSQL_TYPE_BLOB, data, (unsigned long) size, | 243 | MYSQL_TYPE_BLOB, data, (unsigned long) size, |
244 | &v_length, -1))) | 244 | &v_length, -1))) |
245 | { | 245 | { |
@@ -270,7 +270,7 @@ return_ok (void *cls, unsigned int num_values, MYSQL_BIND * values) | |||
270 | * @return the number of results found | 270 | * @return the number of results found |
271 | */ | 271 | */ |
272 | static unsigned int | 272 | static unsigned int |
273 | mysql_plugin_get (void *cls, const GNUNET_HashCode * key, | 273 | mysql_plugin_get (void *cls, const struct GNUNET_HashCode * key, |
274 | enum GNUNET_BLOCK_Type type, GNUNET_DATACACHE_Iterator iter, | 274 | enum GNUNET_BLOCK_Type type, GNUNET_DATACACHE_Iterator iter, |
275 | void *iter_cls) | 275 | void *iter_cls) |
276 | { | 276 | { |
@@ -290,7 +290,7 @@ mysql_plugin_get (void *cls, const GNUNET_HashCode * key, | |||
290 | char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE]; | 290 | char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE]; |
291 | 291 | ||
292 | now = GNUNET_TIME_absolute_get (); | 292 | now = GNUNET_TIME_absolute_get (); |
293 | h_length = sizeof (GNUNET_HashCode); | 293 | h_length = sizeof (struct GNUNET_HashCode); |
294 | v_length = sizeof (buffer); | 294 | v_length = sizeof (buffer); |
295 | total = -1; | 295 | total = -1; |
296 | memset (rbind, 0, sizeof (rbind)); | 296 | memset (rbind, 0, sizeof (rbind)); |
@@ -303,7 +303,7 @@ mysql_plugin_get (void *cls, const GNUNET_HashCode * key, | |||
303 | (ret = | 303 | (ret = |
304 | GNUNET_MYSQL_statement_run_prepared_select (plugin->mc, plugin->count_value, 1, rbind, | 304 | GNUNET_MYSQL_statement_run_prepared_select (plugin->mc, plugin->count_value, 1, rbind, |
305 | return_ok, NULL, MYSQL_TYPE_BLOB, key, | 305 | return_ok, NULL, MYSQL_TYPE_BLOB, key, |
306 | sizeof (GNUNET_HashCode), &h_length, | 306 | sizeof (struct GNUNET_HashCode), &h_length, |
307 | MYSQL_TYPE_LONG, &v_type, GNUNET_YES, | 307 | MYSQL_TYPE_LONG, &v_type, GNUNET_YES, |
308 | MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES, | 308 | MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES, |
309 | -1))) || (-1 == total)) | 309 | -1))) || (-1 == total)) |
@@ -332,7 +332,7 @@ mysql_plugin_get (void *cls, const GNUNET_HashCode * key, | |||
332 | (ret = | 332 | (ret = |
333 | GNUNET_MYSQL_statement_run_prepared_select (plugin->mc, plugin->select_value, 2, rbind, | 333 | GNUNET_MYSQL_statement_run_prepared_select (plugin->mc, plugin->select_value, 2, rbind, |
334 | return_ok, NULL, MYSQL_TYPE_BLOB, key, | 334 | return_ok, NULL, MYSQL_TYPE_BLOB, key, |
335 | sizeof (GNUNET_HashCode), &h_length, | 335 | sizeof (struct GNUNET_HashCode), &h_length, |
336 | MYSQL_TYPE_LONG, &v_type, GNUNET_YES, | 336 | MYSQL_TYPE_LONG, &v_type, GNUNET_YES, |
337 | MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES, | 337 | MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES, |
338 | MYSQL_TYPE_LONG, &off, GNUNET_YES, -1))) | 338 | MYSQL_TYPE_LONG, &off, GNUNET_YES, -1))) |
@@ -364,24 +364,24 @@ mysql_plugin_del (void *cls) | |||
364 | 364 | ||
365 | MYSQL_BIND rbind[5]; | 365 | MYSQL_BIND rbind[5]; |
366 | unsigned int v_type; | 366 | unsigned int v_type; |
367 | GNUNET_HashCode v_key; | 367 | struct GNUNET_HashCode v_key; |
368 | GNUNET_HashCode vhash; | 368 | struct GNUNET_HashCode vhash; |
369 | unsigned long k_length; | 369 | unsigned long k_length; |
370 | unsigned long h_length; | 370 | unsigned long h_length; |
371 | unsigned long v_length; | 371 | unsigned long v_length; |
372 | int ret; | 372 | int ret; |
373 | char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE]; | 373 | char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE]; |
374 | 374 | ||
375 | k_length = sizeof (GNUNET_HashCode); | 375 | k_length = sizeof (struct GNUNET_HashCode); |
376 | h_length = sizeof (GNUNET_HashCode); | 376 | h_length = sizeof (struct GNUNET_HashCode); |
377 | v_length = sizeof (buffer); | 377 | v_length = sizeof (buffer); |
378 | memset (rbind, 0, sizeof (rbind)); | 378 | memset (rbind, 0, sizeof (rbind)); |
379 | rbind[0].buffer_type = MYSQL_TYPE_BLOB; | 379 | rbind[0].buffer_type = MYSQL_TYPE_BLOB; |
380 | rbind[0].buffer_length = sizeof (GNUNET_HashCode); | 380 | rbind[0].buffer_length = sizeof (struct GNUNET_HashCode); |
381 | rbind[0].length = &k_length; | 381 | rbind[0].length = &k_length; |
382 | rbind[0].buffer = &v_key; | 382 | rbind[0].buffer = &v_key; |
383 | rbind[1].buffer_type = MYSQL_TYPE_BLOB; | 383 | rbind[1].buffer_type = MYSQL_TYPE_BLOB; |
384 | rbind[1].buffer_length = sizeof (GNUNET_HashCode); | 384 | rbind[1].buffer_length = sizeof (struct GNUNET_HashCode); |
385 | rbind[1].length = &h_length; | 385 | rbind[1].length = &h_length; |
386 | rbind[1].buffer = &vhash; | 386 | rbind[1].buffer = &vhash; |
387 | rbind[2].buffer_type = MYSQL_TYPE_LONG; | 387 | rbind[2].buffer_type = MYSQL_TYPE_LONG; |
@@ -399,9 +399,9 @@ mysql_plugin_del (void *cls) | |||
399 | (ret = | 399 | (ret = |
400 | GNUNET_MYSQL_statement_run_prepared (plugin->mc, plugin->delete_value, NULL, | 400 | GNUNET_MYSQL_statement_run_prepared (plugin->mc, plugin->delete_value, NULL, |
401 | MYSQL_TYPE_BLOB, &v_key, | 401 | MYSQL_TYPE_BLOB, &v_key, |
402 | sizeof (GNUNET_HashCode), &k_length, | 402 | sizeof (struct GNUNET_HashCode), &k_length, |
403 | MYSQL_TYPE_BLOB, &vhash, | 403 | MYSQL_TYPE_BLOB, &vhash, |
404 | sizeof (GNUNET_HashCode), &h_length, | 404 | sizeof (struct GNUNET_HashCode), &h_length, |
405 | MYSQL_TYPE_LONG, &v_type, GNUNET_YES, | 405 | MYSQL_TYPE_LONG, &v_type, GNUNET_YES, |
406 | MYSQL_TYPE_BLOB, buffer, | 406 | MYSQL_TYPE_BLOB, buffer, |
407 | (unsigned long) sizeof (buffer), &v_length, | 407 | (unsigned long) sizeof (buffer), &v_length, |