#define RXGEN_BUF_MAGIC (0x52420000U | __LINE__)
#define RXGEN_BUF_DEAD (0x6b6bU | __LINE__)
+#define debug(fmt, ...) do { printf(fmt, ## __VA_ARGS__); } while (0)
+
/*
* dump the control messages
*/
return NULL;
}
- //printf("Alloc: buf=%p data=%p\n", buf, data);
+ debug("Alloc: buf=%p data=%p\n", buf, data);
buf->magic = RXGEN_BUF_MAGIC;
buf->buf = data;
size_t ctrllen;
unsigned char control[128];
struct iovec iov[16];
- int ioc, ret;
+ int ioc, ret, i;
- //printf("-->rxrpc_send_data(%u,%u)\n", call->state, call->data_count);
+ debug("-->rxrpc_send_data(%u,0x%x)\n", call->state, call->data_count);
rxrpc_check_call(call);
if (cursor == call->buffer_tail)
end = call->data_cursor - cursor->buf;
+ debug("BUF[%02u] %04x %04x\n", ioc, io_cursor, end);
+
iov[ioc].iov_base = cursor->buf + io_cursor;
iov[ioc].iov_len = end - io_cursor;
if (cursor == call->buffer_tail) {
/* Send the data */
//dump_cmsg(&msg);
- if (0) {
- const uint8_t *p;
- unsigned i, j;
-
- printf("NAME %02u [", msg.msg_namelen);
- p = (const void *)msg.msg_name;
- for (i = 0; i < msg.msg_namelen; i++)
- printf("%02x", *p++);
- printf("]\n");
-
- for (j = 0; j < msg.msg_iovlen; j++) {
- printf("IOV[%02u] %04zu [", j, msg.msg_iov[j].iov_len);
- p = (const void *)msg.msg_iov[j].iov_base;
- for (i = 0; i < msg.msg_iov[j].iov_len; i++)
- printf("%02x", *p++);
- printf("]\n");
- }
-
- printf("CTRL %02zu [", msg.msg_controllen);
- p = (const void *)msg.msg_control;
- for (i = 0; i < msg.msg_controllen; i++)
- printf("%02x", *p++);
- printf("]\n");
-
- printf("FLAGS %x\n", msg.msg_flags);
- }
+ for (i = 0; i < msg.msg_iovlen; i++)
+ debug("IOV[%02u] %04zu %p\n",
+ i, msg.msg_iov[i].iov_len, msg.msg_iov[i].iov_base);
ret = sendmsg(call->conn->fd, &msg, call->more ? MSG_MORE : 0) == -1 ? -1 : 0;
- if (0) {
- printf("SENDMSG: %d\n", ret);
- }
+ debug("SENDMSG: %d\n", ret);
if (ret == -1)
return -1;
if (call->state == rx_call_cl_waiting_for_response) {
/* Prepare to decode the response */
- //printf("Prep to decode\n");
+ debug("Prep to decode\n");
call->data_stop = call->data_cursor = call->data_start = call->buffer_head->buf;
call->buffer_head->io_cursor = 0;
call->data_count = 0;
msg.msg_flags = 0;
ret = recvmsg(z_conn->fd, &msg, MSG_PEEK);
- if (0) {
- printf("RECVMSG: %d\n", ret);
- }
+ debug("RECVMSG: %d\n", ret);
if (ret == -1)
return -1;
msg.msg_controllen = sizeof(control);
msg.msg_flags = 0;
- //printf("Recv: buf[0]=%p data[0]=%p (io=%u)\n",
- // call->buffer_tail, call->buffer_tail->buf, call->buffer_tail->io_cursor);
+ debug("Recv: buf[0]=%p data[0]=%p (io=%u)\n",
+ call->buffer_tail, call->buffer_tail->buf, call->buffer_tail->io_cursor);
rxrpc_check_call(call);
msg.msg_iovlen = 4;
ret = recvmsg(z_conn->fd, &msg, 0);
- if (0) {
- printf("RECVMSG: %d\n", ret);
- }
+ debug("RECVMSG: %d\n", ret);
if (ret == -1)
return -1;
- //printf("RECV: %d [fl:%d]\n", ret, msg.msg_flags);
- //printf("CMSG: %zu\n", msg.msg_controllen);
- //printf("IOV: %zu [0]=%zu\n", msg.msg_iovlen, iov[0].iov_len);
+ debug("RECV: %d [fl:%d]\n", ret, msg.msg_flags);
+ debug("CMSG: %zu\n", msg.msg_controllen);
+ debug("IOV: %zu [0]=%zu\n", msg.msg_iovlen, iov[0].iov_len);
/* Attach any used buffers to the call and discard the rest */
if (ret > 0) {
for (ioc = 0; ioc < 4 && ret > 0; ioc++) {
unsigned added = RXGEN_BUFFER_SIZE - bufs[ioc]->io_cursor;
- //printf("xfer[%d] space=%u rem=%d\n", ioc, added, ret);
+ debug("xfer[%d] space=%u rem=%d\n", ioc, added, ret);
if (added > ret)
added = ret;
bufs[ioc]->io_cursor += added;
rxrpc_check_call(call);
- if (0) {
- for (cursor = call->buffer_head; cursor; cursor = cursor->next)
- printf("Recv buf=%p data=%p ioc=%u\n",
- cursor, cursor->buf, cursor->io_cursor);
- }
+ for (cursor = call->buffer_head; cursor; cursor = cursor->next)
+ debug("Recv buf=%p data=%p ioc=%u\n",
+ cursor, cursor->buf, cursor->io_cursor);
/* Process the metadata */
if (msg.msg_flags & MSG_EOR)
switch (call->state) {
case rx_call_cl_complete:
- //printf("Call complete\n");
+ debug("Call complete\n");
return 0;
case rx_call_remotely_aborted ... rx_call_rejected_busy:
- //printf("Call failed\n");
+ debug("Call failed\n");
errno = call->error_code;
return -1;
default: