Whenever a client connects to a server, notifier function is registered to notifier_list repeatedly.
It makes emulator become infinite loop state when emulator is terminated.
Change-Id: Ib7c92c03bb659290df5434c17822db08b2fa60a8
Signed-off-by: Kitae Kim <kt920.kim@samsung.com>
maru_do_pixman_dpy_surface(dpy_surface->image);
buffer_size = surface_stride(dpy_surface) * surface_height(dpy_surface);
- INFO("extract framebuffer %d\n", buffer_size);
+ TRACE("extract framebuffer %d\n", buffer_size);
memcpy(buffer, surface_data(dpy_surface), buffer_size);
return true;
#define COMMAND_TYPE_MONITOR "monitor"
#define COMMAND_TYPE_DEVICE "device"
-#define COMMAND_TYPE_TETHERING "tethering"
+#define COMMAND_TYPE_TETHERING "eventcast"
#define MSG_TYPE_SENSOR "sensor"
#define MSG_TYPE_LOCATION "location"
void send_eventcast_sensor_status_ecp(void)
{
- LOG_INFO(">> send eventcast_event_status to ecp\n");
+ LOG_TRACE("send event_status to ecp\n");
send_eventcast_status_ntf(ECS_EVENTCAST_MSG_GROUP_ECP,
ECS_EVENTCAST_MSG_ACTION_SENSOR_STATUS);
}
void send_eventcast_connection_status_ecp(void)
{
- LOG_INFO(">> send eventcast_connection_status to ecp\n");
+ LOG_TRACE("send connection_status to ecp\n");
send_eventcast_status_ntf(ECS_EVENTCAST_MSG_GROUP_ECP,
ECS_EVENTCAST_MSG_ACTION_CONNECTION_STATUS);
}
return;
}
- LOG_TRACE(">> send port_num: %d\n", eventcast_port);
+ LOG_TRACE("send port_num: %d\n", eventcast_port);
g_snprintf(data, sizeof(data) - 1, "%d", eventcast_port);
length = strlen(data);
memcpy(msg + 13, &action, sizeof(unsigned char));
memcpy(msg + 14, data, length);
- LOG_TRACE(">> send eventcast_ntf to ecp. action=%d, group=%d, data=%s\n",
+ LOG_TRACE("send eventcast_ntf to ecp. action=%d, group=%d, data=%s\n",
action, group, data);
send_eventcast_ntf((const char *)msg);
return;
}
- LOG_INFO(">> send port_num: %d\n", eventcast_port);
+ LOG_INFO("send eventcast port: %d\n", eventcast_port);
{
const char *ip = get_eventcast_connected_ipaddr();
int port = get_eventcast_connected_port();
memcpy(msg + 13, &action, sizeof(unsigned char));
memcpy(msg + 14, data, length);
- LOG_INFO(">> send connection msg to ecp. "
+ LOG_INFO("send connection msg to ecp. "
"action=%d, group=%d, data=%s length=%d\n",
action, group, data, length);
memcpy(msg + 13, &action, sizeof(unsigned char));
memcpy(msg + 14, data, 1);
- LOG_TRACE(">> send eventcast_ntf to ecp. action=%d, group=%d, data=%s\n",
+ LOG_TRACE("send eventcast_ntf to ecp. action=%d, group=%d, data=%s\n",
action, group, data);
send_eventcast_ntf((const char *)msg);
const char* ijdata = (data + catsize + 2 + 1 + 1);
- LOG_TRACE(">> header cat = %s, length = %d, action=%d, group=%d\n", cat, length,action, group);
+ LOG_TRACE("header cat = %s, length = %d, action=%d, group=%d\n", cat, length,action, group);
ECS__Master master = ECS__MASTER__INIT;
ECS__EventCastNtf ntf = ECS__EVENT_CAST_NTF__INIT;
switch(action) {
case ECS_EVENTCAST_MSG_ACTION_CONNECT:
- LOG_INFO("MSG_ACTION_CONNECT\n");
+ LOG_TRACE("MSG_ACTION_CONNECT\n");
if (msg->data.data && msg->data.len > 0) {
const gchar *data = (const gchar *)msg->data.data;
connect_eventcast_app(ip_address, port);
eventcast_port = port;
- LOG_TRACE(">> port_num: %d, %d\n", port, eventcast_port);
+ LOG_TRACE("port_num: %d, %d\n", port, eventcast_port);
g_free(ip_address);
g_strfreev(server_addr);
} else {
- LOG_INFO("ip address and port value are null\n");
+ LOG_SEVERE("ip address and port value are null\n");
}
break;
case ECS_EVENTCAST_MSG_ACTION_DISCONNECT:
- LOG_INFO(">> MSG_ACTION_DISCONNECT\n");
+ LOG_TRACE("MSG_ACTION_DISCONNECT\n");
disconnect_eventcast_app();
eventcast_port = 0;
break;
case ECS_EVENTCAST_MSG_ACTION_CONNECTION_STATUS:
case ECS_EVENTCAST_MSG_ACTION_SENSOR_STATUS:
case ECS_EVENTCAST_MSG_ACTION_TOUCH_STATUS:
- LOG_TRACE(">> get_status_action\n");
+ LOG_TRACE("get_status_action\n");
send_eventcast_status_ntf(group, action);
break;
default:
#include "util/new_debug_ch.h"
-DECLARE_DEBUG_CHANNEL(app_tethering);
+DECLARE_DEBUG_CHANNEL(app_eventcast);
#define EVENTCAST_MSG_HANDSHAKE_KEY 100
#define MSG_BUF_SIZE 255
static bool get_eventcast_app_state(void);
#endif
+static bool is_notifier = false;
+
// create master message
static void *build_eventcast_msg(Eventcast__EventCastMsg* msg, int *payloadsize)
{
result = select(sockfd + 1, NULL, &writefds, NULL, &timeout);
if (result < 0) {
- LOG_INFO("not possible to send data\n");
+ LOG_SEVERE("not possible to send data\n");
ret = false;
break;
}
LOG_TRACE("enter: %s\n", __func__);
+ LOG_INFO("close eventcast socket\n");
if (closesocket(sockfd) < 0) {
perror("closesocket failure");
return;
eventcast_client->fd = -1;
- LOG_INFO("close eventcast socket\n");
set_eventcast_connection_status(DISCONNECTED);
set_eventcast_sensor_status(status);
set_eventcast_touch_status(status);
if (!eventcast_client) {
LOG_INFO("eventcast_client is null\n");
- LOG_INFO("tetherging connection status: %d\n", status);
+ LOG_INFO("connection status: %d\n", status);
return DISCONNECTED;
}
status = eventcast_client->status;
qemu_mutex_unlock(&eventcast_client->mutex);
- LOG_INFO("tetherging connection status: %d\n", status);
+ LOG_INFO("connection status: %d\n", status);
return status;
}
int get_eventcast_connected_port(void)
{
- if (!eventcast_client) {
- LOG_SEVERE("eventcast_client is null\n");
- return 0;
- }
+ if (!eventcast_client) {
+ LOG_SEVERE("eventcast_client is null\n");
+ return 0;
+ }
- LOG_TRACE("connected port: %d\n", eventcast_client->port);
- return eventcast_client->port;
+ LOG_TRACE("connected port: %d\n", eventcast_client->port);
+ return eventcast_client->port;
}
const char *get_eventcast_connected_ipaddr(void)
{
- if (!eventcast_client) {
- LOG_SEVERE("eventcast client is null\n");
- return NULL;
- }
+ if (!eventcast_client) {
+ LOG_SEVERE("eventcast client is null\n");
+ return NULL;
+ }
- LOG_TRACE("connected ip address: %s\n", eventcast_client->ipaddress);
- return eventcast_client->ipaddress;
+ LOG_TRACE("connected ip address: %s\n", eventcast_client->ipaddress);
+ return eventcast_client->ipaddress;
}
static void set_eventcast_connection_status(int status)
{
int sock = 0;
- LOG_INFO("disconnect app from ecp\n");
+ LOG_INFO("disconnect evencast_client from app\n");
if (!eventcast_client) {
LOG_SEVERE("eventcast client instance is NULL\n");
return -1;
end_eventcast_socket(sock);
}
+ g_free(eventcast_client);
+ eventcast_client = NULL;
+
return 0;
}
reset_eventcast_recv_buf(&recv_buf);
send_handshake_req_msg();
- emulator_add_exit_notifier(&eventcast_exit);
+ if (!is_notifier) {
+ LOG_INFO("add eventcast_exit_notifier\n");
+ emulator_add_exit_notifier(&eventcast_exit);
+ is_notifier = true;
+ }
while (1) {
qemu_mutex_lock(&client->mutex);
if (client->status == DISCONNECTED) {
qemu_mutex_unlock(&client->mutex);
- LOG_INFO("disconnected socket. destroy this thread\n");
+ LOG_INFO("disconnected socket and destory this thread\n");
break;
}
qemu_mutex_unlock(&client->mutex);
#include "util/new_debug_ch.h"
-DECLARE_DEBUG_CHANNEL(app_tethering);
+DECLARE_DEBUG_CHANNEL(app_eventcast);
#if !defined(CONFIG_SDL) && !defined(CONFIG_USE_SHM)
bool maru_extract_framebuffer(void *buffer)
#include "util/new_debug_ch.h"
-DECLARE_DEBUG_CHANNEL(app_tethering);
+DECLARE_DEBUG_CHANNEL(app_eventcast);
typedef struct sensor_state {
bool is_sensor_event;
#include "ecs/ecs_eventcast.h"
#include "util/new_debug_ch.h"
-DECLARE_DEBUG_CHANNEL(app_tethering);
+DECLARE_DEBUG_CHANNEL(app_eventcast);
static int touch_device_status;
static bool send_display_image_data(void);