Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support ldap v3 search #7

Merged
merged 27 commits into from
Feb 14, 2023
Merged

feat: support ldap v3 search #7

merged 27 commits into from
Feb 14, 2023

Conversation

bzp2010
Copy link
Contributor

@bzp2010 bzp2010 commented Feb 6, 2023

Support building LDAPv3 search request and response data parsing.


In addition, the code uses receiveuntil and while true for reading data, which in my perception is a risk of blocking the worker, and I wonder if there is a good way to improve it (its description and reasons are in the code comments).

@bzp2010 bzp2010 self-assigned this Feb 6, 2023
@kingluo
Copy link
Contributor

kingluo commented Feb 6, 2023

In addition, the code uses receiveuntil and while true for reading data, which in my perception is a risk of blocking the worker, and I wonder if there is a good way to improve it (its description and reasons are in the code comments).

The loop of receiveuntil will not block the worker, even if the package is large, it's limited to the length of socket buffer.

@bzp2010
Copy link
Contributor Author

bzp2010 commented Feb 6, 2023

The loop of receiveuntil will not block the worker, even if the package is large, it's limited to the length of socket buffer.

@kingluo My concern is that if the data has already been read (i.e. there is no more data in the buffer), then calling the reader again will block until read timeout, at which point what is its behavior? 🤔

@kingluo
Copy link
Contributor

kingluo commented Feb 6, 2023

The loop of receiveuntil will not block the worker, even if the package is large, it's limited to the length of socket buffer.

@kingluo My concern is that if the data has already been read (i.e. there is no more data in the buffer), then calling the reader again will block until read timeout, at which point what is its behavior? 🤔

receiveutil is a nonblocking method of cosocket, it just analyzes the data according to dfa pattern, which yields if it needs more data. Timeout event, if exists, will trigger next resume.

@bzp2010
Copy link
Contributor Author

bzp2010 commented Feb 6, 2023

receiveutil is a nonblocking method of cosocket, it just analyzes the data according to dfa pattern, which yields if it needs more data. Timeout event, if exists, will trigger next resume.

Get it, this means that that HTTP request that triggered the LDAP operation is stuck and doesn't block other requests, which is great.

@bzp2010 bzp2010 marked this pull request as ready for review February 7, 2023 10:48
if err then
return nil, "Invalid LDAP message encoding: " .. err
-- Get the data of the specified length
local packet = socket:receive(packet_len)

Choose a reason for hiding this comment

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

Do we need to handle read err here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

@@ -16,6 +18,15 @@ local _M = {}
local mt = { __index = _M }


local function to_hex_sequence(data)

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved

Copy link

@hanf2x hanf2x left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -40,10 +40,11 @@ jobs:
sudo apt -y install lua5.1 luarocks
sudo luarocks install lua_pack
sudo luarocks install lpeg
sudo luarocks install lua-resty-string

Choose a reason for hiding this comment

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

Interesting. Isn't the lua-resty-string a part of the std library?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe, it's a blind spot in my knowledge, let me delete it.

@@ -15,6 +15,7 @@ description = {
dependencies = {
"lua_pack = 2.0.0-0"
"lpeg = 1.0.2-1"
"lua-resty-string = 0.09-0"

Choose a reason for hiding this comment

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

We can remove it too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me remove it.

@bzp2010 bzp2010 merged commit 9e21570 into api7:main Feb 14, 2023
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.

None yet

4 participants