Exemplo n.º 1
0
static int
tnt_log_process_xlog(struct tnt_log *l, char *buf, uint32_t size,
		     union tnt_log_value *value)
{
	(void)size;
	/* copying row data */
	memcpy(&l->current.row, buf, sizeof(l->current.row));

	/* preparing pseudo iproto header */
	struct tnt_header hdr_iproto;
	hdr_iproto.type = l->current.row.op;
	hdr_iproto.len = l->current.hdr.len - sizeof(l->current.row);
	hdr_iproto.reqid = 0;

	/* deserializing operation */
	tnt_request_init(&value->r);
	size_t off = 0;
	int rc = tnt_request(&value->r,
			     buf + sizeof(l->current.row),
			     l->current.hdr.len - sizeof(l->current.row),
			     &off,
			     &hdr_iproto);

	/* in case of not completed request or parsing error */
	if (rc != 0)
		return tnt_log_seterr(l, TNT_LOG_ECORRUPT);
	return 0;
}
Exemplo n.º 2
0
static int
tnt_buf_request(struct tnt_stream *s, struct tnt_request *r) {
	struct tnt_stream_buf *sb = TNT_SBUF_CAST(s);
	if (sb->data == NULL)
		return -1;
	if (sb->size == sb->rdoff)
		return 1;
	size_t off = 0;
	int rc = tnt_request(r, sb->data + sb->rdoff, sb->size - sb->rdoff,
			     &off, NULL);
	if (rc == 0)
		sb->rdoff += off;
	return rc;
}