Skip to content

Commit df0fbdc

Browse files
authored
Fix ParkingLot::signal does not modify _pending_signal when there is no waiter (#2916)
1 parent b4ce61f commit df0fbdc

3 files changed

Lines changed: 3 additions & 2 deletions

File tree

src/brpc/event_dispatcher.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ static void StopAndJoinGlobalDispatchers() {
5151
delete g_edisp_read_lantency;
5252
delete g_edisp_write_lantency;
5353
}
54+
5455
void InitializeGlobalDispatchers() {
5556
g_edisp_read_lantency = new bvar::LatencyRecorder("event_dispatcher_read_latency");
5657
g_edisp_write_lantency = new bvar::LatencyRecorder("event_dispatcher_write_latency");

src/bthread/parking_lot.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ class BAIDU_CACHELINE_ALIGNMENT ParkingLot {
4545
// Wake up at most `num_task' workers.
4646
// Returns #workers woken up.
4747
int signal(int num_task) {
48+
_pending_signal.fetch_add((num_task << 1), butil::memory_order_release);
4849
if (_waiter_num.load(butil::memory_order_relaxed) == 0) {
4950
return 0;
5051
}
51-
_pending_signal.fetch_add((num_task << 1), butil::memory_order_release);
5252
return futex_wake_private(&_pending_signal, num_task);
5353
}
5454

src/butil/file_util_posix.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ bool CreateDirectoryAndGetError(const FilePath& full_path,
601601
if (mkdir(i->value().c_str(), 0755/*others can read the dir*/) == 0)
602602
continue;
603603
// Mkdir failed, but it might have failed with EEXIST, or some other error
604-
// due to the the directory appearing out of thin air. This can occur if
604+
// due to the directory appearing out of thin air. This can occur if
605605
// two processes are trying to create the same file system tree at the same
606606
// time. Check to see if it exists and make sure it is a directory.
607607
int saved_errno = errno;

0 commit comments

Comments
 (0)