Skip to content

bsd style receive method for ngx.socket.tcp#861

Open
brg-liuwei wants to merge 2 commits intoopenresty:masterfrom
brg-liuwei:master
Open

bsd style receive method for ngx.socket.tcp#861
brg-liuwei wants to merge 2 commits intoopenresty:masterfrom
brg-liuwei:master

Conversation

@brg-liuwei
Copy link
Copy Markdown

@agentzh bsd style receive for ngx.socket.tcp in lua-nginx-module, and add a comment in the document. Maybe I need to add more test cases, yes?

@mike07026 bsd style receive for cosocket in http has accomplished. Good day.

I hereby granted the copyright of the changes in this pull request to the authors of this lua-nginx-module project.

Comment thread t/146-tcp-socket-receive-bsd-style.t Outdated
"zzz",
},
}
local i = math.random(2)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's test the simplest thing that could possibly work. Complicated test cases are hard to debug when they fail. It took me a while to understand what this test case is trying to do. Better make it as straight forward as possible. No tricks please. Thanks!

@@ -0,0 +1,94 @@
# vim:set ft= ts=4 sw=4 et fdm=marker:

use Test::Nginx::Socket::Lua 'no_plan';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to avoid using no_plan in the lua-nginx-module test suite.
What need to do is just copy the run test number from Bad plan error message.

[error]
--- error_log
lua tcp socket read bsd

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trailing line here is unnecessary.


dd("data read: %.*s", (int) bytes, b->pos);

u->buf_in->buf->last = ngx_cpymem(u->buf_in->buf->last, b->pos, bytes);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u->buf_in->buf and b actually point to the same buffer. So there is no need to copy the content. Just increase the pointer position is enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants