From owner-svn-soc-all@FreeBSD.ORG Mon Aug 19 20:52:57 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 2EF2AF5F for ; Mon, 19 Aug 2013 20:52:57 +0000 (UTC) (envelope-from ambarisha@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 0231F282B for ; Mon, 19 Aug 2013 20:52:57 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7JKquIw034678 for ; Mon, 19 Aug 2013 20:52:56 GMT (envelope-from ambarisha@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r7JKqugJ034667 for svn-soc-all@FreeBSD.org; Mon, 19 Aug 2013 20:52:56 GMT (envelope-from ambarisha@FreeBSD.org) Date: Mon, 19 Aug 2013 20:52:56 GMT Message-Id: <201308192052.r7JKqugJ034667@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ambarisha@FreeBSD.org using -f From: ambarisha@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r256171 - in soc2013/ambarisha/head/usr.bin: dmget dms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Aug 2013 20:52:57 -0000 Author: ambarisha Date: Mon Aug 19 20:52:56 2013 New Revision: 256171 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256171 Log: Handling download failures (file not found, access denied etc.) with grace Modified: soc2013/ambarisha/head/usr.bin/dmget/dmget.c soc2013/ambarisha/head/usr.bin/dms/mirror.c soc2013/ambarisha/head/usr.bin/dms/worker.c Modified: soc2013/ambarisha/head/usr.bin/dmget/dmget.c ============================================================================== --- soc2013/ambarisha/head/usr.bin/dmget/dmget.c Mon Aug 19 20:51:29 2013 (r256170) +++ soc2013/ambarisha/head/usr.bin/dmget/dmget.c Mon Aug 19 20:52:56 2013 (r256171) @@ -423,6 +423,7 @@ rm_dmres(&dmres); goto success; } else { + fprintf(stderr, "dmget: download failed: %s\n", dmres->errstr); rm_dmres(&dmres); goto failure; } @@ -456,6 +457,7 @@ ret = -1; goto done; failure: + remove(dmreq.path); ret = 1; goto done; success: Modified: soc2013/ambarisha/head/usr.bin/dms/mirror.c ============================================================================== --- soc2013/ambarisha/head/usr.bin/dms/mirror.c Mon Aug 19 20:51:29 2013 (r256170) +++ soc2013/ambarisha/head/usr.bin/dms/mirror.c Mon Aug 19 20:52:56 2013 (r256171) @@ -203,7 +203,7 @@ return -1; } - while(mirror != NULL) { + while(mirrors != NULL) { write_mirror(mirror, f); mirrors = rm_mirror(mirrors, mirror); } Modified: soc2013/ambarisha/head/usr.bin/dms/worker.c ============================================================================== --- soc2013/ambarisha/head/usr.bin/dms/worker.c Mon Aug 19 20:51:29 2013 (r256170) +++ soc2013/ambarisha/head/usr.bin/dms/worker.c Mon Aug 19 20:52:56 2013 (r256171) @@ -753,10 +753,7 @@ tmpreq.path = (char *) malloc(strlen(dmreq->path) + strlen(TMP_EXT)); if (tmpreq.path == NULL) { fprintf(stderr, "dmXGet: Insufficient memory\n"); - free(tmpreq.i_filename); - free(tmpreq.path); - free(tmpreq.URL); - return NULL; + goto done; } strcpy(tmpreq.path, dmreq->path); strcat(tmpreq.path, TMP_EXT); @@ -764,11 +761,19 @@ tmpjob.ofd = open(tmpreq.path, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); FILE *f = fetchXGet(tmpjob.url, us, flags); + if (f == NULL) { + close(tmpjob.ofd); + remove(tmpreq.path); + fprintf(stderr, "dmXGet: Couldn't fetch remote file\n");//, fetchLastErrStr); + goto done; + } + fetch(&tmpjob, f, *us); fclose(f); f = fopen(tmpreq.path, "r"); +done: free(tmpjob.url->doc); free(tmpjob.url); free(tmpreq.i_filename);