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

Support ipv6 in http client #310

Merged
merged 4 commits into from
Dec 25, 2023
Merged

Conversation

HanLee13
Copy link
Collaborator

  1. Support ipv6 in http client.
  • refactor KernelSocketClient by removing socket_family in KernelSocketClient.
  • apply dns load balance in DefaultResolver.
  • fix bug in DefaultResolver when timeout happen.
  1. Add big writes/uid/gid/du support to FUSE
  • In Fuse 2.x, without big writes, write io size is limited to 4k. Turing it on can enlarge write io size to 128K at maximum.
  • Support du by adding st_blocks to xmp_getattr result.
  • Add default uid/gid to xmp_getattr to avoid permission problems.

- refactor KernelSocketClient.
- apply dns load balance in DefaultResolver.
- fix bug in DefaultResolver when timeout happen.
- In Fuse 2.x, without big writes, write io size is limited to 4k. Turing it on can enlarge write io size to 128K at maximum.
- Support du by adding st_blocks to xmp_getattr result.
- Add default uid/gid to xmp_getattr to avoid permission problems.
@CLAassistant
Copy link

CLAassistant commented Dec 20, 2023

CLA assistant check
All committers have signed the CLA.

@HanLee13 HanLee13 marked this pull request as ready for review December 20, 2023 10:56
@HanLee13 HanLee13 assigned HanLee13 and unassigned HanLee13 Dec 20, 2023
net/utils.cpp Outdated
ipaddr.recycle(true);
if (ip.undefined() || ipaddr->empty()) ipaddr.recycle(true);
else {
for (auto it = ipaddr->begin(); it != ipaddr->end(); ++it) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

try std::list::remove(const T& value)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

return new IPAddr(ip);
}
return new IPAddr; // undefined addr
sem.wait(1, resolve_timeout_);
Copy link
Collaborator

Choose a reason for hiding this comment

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

if time out, sem will be destructed upon return, but it may be referenced afterwards in the resolving thread.

Copy link
Collaborator

Choose a reason for hiding this comment

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

addrs may also be operated (erased or deleted) when the resolving thread is still running.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

net/utils.cpp Outdated
gethostbyname(host, *addrs);
auto time_elapsed = std::chrono::duration_cast<std::chrono::microseconds>(
std::chrono::steady_clock::now() - now).count();
if ((uint64_t)time_elapsed <= resolve_timeout_) sem.signal(1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

timing control may not be precise enough?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Cause the photon thread should sleep for more than resolve_timeout_, this is enought to run correctly, right?

net/utils.cpp Outdated
auto ctr = [&]() -> IPAddr * {
std::vector<IPAddr> addrs;
auto ctr = [&]() -> std::list<IPAddr>* {
auto addrs = new std::list<IPAddr>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

consider unordered_set

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If using unordered_set, get element in a round-robin order would be O(N).

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK

net/utils.cpp Outdated
if (ips->empty()) LOG_ERRNO_RETURN(0, IPAddr(), "Domain resolution for ` failed", host);
auto ret = ips->front();
if (ips->size() > 1) { // access in round robin order
ips->pop_front();
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's costly to pop and push every time. It's better to use intrusive_list.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

net/utils.cpp Outdated
auto ctr = [&]() -> IPAddr * {
std::vector<IPAddr> addrs;
auto ctr = [&]() -> std::list<IPAddr>* {
auto addrs = new std::list<IPAddr>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

OK

@HanLee13 HanLee13 force-pushed the release/0.7 branch 2 times, most recently from 789514d to 450dd57 Compare December 22, 2023 09:12
auto ctr = [&]() -> IPAddr * {
std::vector<IPAddr> addrs;
auto ctr = [&]() -> IPAddrList* {
auto addrs = new IPAddrList();
Copy link
Collaborator

Choose a reason for hiding this comment

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

The list doesn't need to be new-ed, as it's only a pointer to the node, initially nullptr. And nodes are directly pushed-back into the list.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ObjectCache need its value be a pointer, otherwise using ObjectCache::Borrow would be a problem.

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK

net/utils.cpp Outdated
if (ips->empty()) LOG_ERRNO_RETURN(0, IPAddr(), "Domain resolution for ` failed", host);
auto ret = ips->front();
if (!ret->single()) { // access in round robin order
auto front = ips->pop_front();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just update the pointer in the list object to point to the next node, without popping and pushing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

net/utils.cpp Outdated
ipaddr.recycle(true);
if (ip.undefined() || ipaddr->empty()) ipaddr.recycle(true);
else {
for (auto it : *ipaddr) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's probably better to iterate in reversed order, because the item to be discarded is likely at the end of the ring.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@lihuiba lihuiba merged commit 7cab63e into alibaba:release/0.7 Dec 25, 2023
7 checks passed
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

3 participants