IPC: remove flow control API and move functionality into send()

There is no point in a separate API.

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This commit is contained in:
Angus Salkeld 2010-10-14 09:16:00 +11:00
parent 12b2d87bfa
commit e9d10dfdbe
4 changed files with 20 additions and 36 deletions

View File

@ -115,13 +115,6 @@ ssize_t qb_ipcc_sendv_recv(qb_ipcc_connection_t *c,
ssize_t qb_ipcc_event_recv(qb_ipcc_connection_t* c, void *msg_pt,
size_t msg_len, int32_t ms_timeout);
/**
* Get the flowcontrol state
* @param fc (out) QB_FALSE no fc, QB_TRUE fc enabled
* @return (0 == ok, -errno == error)
*/
int32_t qb_ipcc_flowcontrol_get(struct qb_ipcc_connection * c, int32_t *fc);
/* *INDENT-OFF* */
#ifdef __cplusplus
}

View File

@ -116,6 +116,9 @@ ssize_t qb_ipcc_send(struct qb_ipcc_connection * c, const void *msg_ptr,
if (msg_len > c->request.max_msg_size) {
return -EINVAL;
}
if (c->funcs.fc_get && c->funcs.fc_get(&c->request)) {
return -EAGAIN;
}
res = c->funcs.send(&c->request, msg_ptr, msg_len);
if (res > 0 && c->needs_sock_for_poll) {
@ -138,6 +141,10 @@ ssize_t qb_ipcc_sendv(struct qb_ipcc_connection* c, const struct iovec* iov,
return -EINVAL;
}
if (c->funcs.fc_get && c->funcs.fc_get(&c->request)) {
return -EAGAIN;
}
res = c->funcs.sendv(&c->request, iov, iov_len);
if (res > 0 && c->needs_sock_for_poll) {
qb_ipc_us_send(c->sock, &res, 1);
@ -160,6 +167,10 @@ ssize_t qb_ipcc_sendv_recv (
{
ssize_t res;
if (c->funcs.fc_get && c->funcs.fc_get(&c->request)) {
return -EAGAIN;
}
repeat_send:
res = qb_ipcc_sendv(c, iov, iov_len);
if (res < 0) {
@ -177,16 +188,6 @@ repeat_recv:
return res;
}
int32_t qb_ipcc_flowcontrol_get(struct qb_ipcc_connection * c, int32_t *fc)
{
if (c->funcs.fc_get == NULL) {
*fc = QB_FALSE;
return -ENOSYS;
}
*fc = c->funcs.fc_get(&c->request);
return 0;
}
int32_t qb_ipcc_fd_get(struct qb_ipcc_connection * c, int32_t * fd)
{
*fd = c->sock;

View File

@ -81,24 +81,17 @@ static void bm_finish(const char *operation, int32_t size)
printf("MB/sec, %9.3f\n", mbs_per_sec);
}
static int32_t my_fc = QB_TRUE;
static char buffer[1024 * 1024];
static int32_t bmc_send_nozc(uint32_t size)
{
struct qb_ipc_request_header *req_header = (struct qb_ipc_request_header *)buffer;
struct qb_ipc_response_header res_header;
int32_t res;
int32_t fc;
req_header->id = QB_IPC_MSG_USER_START + 3;
req_header->size = sizeof(struct qb_ipc_request_header) + size;
repeat_send:
qb_ipcc_flowcontrol_get(conn, &fc);
if (fc != my_fc) {
printf("flowcontrol:%d\n", my_fc);
my_fc = fc;
}
res = qb_ipcc_send(conn, req_header, req_header->size);
if (res < 0) {
if (res == -EAGAIN) {

View File

@ -196,29 +196,25 @@ static int32_t send_and_check(uint32_t size)
struct qb_ipc_request_header *req_header = (struct qb_ipc_request_header *)buffer;
struct qb_ipc_response_header res_header;
int32_t res;
int32_t try_times = 0;
req_header->id = IPC_MSG_REQ_TX_RX;
req_header->size = sizeof(struct qb_ipc_request_header) + size;
repeat_send:
res = qb_ipcc_flowcontrol_get(conn, &fc_enabled);
ck_assert_int_eq(res, 0);
if (fc_enabled) {
return -2;
}
res = qb_ipcc_send(conn, req_header, req_header->size);
try_times++;
if (res < 0) {
if (res == -EAGAIN) {
if (res == -EAGAIN && try_times < 10) {
goto repeat_send;
} else if (res == -EINVAL || res == -EINTR) {
perror("qb_ipcc_send");
return -1;
} else {
if (res == -EAGAIN && try_times >= 10) {
fc_enabled = QB_TRUE;
}
errno = -res;
perror("qb_ipcc_send");
goto repeat_send;
return res;
}
}
@ -260,8 +256,9 @@ static void test_ipc_txrx(void)
} while (conn == NULL && c < 5);
fail_if(conn == NULL);
size = QB_MIN(sizeof(struct qb_ipc_request_header), 64);
for (j = 1; j < 19; j++) {
size = (10 * j * j * j) + sizeof(struct qb_ipc_request_header);
size *= 2;
if (size >= MAX_MSG_SIZE)
break;
if (send_and_check(size) < 0) {