Skip to content

Commit 7f9e8d7

Browse files
cheniujhbrother-jin
authored andcommitted
fix:Revise the value check for max-rsync-parallel-num to prevent a core dump when it is set to a value greater than 4 (#2595)
* revised value check of max-rsync-parallel-num to avoid core dump when it's value greater than 4 * avoid fixed num, use kMaxRsyncParallelNum instead * use kMaxRsyncParallelNum to replace another two fixed num 4 --------- Co-authored-by: cjh <1271435567@qq.com>
1 parent 60427cf commit 7f9e8d7

4 files changed

Lines changed: 7 additions & 4 deletions

File tree

conf/pika.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,9 @@ default-slot-num : 1024
433433

434434
# Rsync Rate limiting configuration 200MB/s
435435
throttle-bytes-per-second : 207200000
436+
437+
# The valid range for max-rsync-parallel-num is [1, 4].
438+
# If an invalid value is provided, max-rsync-parallel-num will automatically be reset to 4.
436439
max-rsync-parallel-num : 4
437440

438441
# The synchronization mode of Pika primary/secondary replication is determined by ReplicationID. ReplicationID in one replication_cluster are the same

include/pika_conf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ class PikaConf : public pstd::BaseConf {
814814

815815
// Rsync Rate limiting configuration
816816
int throttle_bytes_per_second_ = 207200000;
817-
int max_rsync_parallel_num_ = 4;
817+
int max_rsync_parallel_num_ = kMaxRsyncParallelNum;
818818
};
819819

820820
#endif

src/pika_admin.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2484,7 +2484,7 @@ void ConfigCmd::ConfigSet(std::shared_ptr<DB> db) {
24842484
g_pika_conf->SetThrottleBytesPerSecond(static_cast<int>(ival));
24852485
res_.AppendStringRaw("+OK\r\n");
24862486
} else if (set_item == "max-rsync-parallel-num") {
2487-
if ((pstd::string2int(value.data(), value.size(), &ival) == 0) || ival > kMaxRsyncParallelNum) {
2487+
if ((pstd::string2int(value.data(), value.size(), &ival) == 0) || ival > kMaxRsyncParallelNum || ival <= 0) {
24882488
res_.AppendStringRaw( "-ERR Invalid argument \'" + value + "\' for CONFIG SET 'max-rsync-parallel-num'\r\n");
24892489
return;
24902490
}

src/pika_conf.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,8 @@ int PikaConf::Load() {
597597
}
598598

599599
GetConfInt("max-rsync-parallel-num", &max_rsync_parallel_num_);
600-
if (max_rsync_parallel_num_ <= 0) {
601-
max_rsync_parallel_num_ = 4;
600+
if (max_rsync_parallel_num_ <= 0 || max_rsync_parallel_num_ > kMaxRsyncParallelNum) {
601+
max_rsync_parallel_num_ = kMaxRsyncParallelNum;
602602
}
603603

604604
return ret;

0 commit comments

Comments
 (0)