Skip to content

Commit 038db1b

Browse files
committed
Bugfixes in storage daemon
1 parent 8a49651 commit 038db1b

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

storage/NodeActor.cpp

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "td/utils/overloaded.h"
2828
#include "tl-utils/tl-utils.hpp"
2929
#include "auto/tl/ton_api.hpp"
30+
#include "common/delay.h"
3031
#include "td/actor/MultiPromise.h"
3132

3233
namespace ton {
@@ -545,8 +546,9 @@ void NodeActor::loop_queries() {
545546
auto it = peers_.find(part.peer_id);
546547
CHECK(it != peers_.end());
547548
auto &state = it->second.state;
548-
CHECK(state->peer_state_ready_);
549-
CHECK(state->peer_state_.load().will_upload);
549+
if (!state->peer_state_ready_ || !state->peer_state_.load().will_upload) {
550+
continue;
551+
}
550552
CHECK(state->node_queries_active_.size() < MAX_PEER_TOTAL_QUERIES);
551553
auto part_id = part.part_id;
552554
if (state->node_queries_active_.insert(static_cast<td::uint32>(part_id)).second) {
@@ -787,15 +789,21 @@ void NodeActor::db_store_torrent_meta() {
787789
return;
788790
}
789791
next_db_store_meta_at_ = td::Timestamp::never();
790-
auto meta = torrent_.get_meta_str();
791-
db_->set(create_hash_tl_object<ton_api::storage_db_key_torrentMeta>(torrent_.get_hash()), td::BufferSlice(meta),
792-
[new_count = (td::int64)torrent_.get_ready_parts_count(), SelfId = actor_id(this)](td::Result<td::Unit> R) {
793-
if (R.is_error()) {
794-
td::actor::send_closure(SelfId, &NodeActor::after_db_store_torrent_meta, R.move_as_error());
795-
} else {
796-
td::actor::send_closure(SelfId, &NodeActor::after_db_store_torrent_meta, new_count);
797-
}
798-
});
792+
auto meta = torrent_.get_meta();
793+
delay_action(
794+
[SelfId = actor_id(this), meta = std::move(meta), db = db_, hash = torrent_.get_hash(),
795+
new_count = (td::int64)torrent_.get_ready_parts_count()]() {
796+
auto meta_str = meta.serialize();
797+
db->set(create_hash_tl_object<ton_api::storage_db_key_torrentMeta>(hash), td::BufferSlice(meta_str),
798+
[=](td::Result<td::Unit> R) {
799+
if (R.is_error()) {
800+
td::actor::send_closure(SelfId, &NodeActor::after_db_store_torrent_meta, R.move_as_error());
801+
} else {
802+
td::actor::send_closure(SelfId, &NodeActor::after_db_store_torrent_meta, new_count);
803+
}
804+
});
805+
},
806+
td::Timestamp::now());
799807
}
800808

801809
void NodeActor::after_db_store_torrent_meta(td::Result<td::int64> R) {

storage/storage-daemon/storage-daemon.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
#if TD_DARWIN || TD_LINUX
4343
#include <unistd.h>
4444
#endif
45+
#include "td/utils/port/rlimit.h"
46+
4547
#include <iostream>
4648

4749
namespace ton {
@@ -950,6 +952,7 @@ int main(int argc, char *argv[]) {
950952
SCOPE_EXIT {
951953
td::log_interface = td::default_log_interface;
952954
};
955+
LOG_STATUS(td::change_maximize_rlimit(td::RlimitType::nofile, 786432));
953956

954957
td::IPAddress ip_addr;
955958
bool client_mode = false;

0 commit comments

Comments
 (0)