-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtp_ext.h
43 lines (34 loc) · 859 Bytes
/
tp_ext.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef TP_EXT_H_
#define TP_EXT_H_
//////////////////////////////////////////////////////
// Missed tp methods
//////////////////////////////////////////////////////
static inline ssize_t
tp_reqbuf(const char *buf, size_t size)
{
const ssize_t header_size = 5;
if (tpunlikely(size < header_size))
return header_size - size;
/* len */
if (mp_typeof(*buf) != MP_UINT)
{
/* wrong data*/
return -1;
}
ssize_t len = mp_decode_uint(&buf);
return header_size + len - size;
}
static inline ssize_t
tp_req(struct tp *p)
{
return tp_reqbuf(p->s, tp_used(p));
}
static inline ssize_t
tp_recv2(struct tnt_stream_net *s, struct tp *p, size_t to_recv)
{
// ssize_t received = tb_sesrecv(s, p->p, to_recv, false);
ssize_t received = tnt_io_recv_raw(s, p->p, to_recv, false);
p->p += received;
return received;
}
#endif // TP_EXT_H_