const struct timespec TRY_SLEEP_TIME = { 0, 500 * 1000 * 1000 };
int bytes_read = 0;
char* buffer = static_cast<char*>(buf);
+ std::lock_guard<std::recursive_mutex> lock(mutex_);
while (left && (retry_cnt < MAX_RETRY_CNT)) {
nb = read(fd_, buffer, left);
int ret;
int bytes_write = 0;
const char* buffer = static_cast<const char*>(buf);
+ std::lock_guard<std::recursive_mutex> lock(mutex_);
fds[0].fd = fd_;
fds[0].events = POLLOUT;
#include <glib.h>
+#include <thread>
+#include <mutex>
+
#include "rpc-port.h"
#include "port-internal.h"
#include "proxy-internal.h"
}
}
+ std::recursive_mutex& GetMutex() const {
+ return mutex_;
+ }
+
private:
std::list<std::unique_ptr<Event<rpc_port_proxy_connected_event_cb>>>
connected_events_;
rejected_events_;
std::list<std::unique_ptr<Event<rpc_port_proxy_received_event_cb>>>
received_events_;
+ mutable std::recursive_mutex mutex_;
};
class StubExt : public Stub, public Stub::IEventListener {
return 0;
}
+ std::recursive_mutex& GetMutex() const {
+ return mutex_;
+ }
+
private:
std::list<std::unique_ptr<Event<rpc_port_stub_connected_event_cb>>>
connected_events_;
disconnected_events_;
std::list<std::unique_ptr<Event<rpc_port_stub_received_event_cb>>>
received_events_;
+ mutable std::recursive_mutex mutex_;
};
} // namespace
return -1;
auto p = static_cast<::ProxyExt*>(h);
+ std::lock_guard<std::recursive_mutex> lock(p->GetMutex());
p->Connect(appid, port, p);
return 0;
return -1;
auto p = static_cast<::ProxyExt*>(h);
+ std::lock_guard<std::recursive_mutex> lock(p->GetMutex());
p->AddConnectedEventListener(cb, data);
return 0;
return -1;
auto p = static_cast<::ProxyExt*>(h);
+ std::lock_guard<std::recursive_mutex> lock(p->GetMutex());
p->AddDisconnectedEventListener(cb, data);
return 0;
return -1;
auto p = static_cast<::ProxyExt*>(h);
+ std::lock_guard<std::recursive_mutex> lock(p->GetMutex());
p->AddRejectedEventListener(cb, data);
return 0;
return -1;
auto p = static_cast<::ProxyExt*>(h);
+ std::lock_guard<std::recursive_mutex> lock(p->GetMutex());
p->AddReceivedEventListener(cb, data);
return 0;
return -1;
auto p = static_cast<::StubExt*>(h);
+ std::lock_guard<std::recursive_mutex> lock(p->GetMutex());
p->Listen(p);
return 0;
return -1;
auto p = static_cast<::StubExt*>(h);
+ std::lock_guard<std::recursive_mutex> lock(p->GetMutex());
+
p->AddPrivilege(privilege);
return 0;
}
return -1;
auto p = static_cast<::StubExt*>(h);
+ std::lock_guard<std::recursive_mutex> lock(p->GetMutex());
p->AddConnectedEventListener(cb, data);
return 0;
return -1;
auto p = static_cast<::StubExt*>(h);
+ std::lock_guard<std::recursive_mutex> lock(p->GetMutex());
p->AddDisconnectedEventListener(cb, data);
return 0;
return -1;
auto p = static_cast<::StubExt*>(h);
+ std::lock_guard<std::recursive_mutex> lock(p->GetMutex());
p->AddReceivedEventListener(cb, data);
return 0;