tag 359854 patch thanks It is looping with recv()=0, which means "the remote end has shut down". It is a special return value, and has to be handled as such. Attached is functional and mildly tested patch.
I also made some changes to fix some ugly stuff valgrind turned up. It still doesn't detect errors, but this didn't work before anyway. I would seriously reconsider maintenance of this package..trivially fixed valgrind warnings, saved files aren't correct, overwrites files which wget wouldn't, and improper use of recv. Alternatives: aria axel cget icecream The one thing it has going for it is that it is small, and if you wanted to make relatively heavy modifications, you could do so without much pain.
diff -Naur orig/aget-0.4/Aget.c aget-0.4/Aget.c --- orig/aget-0.4/Aget.c 2006-04-01 00:56:32.000000000 -0500 +++ aget-0.4/Aget.c 2006-04-01 01:32:29.000000000 -0500 @@ -47,7 +47,7 @@ if (!fsuggested) nthreads = ret; - wthread = (struct thread_data *)malloc(nthreads * sizeof(struct thread_data)); + wthread = (struct thread_data *)calloc(nthreads, sizeof(struct thread_data)); Log("Downloading %s (%.f bytes) from site %s(%s:%d). Number of Threads: %d", req->url, req->clength, req->host, req->ip, req->port, nthreads); @@ -81,7 +81,7 @@ soffset = calc_offset(req->clength, i, nthreads); foffset = calc_offset(req->clength, i + 1, nthreads); wthread[i].soffset = soffset; - wthread[i].foffset = (i == nthreads - 1 ? req->clength : foffset); + wthread[i].foffset = (i == nthreads - 1 ? 1+req->clength : foffset); wthread[i].sin.sin_family = AF_INET; wthread[i].sin.sin_addr.s_addr = inet_addr(req->ip); wthread[i].sin.sin_port = htons(req->port); diff -Naur orig/aget-0.4/Download.c aget-0.4/Download.c --- orig/aget-0.4/Download.c 2006-04-01 00:56:32.000000000 -0500 +++ aget-0.4/Download.c 2006-04-01 01:19:11.000000000 -0500 @@ -108,6 +108,10 @@ while (td->offset < foffset) { memset(rbuf, GETRECVSIZ, 0); dr = recv(sd, rbuf, GETRECVSIZ, 0); + if (dr<=0) { + break; + } + if ((td->offset + dr) > foffset) dw = pwrite(td->fd, rbuf, foffset - td->offset, td->offset); else diff -Naur orig/aget-0.4/Misc.c aget-0.4/Misc.c --- orig/aget-0.4/Misc.c 2006-04-01 00:56:32.000000000 -0500 +++ aget-0.4/Misc.c 2006-04-01 01:08:57.000000000 -0500 @@ -144,9 +144,9 @@ if ((size = strlen(str)) == 0) return; - p = (char *)calloc(size, sizeof(char)); + p = (char *)calloc(1+size, sizeof(char)); s = p; - for (i = size; i >= 0; i--, s++) + for (i = size; i > 0; i--, s++) *s = *(str + i - 1); *s = '\0'; memset(str, 0, size);