提交 3dcb78d3 编写于 作者: B bernard.xiong@gmail.com

optimize netio code.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1674 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 e1e75c45
...@@ -183,6 +183,7 @@ netio_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) ...@@ -183,6 +183,7 @@ netio_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
} }
} else if (ns->state == NETIO_STATE_RECV_DATA) { } else if (ns->state == NETIO_STATE_RECV_DATA) {
int chunk_length;
if(ns->cntr == 0){ if(ns->cntr == 0){
/* save the first byte of this new round of data /* save the first byte of this new round of data
...@@ -191,13 +192,18 @@ netio_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) ...@@ -191,13 +192,18 @@ netio_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
*/ */
ns->first_byte = *data_ptr; ns->first_byte = *data_ptr;
} }
ns->buf_ptr[ns->buf_pos++] = *data_ptr++; if (ns->cntr + (data_cntr + 1) < ns->data_len) chunk_length = data_cntr + 1;
ns->cntr++; else chunk_length = (ns->data_len - ns->cntr);
if (ns->buf_pos == NETIO_BUF_SIZE) { ns->buf_pos += chunk_length;
data_ptr += chunk_length;
ns->cntr += chunk_length;
data_cntr -= (chunk_length - 1);
if (ns->buf_pos >= NETIO_BUF_SIZE) {
/* circularize the buffer */ /* circularize the buffer */
ns->buf_pos = 0; ns->buf_pos %= NETIO_BUF_SIZE;
} }
if(ns->cntr == ns->data_len){ if(ns->cntr == ns->data_len){
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册