summaryrefslogtreecommitdiff
path: root/src/transports
diff options
context:
space:
mode:
authorVicent Martí <tanoku@gmail.com>2012-05-05 16:47:20 -0700
committerVicent Martí <tanoku@gmail.com>2012-05-05 16:47:20 -0700
commitcd58c15c589970765cd46e7bbdaebf6250fd7626 (patch)
treef7f95202e96151b3ac7ea22697e7e60825375268 /src/transports
parent48ecd122ea6fb8cf12fb4029974c314e5d9efb62 (diff)
parent35cdd261f353696181236328323e8d123cad57d4 (diff)
downloadlibgit2-cd58c15c589970765cd46e7bbdaebf6250fd7626.tar.gz
Merge remote-tracking branch 'scottjg/fix-mingw32' into development
Conflicts: src/netops.c src/netops.h src/transports/http.c tests-clar/clar
Diffstat (limited to 'src/transports')
-rw-r--r--src/transports/git.c23
-rw-r--r--src/transports/http.c4
2 files changed, 15 insertions, 12 deletions
diff --git a/src/transports/git.c b/src/transports/git.c
index c51b1670..9eae9a1a 100644
--- a/src/transports/git.c
+++ b/src/transports/git.c
@@ -100,10 +100,11 @@ cleanup:
*/
static int do_connect(transport_git *t, const char *url)
{
- GIT_SOCKET s;
char *host, *port;
const char prefix[] = "git://";
- int error, connected = 0;
+ int error;
+
+ t->socket = INVALID_SOCKET;
if (!git__prefixcmp(url, prefix))
url += strlen(prefix);
@@ -111,22 +112,24 @@ static int do_connect(transport_git *t, const char *url)
if (gitno_extract_host_and_port(&host, &port, url, GIT_DEFAULT_PORT) < 0)
return -1;
- s = gitno_connect(host, port);
- connected = 1;
- error = send_request(s, NULL, url);
- t->socket = s;
+ if (gitno_connect(&t->socket, host, port) == 0) {
+ error = send_request(t->socket, NULL, url);
+ }
git__free(host);
git__free(port);
- if (error < GIT_SUCCESS && s > 0)
- gitno_close(s);
- if (!connected) {
+ if (error < 0 && t->socket != INVALID_SOCKET) {
+ gitno_close(t->socket);
+ t->socket = INVALID_SOCKET;
+ }
+
+ if (t->socket == INVALID_SOCKET) {
giterr_set(GITERR_NET, "Failed to connect to the host");
return -1;
}
- return error;
+ return 0;
}
/*
diff --git a/src/transports/http.c b/src/transports/http.c
index 1b2b5eb8..bc4a615f 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -85,12 +85,12 @@ static int gen_request(git_buf *buf, const char *url, const char *host, const ch
static int do_connect(transport_http *t, const char *host, const char *port)
{
- GIT_SOCKET s = -1;
+ GIT_SOCKET s;
if (t->parent.connected && http_should_keep_alive(&t->parser))
return 0;
- if ((s = gitno_connect(host, port)) < 0)
+ if (gitno_connect(&s, host, port) < 0)
return -1;
t->socket = s;