diff options
Diffstat (limited to 'src/namestore/gnunet-service-namestore.c')
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 58 |
1 files changed, 47 insertions, 11 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index ada2acb16..bdc55cff0 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -1220,13 +1220,43 @@ client_disconnect_cb (void *cls, | |||
1220 | struct NamestoreClient *nc = app_ctx; | 1220 | struct NamestoreClient *nc = app_ctx; |
1221 | struct ZoneIteration *no; | 1221 | struct ZoneIteration *no; |
1222 | struct CacheOperation *cop; | 1222 | struct CacheOperation *cop; |
1223 | struct StoreActivity *sa; | ||
1224 | struct StoreActivity *sn; | ||
1225 | char *emsg; | ||
1223 | 1226 | ||
1224 | (void) cls; | 1227 | (void) cls; |
1225 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client); | 1228 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client); |
1229 | if (GNUNET_YES == nc->in_transaction) | ||
1230 | { | ||
1231 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1232 | "Client in transaction, rolling back...\n"); | ||
1233 | if (GNUNET_SYSERR == nc->GSN_database->transaction_rollback ( | ||
1234 | nc->GSN_database->cls, | ||
1235 | &emsg)) | ||
1236 | { | ||
1237 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1238 | "Unable to roll back: %s\n", emsg); | ||
1239 | GNUNET_free (emsg); | ||
1240 | } | ||
1241 | else | ||
1242 | { | ||
1243 | nc->in_transaction = GNUNET_NO; | ||
1244 | while (NULL != sa) | ||
1245 | { | ||
1246 | if ((nc != sa->nc) || | ||
1247 | (GNUNET_NO == sa->uncommited)) | ||
1248 | { | ||
1249 | sa = sa->next; | ||
1250 | continue; | ||
1251 | } | ||
1252 | sn = sa->next; | ||
1253 | free_store_activity (sa); | ||
1254 | sa = sn; | ||
1255 | } | ||
1256 | } | ||
1257 | } | ||
1226 | for (struct ZoneMonitor *zm = monitor_head; NULL != zm; zm = zm->next) | 1258 | for (struct ZoneMonitor *zm = monitor_head; NULL != zm; zm = zm->next) |
1227 | { | 1259 | { |
1228 | struct StoreActivity *san; | ||
1229 | |||
1230 | if (nc != zm->nc) | 1260 | if (nc != zm->nc) |
1231 | continue; | 1261 | continue; |
1232 | GNUNET_CONTAINER_DLL_remove (monitor_head, monitor_tail, zm); | 1262 | GNUNET_CONTAINER_DLL_remove (monitor_head, monitor_tail, zm); |
@@ -1240,9 +1270,9 @@ client_disconnect_cb (void *cls, | |||
1240 | GNUNET_SCHEDULER_cancel (zm->sa_wait_warning); | 1270 | GNUNET_SCHEDULER_cancel (zm->sa_wait_warning); |
1241 | zm->sa_wait_warning = NULL; | 1271 | zm->sa_wait_warning = NULL; |
1242 | } | 1272 | } |
1243 | for (struct StoreActivity *sa = sa_head; NULL != sa; sa = san) | 1273 | for (sa = sa_head; NULL != sa; sa = sn) |
1244 | { | 1274 | { |
1245 | san = sa->next; | 1275 | sn = sa->next; |
1246 | if (zm == sa->zm_pos) | 1276 | if (zm == sa->zm_pos) |
1247 | { | 1277 | { |
1248 | sa->zm_pos = zm->next; | 1278 | sa->zm_pos = zm->next; |
@@ -1688,7 +1718,8 @@ store_record_set (struct NamestoreClient *nc, | |||
1688 | } | 1718 | } |
1689 | 1719 | ||
1690 | if (GNUNET_OK != | 1720 | if (GNUNET_OK != |
1691 | GNUNET_GNSRECORD_records_deserialize (rd_ser_len, rd_ser, rd_count, rd)) | 1721 | GNUNET_GNSRECORD_records_deserialize (rd_ser_len, rd_ser, rd_count, |
1722 | rd)) | ||
1692 | { | 1723 | { |
1693 | *emsg = GNUNET_strdup (_ ("Error deserializing records.")); | 1724 | *emsg = GNUNET_strdup (_ ("Error deserializing records.")); |
1694 | GNUNET_free (*conv_name); | 1725 | GNUNET_free (*conv_name); |
@@ -1706,8 +1737,10 @@ store_record_set (struct NamestoreClient *nc, | |||
1706 | if ((GNUNET_NO == nc->GSN_database->lookup_records (nc->GSN_database->cls, | 1737 | if ((GNUNET_NO == nc->GSN_database->lookup_records (nc->GSN_database->cls, |
1707 | private_key, | 1738 | private_key, |
1708 | *conv_name, | 1739 | *conv_name, |
1709 | &get_block_exp_existing, | 1740 | & |
1710 | &existing_block_exp)) && | 1741 | get_block_exp_existing, |
1742 | &existing_block_exp)) | ||
1743 | && | ||
1711 | (rd_count == 0)) | 1744 | (rd_count == 0)) |
1712 | { | 1745 | { |
1713 | /* This name does not exist, so cannot be removed */ | 1746 | /* This name does not exist, so cannot be removed */ |
@@ -1954,6 +1987,7 @@ handle_tx_control (void *cls, const struct TxControlMessage *tx_msg) | |||
1954 | txr_msg->success = htons (ret); | 1987 | txr_msg->success = htons (ret); |
1955 | err_tmp = (char *) &txr_msg[1]; | 1988 | err_tmp = (char *) &txr_msg[1]; |
1956 | GNUNET_memcpy (err_tmp, emsg, err_len); | 1989 | GNUNET_memcpy (err_tmp, emsg, err_len); |
1990 | GNUNET_free (emsg); | ||
1957 | GNUNET_MQ_send (nc->mq, env); | 1991 | GNUNET_MQ_send (nc->mq, env); |
1958 | GNUNET_SERVICE_client_continue (nc->client); | 1992 | GNUNET_SERVICE_client_continue (nc->client); |
1959 | } | 1993 | } |
@@ -2439,12 +2473,14 @@ monitor_iterate_cb (void *cls, | |||
2439 | * @param zis_msg message from the client | 2473 | * @param zis_msg message from the client |
2440 | */ | 2474 | */ |
2441 | static void | 2475 | static void |
2442 | handle_monitor_start (void *cls, const struct ZoneMonitorStartMessage *zis_msg) | 2476 | handle_monitor_start (void *cls, const struct |
2477 | ZoneMonitorStartMessage *zis_msg) | ||
2443 | { | 2478 | { |
2444 | struct NamestoreClient *nc = cls; | 2479 | struct NamestoreClient *nc = cls; |
2445 | struct ZoneMonitor *zm; | 2480 | struct ZoneMonitor *zm; |
2446 | 2481 | ||
2447 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ZONE_MONITOR_START message\n"); | 2482 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2483 | "Received ZONE_MONITOR_START message\n"); | ||
2448 | zm = GNUNET_new (struct ZoneMonitor); | 2484 | zm = GNUNET_new (struct ZoneMonitor); |
2449 | zm->nc = nc; | 2485 | zm->nc = nc; |
2450 | zm->zone = zis_msg->zone; | 2486 | zm->zone = zis_msg->zone; |
@@ -2477,9 +2513,9 @@ monitor_iteration_next (void *cls) | |||
2477 | zm->task = NULL; | 2513 | zm->task = NULL; |
2478 | GNUNET_assert (0 == zm->iteration_cnt); | 2514 | GNUNET_assert (0 == zm->iteration_cnt); |
2479 | if (zm->limit > 16) | 2515 | if (zm->limit > 16) |
2480 | zm->iteration_cnt = zm->limit / 2; /* leave half for monitor events */ | 2516 | zm->iteration_cnt = zm->limit / 2; /* leave half for monitor events */ |
2481 | else | 2517 | else |
2482 | zm->iteration_cnt = zm->limit; /* use it all */ | 2518 | zm->iteration_cnt = zm->limit; /* use it all */ |
2483 | ret = nc->GSN_database->iterate_records (nc->GSN_database->cls, | 2519 | ret = nc->GSN_database->iterate_records (nc->GSN_database->cls, |
2484 | (GNUNET_YES == GNUNET_is_zero ( | 2520 | (GNUNET_YES == GNUNET_is_zero ( |
2485 | &zm->zone)) ? NULL : &zm->zone, | 2521 | &zm->zone)) ? NULL : &zm->zone, |