Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
c41fc475
Commit
c41fc475
authored
Jun 07, 2012
by
Chris Young
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
horrid gethostbyname compatibility
parent
2774ccb8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
4 deletions
+30
-4
src/netops.c
+30
-4
No files found.
src/netops.c
View file @
c41fc475
...
@@ -376,11 +376,17 @@ static int ssl_setup(git_transport *t, const char *host)
...
@@ -376,11 +376,17 @@ static int ssl_setup(git_transport *t, const char *host)
int
gitno_connect
(
git_transport
*
t
,
const
char
*
host
,
const
char
*
port
)
int
gitno_connect
(
git_transport
*
t
,
const
char
*
host
,
const
char
*
port
)
{
{
#ifndef __amigaos4__
struct
addrinfo
*
info
=
NULL
,
*
p
;
struct
addrinfo
*
info
=
NULL
,
*
p
;
struct
addrinfo
hints
;
struct
addrinfo
hints
;
#else
int
p
;
struct
hostent
*
hent
;
struct
sockaddr_in
saddr
;
#endif
int
ret
;
int
ret
;
GIT_SOCKET
s
=
INVALID_SOCKET
;
GIT_SOCKET
s
=
INVALID_SOCKET
;
#ifndef __amigaos4__
memset
(
&
hints
,
0x0
,
sizeof
(
struct
addrinfo
));
memset
(
&
hints
,
0x0
,
sizeof
(
struct
addrinfo
));
hints
.
ai_family
=
AF_UNSPEC
;
hints
.
ai_family
=
AF_UNSPEC
;
hints
.
ai_socktype
=
SOCK_STREAM
;
hints
.
ai_socktype
=
SOCK_STREAM
;
...
@@ -389,15 +395,29 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
...
@@ -389,15 +395,29 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
giterr_set
(
GITERR_NET
,
"Failed to resolve address for %s: %s"
,
host
,
gai_strerror
(
ret
));
giterr_set
(
GITERR_NET
,
"Failed to resolve address for %s: %s"
,
host
,
gai_strerror
(
ret
));
return
-
1
;
return
-
1
;
}
}
#else
hent
=
gethostbyname
(
host
);
#endif
#ifndef __amigaos4__
for
(
p
=
info
;
p
!=
NULL
;
p
=
p
->
ai_next
)
{
for
(
p
=
info
;
p
!=
NULL
;
p
=
p
->
ai_next
)
{
s
=
socket
(
p
->
ai_family
,
p
->
ai_socktype
,
p
->
ai_protocol
);
s
=
socket
(
p
->
ai_family
,
p
->
ai_socktype
,
p
->
ai_protocol
);
#else
for
(
p
=
0
;
hent
->
h_addr_list
[
p
]
!=
NULL
;
p
++
)
{
s
=
socket
(
hent
->
h_addrtype
,
SOCK_STREAM
,
0
);
#endif
if
(
s
==
INVALID_SOCKET
)
{
if
(
s
==
INVALID_SOCKET
)
{
net_set_error
(
"error creating socket"
);
net_set_error
(
"error creating socket"
);
break
;
break
;
}
}
#ifndef __amigaos4__
if
(
connect
(
s
,
p
->
ai_addr
,
(
socklen_t
)
p
->
ai_addrlen
)
==
0
)
if
(
connect
(
s
,
p
->
ai_addr
,
(
socklen_t
)
p
->
ai_addrlen
)
==
0
)
#else
saddr
.
sin_addr
.
s_addr
=
*
hent
->
h_addr_list
[
p
];
saddr
.
sin_family
=
hent
->
h_addrtype
;
saddr
.
sin_port
=
port
;
if
(
connect
(
s
,
(
struct
sockaddr
*
)
&
saddr
,
sizeof
(
struct
sockaddr_in
))
==
0
)
#endif
break
;
break
;
/* If we can't connect, try the next one */
/* If we can't connect, try the next one */
...
@@ -406,14 +426,20 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
...
@@ -406,14 +426,20 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
}
}
/* Oops, we couldn't connect to any address */
/* Oops, we couldn't connect to any address */
if
(
s
==
INVALID_SOCKET
&&
p
==
NULL
)
{
if
(
s
==
INVALID_SOCKET
&&
#ifndef __amigaos4__
p
==
NULL
)
{
#else
hent
->
h_addr_list
[
p
]
==
NULL
)
{
#endif
giterr_set
(
GITERR_OS
,
"Failed to connect to %s"
,
host
);
giterr_set
(
GITERR_OS
,
"Failed to connect to %s"
,
host
);
return
-
1
;
return
-
1
;
}
}
t
->
socket
=
s
;
t
->
socket
=
s
;
#ifndef __amigaos4__
freeaddrinfo
(
info
);
freeaddrinfo
(
info
);
#endif
if
(
t
->
encrypt
&&
ssl_setup
(
t
,
host
)
<
0
)
if
(
t
->
encrypt
&&
ssl_setup
(
t
,
host
)
<
0
)
return
-
1
;
return
-
1
;
...
...
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