diff --git a/include/qb/qbipcc.h b/include/qb/qbipcc.h index 9787b2a..f5b1947 100644 --- a/include/qb/qbipcc.h +++ b/include/qb/qbipcc.h @@ -98,11 +98,6 @@ ssize_t qb_ipcc_recv(qb_ipcc_connection_t* c, void *msg_ptr, ssize_t qb_ipcc_event_recv(qb_ipcc_connection_t* c, void *msg_pt, size_t msg_len, int32_t ms_timeout); -/** - * Cleanup after receiving an event. - * @param c connection instance - */ -void qb_ipcc_event_release(qb_ipcc_connection_t* c); /* *INDENT-OFF* */ #ifdef __cplusplus diff --git a/lib/ipc_int.h b/lib/ipc_int.h index fb4c7fa..76cdb41 100644 --- a/lib/ipc_int.h +++ b/lib/ipc_int.h @@ -95,7 +95,6 @@ struct qb_ipcc_funcs { ssize_t (*recv)(struct qb_ipc_one_way *one_way, void *buf, size_t buf_size, int32_t timeout); ssize_t (*send)(struct qb_ipc_one_way *one_way, const void *data, size_t size); ssize_t (*sendv)(struct qb_ipc_one_way *one_way, const struct iovec *iov, size_t iov_len); - void (*event_release)(struct qb_ipcc_connection* c); void (*disconnect)(struct qb_ipcc_connection* c); }; diff --git a/lib/ipcc.c b/lib/ipcc.c index 4661602..8c0df39 100644 --- a/lib/ipcc.c +++ b/lib/ipcc.c @@ -171,11 +171,6 @@ ssize_t qb_ipcc_event_recv(struct qb_ipcc_connection * c, void *msg_pt, return c->funcs.recv(&c->event, msg_pt, msg_len, ms_timeout); } -void qb_ipcc_event_release(struct qb_ipcc_connection *c) -{ - c->funcs.event_release(c); -} - void qb_ipcc_disconnect(struct qb_ipcc_connection *c) { qb_util_log(LOG_DEBUG, "%s()", __func__); diff --git a/tests/check_ipc.c b/tests/check_ipc.c index b9d22d2..6a44adc 100644 --- a/tests/check_ipc.c +++ b/tests/check_ipc.c @@ -39,11 +39,12 @@ static qb_ipcc_connection_t *conn; static enum qb_ipc_type ipc_type; -#define IPC_MSG_REQ_TX_RX (QB_IPC_MSG_USER_START + 3) -#define IPC_MSG_RES_TX_RX (QB_IPC_MSG_USER_START + 13) -#define IPC_MSG_REQ_DISPATCH (QB_IPC_MSG_USER_START + 4) -#define IPC_MSG_RES_DISPATCH (QB_IPC_MSG_USER_START + 14) - +enum my_msg_ids { + IPC_MSG_REQ_TX_RX, + IPC_MSG_RES_TX_RX, + IPC_MSG_REQ_DISPATCH, + IPC_MSG_RES_DISPATCH +}; /* Test Cases * @@ -257,8 +258,8 @@ static void test_ipc_dispatch(void) int32_t j; int32_t c = 0; pid_t pid; - struct qb_ipc_request_header *req_header = (struct qb_ipc_request_header *)buffer; - struct qb_ipc_response_header *res_header; + struct qb_ipc_request_header req_header; + struct qb_ipc_response_header *res_header = (struct qb_ipc_response_header*)buffer; pid = run_function_in_new_process(run_ipc_server); fail_if(pid == -1); @@ -275,11 +276,11 @@ static void test_ipc_dispatch(void) } while (conn == NULL && c < 5); fail_if(conn == NULL); - req_header->id = IPC_MSG_REQ_DISPATCH; - req_header->size = sizeof(struct qb_ipc_request_header); + req_header.id = IPC_MSG_REQ_DISPATCH; + req_header.size = sizeof(struct qb_ipc_request_header); -repeat_send: - res = qb_ipcc_send(conn, req_header, req_header->size); + repeat_send: + res = qb_ipcc_send(conn, &req_header, req_header.size); if (res < 0) { if (res == -EAGAIN || res == -ENOMEM) { goto repeat_send; @@ -292,11 +293,19 @@ repeat_send: goto repeat_send; } } - - res = qb_ipcc_event_recv(conn, (void**)&res_header, 0); + repeat_event_recv: + res = qb_ipcc_event_recv(conn, res_header, IPC_BUF_SIZE, 0); + if (res < 0) { + if (res == -EAGAIN) { + goto repeat_event_recv; + } else { + errno = -res; + perror("qb_ipcc_send"); + goto repeat_send; + } + } ck_assert_int_eq(res, sizeof(struct qb_ipc_response_header)); ck_assert_int_eq(res_header->id, IPC_MSG_RES_DISPATCH); - qb_ipcc_event_release(conn); qb_ipcc_disconnect(conn); stop_process(pid);