Пример #1
0
static int __tcpnode_push_and_send(struct nd_tcp_node *node, void *msg_buf, size_t datalen, int is_write_all)
{
	ENTER_FUNC();
	signed int ret =0;
	
	nd_netbuf_t *pbuf = &(node->send_buffer);
	size_t length_in_buff = ndlbuf_datalen(pbuf);

	if (length_in_buff) {
		int flushlen = node->sock_write((nd_handle)node, ndlbuf_data(pbuf), length_in_buff);
		if (flushlen > 0) {
			nd_assert(flushlen <= length_in_buff);
			ndlbuf_sub_data(pbuf, (size_t)flushlen);
		}
		length_in_buff = ndlbuf_datalen(pbuf);

	}
	if (length_in_buff == 0) {
		ret = __tcpnode_send_with_save(node, msg_buf, datalen);
	}
	else {
		size_t space_len = ndlbuf_free_capacity(pbuf);
		if(is_write_all && space_len < datalen) {
			node->myerrno = NDERR_WOULD_BLOCK;
			ret = -1;
		}
		else {
			ret = ndlbuf_write(pbuf, (void*)msg_buf, datalen, EBUF_SPECIFIED);
		}
	}
	LEAVE_FUNC();
	return ret ;
}
Пример #2
0
char *NDHttpRequest::_getCurParseAddr()
{
	if (ndlbuf_datalen(&m_recvBuf)) {
		return (char*) ndlbuf_data(&m_recvBuf) ;
	}
	return NULL ;

}
Пример #3
0
int NDHttpRequest::_getDataSize()
{
	return (int) ndlbuf_datalen(&m_recvBuf) ;
}