mirror of
https://github.com/ceph/ceph
synced 2025-02-24 11:37:37 +00:00
Merge pull request #46027 from cbodley/wip-55432
rgw: OpsLogFile::stop() signals under mutex Reviewed-by: Matt Benjamin <mbenjami@redhat.com> Reviewed-by: Cory Snyder <csnyder@iland.com>
This commit is contained in:
commit
bab8b96a7a
@ -354,9 +354,8 @@ void OpsLogFile::reopen() {
|
||||
|
||||
void OpsLogFile::flush()
|
||||
{
|
||||
std::scoped_lock flush_lock(flush_mutex);
|
||||
{
|
||||
std::scoped_lock log_lock(log_mutex);
|
||||
std::scoped_lock log_lock(mutex);
|
||||
assert(flush_buffer.empty());
|
||||
flush_buffer.swap(log_buffer);
|
||||
data_size = 0;
|
||||
@ -389,7 +388,7 @@ void OpsLogFile::flush()
|
||||
}
|
||||
|
||||
void* OpsLogFile::entry() {
|
||||
std::unique_lock lock(log_mutex);
|
||||
std::unique_lock lock(mutex);
|
||||
while (!stopped) {
|
||||
if (!log_buffer.empty()) {
|
||||
lock.unlock();
|
||||
@ -397,8 +396,9 @@ void* OpsLogFile::entry() {
|
||||
lock.lock();
|
||||
continue;
|
||||
}
|
||||
cond_flush.wait(lock);
|
||||
cond.wait(lock);
|
||||
}
|
||||
lock.unlock();
|
||||
flush();
|
||||
return NULL;
|
||||
}
|
||||
@ -410,7 +410,8 @@ void OpsLogFile::start() {
|
||||
|
||||
void OpsLogFile::stop() {
|
||||
{
|
||||
cond_flush.notify_one();
|
||||
std::unique_lock lock(mutex);
|
||||
cond.notify_one();
|
||||
stopped = true;
|
||||
}
|
||||
join();
|
||||
@ -426,14 +427,14 @@ OpsLogFile::~OpsLogFile()
|
||||
|
||||
int OpsLogFile::log_json(struct req_state* s, bufferlist& bl)
|
||||
{
|
||||
std::unique_lock lock(log_mutex);
|
||||
std::unique_lock lock(mutex);
|
||||
if (data_size + bl.length() >= max_data_size) {
|
||||
ldout(s->cct, 0) << "ERROR: RGW ops log file buffer too full, dropping log for txn: " << s->trans_id << dendl;
|
||||
return -1;
|
||||
}
|
||||
log_buffer.push_back(bl);
|
||||
data_size += bl.length();
|
||||
cond_flush.notify_all();
|
||||
cond.notify_all();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -165,11 +165,10 @@ public:
|
||||
|
||||
class OpsLogFile : public JsonOpsLogSink, public Thread, public DoutPrefixProvider {
|
||||
CephContext* cct;
|
||||
ceph::mutex log_mutex = ceph::make_mutex("OpsLogFile_log");
|
||||
ceph::mutex flush_mutex = ceph::make_mutex("OpsLogFile_flush");
|
||||
ceph::mutex mutex = ceph::make_mutex("OpsLogFile");
|
||||
std::vector<bufferlist> log_buffer;
|
||||
std::vector<bufferlist> flush_buffer;
|
||||
ceph::condition_variable cond_flush;
|
||||
ceph::condition_variable cond;
|
||||
std::ofstream file;
|
||||
bool stopped;
|
||||
uint64_t data_size;
|
||||
|
Loading…
Reference in New Issue
Block a user