Add -g option for generating strip binary correctly
authorSung-jae Park <nicesj.park@samsung.com>
Mon, 23 Jul 2012 08:09:43 +0000 (17:09 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Tue, 24 Jul 2012 04:30:33 +0000 (13:30 +0900)
Add timeout parameter for async_send

Change-Id: I837dacccdf65122d2905108ef69d36185ed2a4b7

CMakeLists.txt
debian/changelog
include/com-core_packet.h
packaging/libcom-core.spec
src/com-core_packet.c

index 1f2d967..60cc4c4 100644 (file)
@@ -24,7 +24,7 @@ FOREACH(flag ${pkgs_CFLAGS})
 ENDFOREACH(flag)
 
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g")
 
 ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
 ADD_DEFINITIONS("-DLOG_TAG=\"${PROJECT_NAME}\"")
index d20bcc2..b9fbb52 100644 (file)
@@ -1,3 +1,10 @@
+com-core (0.0.5) unstable; urgency=low
+
+  * Git: slp/pkgs/c/com-core
+  * Tag: com-core_0.0.5
+
+ -- Sung-jae Park <nicesj.park@samsung.com>  Tue, 24 Jul 2012 13:30:04 +0900
+
 com-core (0.0.4) unstable; urgency=low
 
   * Git: slp/pkgs/c/com-core
index 2625b66..280e5ce 100644 (file)
@@ -7,7 +7,7 @@ struct method {
        struct packet *(*handler)(pid_t pid, int handle, const struct packet *packet);
 };
 
-extern int com_core_packet_async_send(int handle, struct packet *packet, int (*recv_cb)(pid_t, int handle, const struct packet *packet, void *data), void *data);
+extern int com_core_packet_async_send(int handle, struct packet *packet, unsigned int timeout, int (*recv_cb)(pid_t, int handle, const struct packet *packet, void *data), void *data);
 extern int com_core_packet_send_only(int handle, struct packet *packet);
 extern struct packet *com_core_packet_oneshot_send(const char *addr, struct packet *packet);
 
index f7a6f1f..3da793f 100644 (file)
@@ -1,6 +1,6 @@
 Name: libcom-core
 Summary: Library for the light-weight IPC 
-Version: 0.0.4
+Version: 0.0.5
 Release: 1
 Group: main/util
 License: Samsung Proprietary License
index 7fc7ce2..6135146 100644 (file)
@@ -5,6 +5,7 @@
 #include <stdlib.h>
 #include <fcntl.h>
 
+#include <glib.h>
 #include <dlog.h>
 
 #include "debug.h"
@@ -32,6 +33,8 @@ struct request_ctx {
        struct packet *packet;
        int (*recv_cb)(pid_t pid, int handle, const struct packet *packet, void *data);
        void *data;
+
+       guint timeout;
 };
 
 struct recv_ctx {
@@ -63,6 +66,9 @@ static inline struct request_ctx *find_request_ctx(int handle, unsigned long seq
 
 static inline void destroy_request_ctx(struct request_ctx *ctx)
 {
+       if (ctx->timeout > 0)
+               g_source_remove(ctx->timeout);
+
        packet_unref(ctx->packet);
        dlist_remove_data(s_info.request_list, ctx);
        free(ctx);
@@ -336,7 +342,21 @@ static int service_cb(int handle, int readsize, void *data)
        return 0;
 }
 
-EAPI int com_core_packet_async_send(int handle, struct packet *packet, int (*recv_cb)(pid_t pid, int handle, const struct packet *packet, void *data), void *data)
+static gboolean timeout_cb(gpointer data)
+{
+       struct request_ctx *ctx = data;
+
+       ErrPrint("Timeout (Not responding in time)\n");
+
+       if (ctx->recv_cb)
+               ctx->recv_cb(ctx->pid, ctx->handle, NULL, ctx->data);
+
+       ctx->timeout = 0u;
+       destroy_request_ctx(ctx);
+       return FALSE;
+}
+
+EAPI int com_core_packet_async_send(int handle, struct packet *packet, unsigned int timeout, int (*recv_cb)(pid_t pid, int handle, const struct packet *packet, void *data), void *data)
 {
        int ret;
        struct request_ctx *ctx;
@@ -348,6 +368,11 @@ EAPI int com_core_packet_async_send(int handle, struct packet *packet, int (*rec
        ctx->recv_cb = recv_cb;
        ctx->data = data;
        ctx->packet = packet_ref(packet);
+       if (timeout > 0) {
+               ctx->timeout = g_timeout_add(timeout, timeout_cb, ctx);
+               if (ctx->timeout == 0)
+                       ErrPrint("Failed to add timeout\n");
+       }
 
        ret = secure_socket_send(handle, (void *)packet_data(packet), packet_size(packet));
        if (ret != packet_size(packet)) {