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}\"")
+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
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);
#include <stdlib.h>
#include <fcntl.h>
+#include <glib.h>
#include <dlog.h>
#include "debug.h"
struct packet *packet;
int (*recv_cb)(pid_t pid, int handle, const struct packet *packet, void *data);
void *data;
+
+ guint timeout;
};
struct recv_ctx {
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);
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;
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)) {