From: Jinhyung Choi Date: Tue, 19 Nov 2013 07:09:53 +0000 (+0900) Subject: suspend/resume: NOT allow to add duplicated client. X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~592^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b2632df90fcd27e6c6293d8a629fd23d101205dd;p=sdk%2Femulator%2Fqemu.git suspend/resume: NOT allow to add duplicated client. Change-Id: Ib1ac637058413b8051cfb9af4825ca75b80bfe94 Signed-off-by: Jinhyung Choi --- diff --git a/tizen/src/ecs/ecs.c b/tizen/src/ecs/ecs.c index 0bfbb8c763..d4265b78de 100644 --- a/tizen/src/ecs/ecs.c +++ b/tizen/src/ecs/ecs.c @@ -391,7 +391,7 @@ static void ecs_read(ECS_Client *cli) { #endif if (to_read_bytes == 0) { - LOG("ioctl FIONREAD: 0\n"); + LOG("ioctl FIONREAD: 0"); goto fail; } diff --git a/tizen/src/guest_server.c b/tizen/src/guest_server.c index 40a7857e1e..51a0d3f9cc 100644 --- a/tizen/src/guest_server.c +++ b/tizen/src/guest_server.c @@ -125,7 +125,7 @@ static void send_to_client(GS_Client* client, int state) // send message "[4 digit message length]host:sync:emulator-26101:[0|1]" sprintf(buf, "%04xhost:sync:%s:%01d", (serial_len + 12), client->serial, state); - INFO("send %s to client \n", buf); + INFO("send %s to client %s\n", buf, inet_ntoa(client->addr.sin_addr)); if (send(s, buf, sizeof(buf), 0) == -1) { @@ -151,12 +151,8 @@ void notify_all_sdb_clients(int state) static void add_sdb_client(struct sockaddr_in* addr, int port, const char* serial) { - - GS_Client *client = g_malloc0(sizeof(GS_Client)); - if (NULL == client) { - INFO("GS_Client allocation failed.\n"); - return; - } + GS_Client *cli = NULL; + GS_Client *client = NULL; if (addr == NULL) { INFO("GS_Client client's address is EMPTY.\n"); @@ -169,6 +165,20 @@ static void add_sdb_client(struct sockaddr_in* addr, int port, const char* seria return; } + QTAILQ_FOREACH(cli, &clients, next) + { + if (!strcmp(serial, cli->serial) && !strcmp(inet_ntoa(addr->sin_addr), inet_ntoa((cli->addr).sin_addr))) { + INFO("Client cannot be duplicated.\n"); + return; + } + } + + client = g_malloc0(sizeof(GS_Client)); + if (NULL == client) { + INFO("GS_Client allocation failed.\n"); + return; + } + memcpy(&client->addr, addr, sizeof(struct sockaddr_in)); client->port = port; strcpy(client->serial, serial); @@ -179,7 +189,7 @@ static void add_sdb_client(struct sockaddr_in* addr, int port, const char* seria pthread_mutex_unlock(&mutex_clilist); - INFO("Added new sdb client. ip: %s, port: %d, serial: %s\n", inet_ntoa(client->addr.sin_addr), client->port, client->serial); + INFO("Added new sdb client. ip: %s, port: %d, serial: %s\n", inet_ntoa((client->addr).sin_addr), client->port, client->serial); send_to_client(client, runstate_check(RUN_STATE_SUSPENDED)); }