Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liblongpath-rsync
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liblongpath
liblongpath-rsync
Commits
1c99b1d9
Commit
1c99b1d9
authored
Jan 01, 2011
by
Wayne Davison
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Report all socket connection errors if we fail.
Fixes bug 6588.
parent
575933e9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
5 deletions
+23
-5
socket.c
socket.c
+23
-5
No files found.
socket.c
View file @
1c99b1d9
...
...
@@ -182,7 +182,7 @@ int open_socket_out(char *host, int port, const char *bind_addr,
int
af_hint
)
{
int
type
=
SOCK_STREAM
;
int
error
,
s
;
int
error
,
s
,
j
,
addr_cnt
,
*
errnos
;
struct
addrinfo
hints
,
*
res0
,
*
res
;
char
portbuf
[
10
];
char
*
h
,
*
cp
;
...
...
@@ -244,12 +244,17 @@ int open_socket_out(char *host, int port, const char *bind_addr,
return
-
1
;
}
for
(
res
=
res0
,
addr_cnt
=
0
;
res
;
res
=
res
->
ai_next
,
addr_cnt
++
)
{}
errnos
=
new_array0
(
int
,
addr_cnt
);
if
(
!
errnos
)
out_of_memory
(
"open_socket_out"
);
s
=
-
1
;
/* Try to connect to all addresses for this machine until we get
* through. It might e.g. be multi-homed, or have both IPv4 and IPv6
* addresses. We need to create a socket for each record, since the
* address record tells us what protocol to use to try to connect. */
for
(
res
=
res0
;
res
;
res
=
res
->
ai_next
)
{
for
(
res
=
res0
,
j
=
0
;
res
;
res
=
res
->
ai_next
,
j
++
)
{
s
=
socket
(
res
->
ai_family
,
res
->
ai_socktype
,
res
->
ai_protocol
);
if
(
s
<
0
)
continue
;
...
...
@@ -280,8 +285,10 @@ int open_socket_out(char *host, int port, const char *bind_addr,
if
(
connect_timeout
>
0
)
alarm
(
0
);
if
(
s
<
0
)
if
(
s
<
0
)
{
errnos
[
j
]
=
errno
;
continue
;
}
if
(
proxied
&&
establish_proxy_connection
(
s
,
host
,
port
,
...
...
@@ -293,10 +300,21 @@ int open_socket_out(char *host, int port, const char *bind_addr,
break
;
}
freeaddrinfo
(
res0
);
if
(
s
<
0
)
{
rsyserr
(
FERROR
,
errno
,
"failed to connect to %s"
,
h
);
return
-
1
;
char
buf
[
2048
];
for
(
res
=
res0
,
j
=
0
;
res
;
res
=
res
->
ai_next
,
j
++
)
{
if
(
errnos
[
j
]
==
0
)
continue
;
if
(
inet_ntop
(
res
->
ai_family
,
res
->
ai_addr
->
sa_data
+
2
,
buf
,
sizeof
buf
)
==
NULL
)
strlcpy
(
buf
,
"*inet_ntop failed*"
,
sizeof
buf
);
rsyserr
(
FERROR
,
errnos
[
j
],
"failed to connect to %s (%s)"
,
h
,
buf
);
}
s
=
-
1
;
}
free
(
errnos
);
return
s
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment