*
*/
+#include <poll.h>
+#include <sys/un.h>
+#include <unistd.h>
+
#include "common/OutputDataSocket.h"
#include "common/errno.h"
+#include "common/debug.h"
#include "common/safe_io.h"
#include "include/compat.h"
#include "include/sock_compat.h"
-#include <poll.h>
-#include <sys/un.h>
-
// re-include our assert to clobber the system one; fix dout:
#include "include/ceph_assert.h"
m_shutdown_rd_fd(-1),
m_shutdown_wr_fd(-1),
going_down(false),
- data_size(0),
- m_lock("OutputDataSocket::m_lock")
+ data_size(0)
{
}
return;
do {
- m_lock.lock();
- cond.Wait(m_lock);
-
- if (going_down) {
- m_lock.unlock();
- break;
+ {
+ std::unique_lock l(m_lock);
+ if (!going_down) {
+ cond.wait(l);
+ }
+ if (going_down) {
+ break;
+ }
}
- m_lock.unlock();
-
ret = dump_data(fd);
} while (ret >= 0);
}
{
m_lock.lock();
going_down = true;
- cond.Signal();
+ cond.notify_all();
m_lock.unlock();
if (m_shutdown_wr_fd < 0)
void OutputDataSocket::append_output(bufferlist& bl)
{
- std::lock_guard<Mutex> l(m_lock);
+ std::lock_guard l(m_lock);
if (data_size + bl.length() > data_max_backlog) {
ldout(m_cct, 20) << "dropping data output, max backlog reached" << dendl;
data_size += bl.length();
- cond.Signal();
+ cond.notify_all();
}
#ifndef CEPH_COMMON_OUTPUTDATASOCKET_H
#define CEPH_COMMON_OUTPUTDATASOCKET_H
-#include "common/Cond.h"
+#include "common/ceph_mutex.h"
+#include "common/Thread.h"
+#include "include/buffer.h"
class CephContext;
std::list<bufferlist> data;
- Mutex m_lock;
- Cond cond;
+ ceph::mutex m_lock = ceph::make_mutex("OutputDataSocket::m_lock");
+ ceph::condition_variable cond;
bufferlist delim;
};