mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
resolved: fix fastopen fallback
We should not invalidate the socket address size before we use it.
Fixes: #34579
(cherry picked from commit 5699e4c2d4
)
This commit is contained in:
parent
5e45c58274
commit
964f7772ad
@ -205,6 +205,7 @@ static int dns_stream_identify(DnsStream *s) {
|
||||
|
||||
ssize_t dns_stream_writev(DnsStream *s, const struct iovec *iov, size_t iovcnt, int flags) {
|
||||
ssize_t m;
|
||||
int r;
|
||||
|
||||
assert(s);
|
||||
assert(iov);
|
||||
@ -224,12 +225,14 @@ ssize_t dns_stream_writev(DnsStream *s, const struct iovec *iov, size_t iovcnt,
|
||||
|
||||
m = sendmsg(s->fd, &hdr, MSG_FASTOPEN);
|
||||
if (m < 0) {
|
||||
if (errno == EOPNOTSUPP) {
|
||||
s->tfo_salen = 0;
|
||||
if (connect(s->fd, &s->tfo_address.sa, s->tfo_salen) < 0)
|
||||
return -errno;
|
||||
if (ERRNO_IS_NOT_SUPPORTED(errno)) {
|
||||
/* MSG_FASTOPEN not supported? Then try to connect() traditionally */
|
||||
r = RET_NERRNO(connect(s->fd, &s->tfo_address.sa, s->tfo_salen));
|
||||
s->tfo_salen = 0; /* connection is made */
|
||||
if (r < 0 && r != -EINPROGRESS)
|
||||
return r;
|
||||
|
||||
return -EAGAIN;
|
||||
return -EAGAIN; /* In case of EINPROGRESS, EAGAIN or success: return EAGAIN, so that caller calls us again */
|
||||
}
|
||||
if (errno == EINPROGRESS)
|
||||
return -EAGAIN;
|
||||
|
Loading…
Reference in New Issue
Block a user