ecs: fixed socket creation failure with disabled network
authorJinhyung Choi <jinhyung2.choi@samsung.com>
Fri, 22 May 2015 06:10:27 +0000 (15:10 +0900)
committerJinhyung Choi <jinhyung2.choi@samsung.com>
Fri, 22 May 2015 07:52:13 +0000 (16:52 +0900)
added ipv4 option as default for loopback.
Without setting the ipv4 option, AF_UNSPEC is set
and mismatched address type occurs occasionaly.

To prevent an another socket error, the mutex initialization locates
earlier than ecs socket creation.

Change-Id: I1ae3570d612bcc25794b86768430d287b3ccce2e
Signed-off-by: Jinhyung Choi <jinhyung2.choi@samsung.com>
tizen/src/ecs/ecs.c

index 8e1091c20c7e86971ab93299f8b00c7fe55bb2aa..b10523c67c66ab5bf26d853b3370e5fb4dddef5c 100644 (file)
@@ -222,6 +222,7 @@ static void ecs_close(ECS_State *cs) {
 
     if (cs->alive_timer != NULL) {
         timer_del(cs->alive_timer);
+        timer_free(cs->alive_timer);
         cs->alive_timer = NULL;
     }
 
@@ -677,6 +678,9 @@ static void* ecs_initialize(void* args) {
 
     INFO("ecs starts initializing.\n");
 
+    qemu_mutex_init(&mutex_clilist);
+    qemu_mutex_init(&mutex_location_data);
+
     opts = qemu_opts_create(qemu_find_opts(ECS_OPTS_NAME), ECS_OPTS_NAME, 1, &local_err);
     if (error_is_set(&local_err)) {
         qerror_report_err(local_err);
@@ -685,12 +689,16 @@ static void* ecs_initialize(void* args) {
     }
 
     qemu_opt_set(opts, "host", HOST_LISTEN_ADDR);
+    qemu_opt_set_bool(opts, "ipv4", true);
 
     cs = g_malloc0(sizeof(ECS_State));
     if (NULL == cs) {
         ERR("ECS_State allocation failed.\n");
         return NULL;
     }
+
+    cs->listen_fd = -1;
+
     port = get_emul_ecs_port();
     INFO("ecs port: %d\n", port);
     sprintf(host_port, "%d", port);
@@ -714,9 +722,6 @@ static void* ecs_initialize(void* args) {
     current_ecs = cs;
     cs->ecs_running = 1;
 
-    qemu_mutex_init(&mutex_clilist);
-    qemu_mutex_init(&mutex_location_data);
-
     TRACE("ecs_loop entered.\n");
     while (cs->ecs_running) {
         ret = ecs_loop(cs);