diff options
| author | Carlos Martín Nieto <carlos@cmartin.tk> | 2011-08-13 20:18:29 +0200 |
|---|---|---|
| committer | Vicent Marti <tanoku@gmail.com> | 2011-08-18 02:34:10 +0200 |
| commit | 7adba5f49c5520f591c4e6519c5bea770a3e4b5d (patch) | |
| tree | 4a5f4a077c420faadbf24a9d9388393087286177 /src | |
| parent | 427ca3d3c5b415c3970759b9334425707497fdf4 (diff) | |
| download | libgit2-7adba5f49c5520f591c4e6519c5bea770a3e4b5d.tar.gz | |
Keep sending want lines if the server doesn't anwer a flush
Some servers take a long time to answer and expect us to keep sending
want lines; otherwise they close the connection. Avoid this by waiting
for one second for the server to answer. If the timeout runs out,
treat is as a NAK and keep sending want lines.
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Diffstat (limited to 'src')
| -rw-r--r-- | src/transport_git.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/transport_git.c b/src/transport_git.c index 0e50a087a..88ad7a901 100644 --- a/src/transport_git.c +++ b/src/transport_git.c @@ -23,6 +23,8 @@ * Boston, MA 02110-1301, USA. */ +#include <sys/select.h> + #include "git2/net.h" #include "git2/common.h" #include "git2/types.h" @@ -388,6 +390,27 @@ static int git_negotiate_fetch(git_transport *transport, git_repository *repo, g git_pkt *pkt; git_pkt_send_flush(t->socket); while (1) { + fd_set fds; + struct timeval tv; + + FD_ZERO(&fds); + FD_SET(t->socket, &fds); + tv.tv_sec = 1; /* Wait for max. 1 second */ + tv.tv_usec = 0; + + /* The select(2) interface is silly */ + error = select(t->socket + 1, &fds, NULL, NULL, &tv); + if (error < GIT_SUCCESS) { + error = git__throw(GIT_EOSERR, "Error in select"); + } else if (error == 0) { + /* + * Some servers don't respond immediately, so if this + * happens, we keep sending information until it + * answers. + */ + break; + } + error = gitno_recv(&buf); if (error < GIT_SUCCESS) { error = git__rethrow(error, "Error receiving data"); |
