#define _GNU_SOURCE
#endif
+#include <sys/types.h>
+#include <sys/socket.h>
#include <dlog.h>
#include "proxy-internal.h"
: fd_broker_(mock) {}
Proxy::~Proxy() {
+ LOGD("Proxy::~Proxy");
if (src_ > 0)
g_source_remove(src_);
gpointer data) {
Proxy* proxy = static_cast<Proxy*>(data);
+ LOGW("Socket was disconnected");
proxy->listener_->OnDisconnected(proxy->target_appid_);
proxy->disconn_src_ = 0;
gboolean Proxy::OnDataReceived(GIOChannel *gio, GIOCondition cond,
gpointer data) {
Proxy* proxy = static_cast<Proxy*>(data);
+ int fd = g_io_channel_unix_get_fd(gio);
+ char buffer[4];
+
+ if (recv(fd, buffer, sizeof(buffer), MSG_PEEK | MSG_DONTWAIT) == 0) {
+ LOGW("Socket was disconnected by stub");
+ proxy->listener_->OnDisconnected(proxy->target_appid_);
+ proxy->src_ = 0;
+ return FALSE;
+ }
proxy->listener_->OnReceived(proxy->target_appid_);
#define _GNU_SOURCE
#endif
+#include <sys/types.h>
+#include <sys/socket.h>
#include <dlog.h>
#include "stub-internal.h"
Stub::Stub(const std::string& port_name, bool mock)
: fd_broker_(mock), port_name_(port_name) {}
-Stub::~Stub() {}
+Stub::~Stub() {
+ LOGD("Stub::~Stub");
+}
void Stub::Listen(IEventListener* ev) {
if (ev == nullptr)
gpointer data) {
Stub* stub = static_cast<Stub*>(data);
int fd = g_io_channel_unix_get_fd(gio);
+ char buffer[4];
for (auto& p : stub->ports_) {
if (p->GetFd() == fd) {
+ if (recv(fd, buffer, sizeof(buffer), MSG_PEEK | MSG_DONTWAIT) == 0) {
+ LOGW("Socket was disconnected from proxy");
+ stub->listener_->OnDisconnected(p->GetId());
+ stub->ports_.remove(p);
+ return FALSE;
+ }
+
int ret = stub->listener_->OnReceived(p->GetId(), *p);
if (ret != 0) {
+ LOGW("Invalid protocol");
stub->listener_->OnDisconnected(p->GetId());
stub->ports_.remove(p);
return FALSE;
Stub* stub = static_cast<Stub*>(data);
int fd = g_io_channel_unix_get_fd(gio);
+ LOGW("Socket was disconnected");
for (auto& p : stub->ports_) {
if (p->GetFd() == fd) {
stub->listener_->OnDisconnected(p->GetId());