Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Fix ssh support
Baptiste Daroussin committed 12 years ago
commit 8c2f1882e2ce704ca1b5729ba2903deb8b383f5e
parent fc5a3d3
2 files changed +22 -3
modified libpkg/fetch.c
@@ -32,6 +32,7 @@

#include <ctype.h>
#include <fcntl.h>
+
#include <errno.h>
#define _WITH_GETLINE
#include <stdio.h>
#include <string.h>
@@ -190,6 +191,7 @@ pkg_fetch_file_to_fd(struct pkg_repo *repo, const char *url, int dest, time_t *t

	int64_t max_retry, retry;
	int64_t fetch_timeout;
+
	int tmout;
	time_t begin_dl;
	time_t now;
	time_t last = 0;
@@ -316,14 +318,24 @@ pkg_fetch_file_to_fd(struct pkg_repo *repo, const char *url, int dest, time_t *t
	}

	begin_dl = time(NULL);
+
	tmout = fetch_timeout;
	while (done < sz) {
		if (kq == - 1) {
			if ((r = fread(buf, 1, sizeof(buf), remote)) < 1)
				break;
		} else {
-
			ts.tv_sec = fetch_timeout;
+
			ts.tv_sec = tmout;
			ts.tv_nsec = 0;
			if (kevent(kq, &e, 1, &ev, 1, &ts) == -1) {
+
				if (time(NULL) - now > fetch_timeout) {
+
					pkg_emit_error("Fetch timeout");
+
					retcode = EPKG_FATAL;
+
					goto cleanup;
+
				}
+
				if (errno == EINTR) {
+
					tmout = fetch_timeout - (time(NULL) - now);
+
					continue;
+
				}
				pkg_emit_errno("kevent", "ssh");
				retcode = EPKG_FATAL;
				goto cleanup;
modified pkg/progressmeter.c
@@ -263,6 +263,8 @@ update_progress_meter(__unused int ignore)
void
start_progress_meter(char *f, off_t filesize, off_t *ctr)
{
+
	struct sigaction sa;
+

	start = last_update = time(NULL);
	file = f;
	end_pos = filesize;
@@ -275,8 +277,13 @@ start_progress_meter(char *f, off_t filesize, off_t *ctr)
	if (can_output())
		refresh_progress_meter();

-
	signal(SIGALRM, update_progress_meter);
-
	signal(SIGWINCH, sig_winch);
+

+
	memset(&sa, 0, sizeof(sa));
+
	sa.sa_handler = update_progress_meter;
+
	sigemptyset(&sa.sa_mask);
+
	sigaction(SIGALRM, &sa, NULL);
+
	sa.sa_handler = sig_winch;
+
	sigaction(SIGWINCH, &sa, NULL);
	alarm(UPDATE_INTERVAL);
}