Disconnected callback should be called even if connection closed by main thread.
authorSung-jae Park <nicesj.park@samsung.com>
Wed, 12 Jun 2013 11:25:14 +0000 (20:25 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Wed, 12 Jun 2013 11:25:14 +0000 (20:25 +0900)
[model] Redwood
[binary_type] AP
[customer] Docomo/Orange/Open
[issue#] N/A
[problem] Disconnected callback is not invoked.
[cause] When a main thread tries to close the connection, disconnected callback is not invoked.
[solution] Guarantees call of registered disconnected callback even though the main thread explictly close a socket.
[team] HomeTF
[request]
[horizontal_expansion]

Change-Id: Ia90480aca9e558d6edeb7b5a9656f89fc0fa5cc4

packaging/libcom-core.spec
src/com-core.c
src/com-core_thread.c

index 27e633e..5e7ab5e 100644 (file)
@@ -1,6 +1,6 @@
 Name: libcom-core
 Summary: Library for the light-weight IPC 
-Version: 0.4.0
+Version: 0.4.1
 Release: 1
 Group: HomeTF/Framework
 License: Apache License
index fea5ce1..7aa172e 100644 (file)
@@ -483,6 +483,7 @@ EAPI void *com_core_del_event_callback(enum com_core_event_type type, int (*cb)(
 EAPI int com_core_server_destroy(int handle)
 {
        DbgPrint("Close server handle[%d]\n", handle);
+       invoke_disconn_cb_list(handle);
        secure_socket_destroy_handle(handle);
        return 0;
 }
@@ -490,6 +491,7 @@ EAPI int com_core_server_destroy(int handle)
 EAPI int com_core_client_destroy(int handle)
 {
        DbgPrint("Close client handle[%d]\n", handle);
+       invoke_disconn_cb_list(handle);
        secure_socket_destroy_handle(handle);
        return 0;
 }
index 387c4fc..4f0b12b 100644 (file)
@@ -921,18 +921,22 @@ EAPI int com_core_thread_server_destroy(int handle)
                if (tcb->server_handle != handle)
                        continue;
 
+               invoke_disconn_cb_list(handle);
                terminate_thread(tcb);
                tcb_destroy(tcb);
+               return 0;
        }
 
        dlist_foreach_safe(s_info.server_list, l, n, server) {
-               if (server->handle == handle) {
-                       server_destroy(server);
-                       break;
-               }
+               if (server->handle != handle)
+                       continue;
+
+               invoke_disconn_cb_list(handle);
+               server_destroy(server);
+               return 0;
        }
 
-       return 0;
+       return -ENOENT;
 }
 
 /*!
@@ -947,6 +951,7 @@ EAPI int com_core_thread_client_destroy(int handle)
        if (!tcb)
                return -ENOENT;
 
+       invoke_disconn_cb_list(handle);
        terminate_thread(tcb);
        tcb_destroy(tcb);
        return 0;