static int tnt_rpl_request(struct tnt_stream *s, struct tnt_request *r) { struct tnt_stream_rpl *sr = TNT_RPL_CAST(s); struct tnt_stream_net *sn = TNT_SNET_CAST(sr->net); /* fetching header */ if (tnt_io_recv(sn, (char*)&sr->hdr, sizeof(sr->hdr)) == -1) return -1; /* fetching row header */ if (tnt_io_recv(sn, (char*)&sr->row, sizeof(sr->row)) == -1) return -1; /* preparing pseudo iproto header */ struct tnt_header hdr_iproto; hdr_iproto.type = sr->row.op; hdr_iproto.len = sr->hdr.len - sizeof(struct tnt_log_row_v11); hdr_iproto.reqid = 0; /* deserializing operation */ if (tnt_request_from(r, (tnt_request_t)tnt_rpl_recv_cb, sr->net, &hdr_iproto) == -1) return -1; return 0; }
int tnt_request(struct tnt_request *r, char *buf, size_t size, size_t *off, struct tnt_header *hdr) { if (hdr == NULL) { if (size < (sizeof(struct tnt_header))) { if (off) *off = sizeof(struct tnt_header) - size; return 1; } struct tnt_header *hdr_ = (struct tnt_header*)buf; if (size < hdr_->len) { if (off) *off = hdr_->len - size; return 1; } } size_t offv = 0; void *ptr[2] = { buf, &offv }; int rc = tnt_request_from(r, (tnt_request_t)tnt_request_cb, ptr, hdr); if (off) *off = offv; return rc; }
static int tnt_net_request(struct tnt_stream *s, struct tnt_request *r) { /* read doesn't touches wrcnt */ return tnt_request_from(r, (tnt_request_t)tnt_net_recv_cb, s, NULL); }