-
Notifications
You must be signed in to change notification settings - Fork 115
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
Conversation
HanLee13
commented
Dec 20, 2023
- 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.
- 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.
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) { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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_); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider unordered_set
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
789514d
to
450dd57
Compare
auto ctr = [&]() -> IPAddr * { | ||
std::vector<IPAddr> addrs; | ||
auto ctr = [&]() -> IPAddrList* { | ||
auto addrs = new IPAddrList(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
450dd57
to
1c653cd
Compare