From: Andrew Deason Date: Fri, 3 Sep 2010 15:59:45 +0000 (-0500) Subject: cacheout: Improve error handling X-Git-Tag: openafs-devel-1_5_77~16 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=b030d05e0501790499d84d048f29549b9e0d1aa0;p=packages%2Fo%2Fopenafs.git cacheout: Improve error handling Bail out when we encounter errors in initialization. Among other things, this prevents a segfault if we can't read the client configuration. Change-Id: I8b35163c5c4750eb05539a225069327051a3f148 Reviewed-on: http://gerrit.openafs.org/2665 Tested-by: BuildBot Reviewed-by: Jeffrey Hutzelman Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear (cherry picked from commit defd84d0fb43a068d2b9ae88a103ffea266c8d95) Reviewed-on: http://gerrit.openafs.org/2697 --- diff --git a/src/venus/cacheout.c b/src/venus/cacheout.c index b84305204..5fbd058fc 100644 --- a/src/venus/cacheout.c +++ b/src/venus/cacheout.c @@ -252,19 +252,25 @@ MyBeforeProc(struct cmd_syndesc *as, void *arock) sprintf(confdir, "%s", AFSDIR_CLIENT_ETC_DIRPATH); /* setup to talk to servers */ code = rx_Init(0); - if (code) + if (code) { printf("Warning: could not initialize network communication.\n"); + return 1; + } junk = rxnull_NewClientSecurityObject(); tdir = afsconf_Open(confdir); - if (!tdir) + if (!tdir) { printf("Warning: could not get cell configuration.\n"); + return 1; + } if (as->parms[2].items) /* if -cell specified */ tcell = as->parms[2].items->data; code = afsconf_GetCellInfo(tdir, tcell, AFSCONF_VLDBSERVICE, &info); - if (info.numServers > MAXSERVERS) + if (code || info.numServers > MAXSERVERS) { printf("Warning: could not init cell info.\n"); + return 1; + } for (i = 0; i < info.numServers; ++i) serverconns[i] = @@ -275,8 +281,10 @@ MyBeforeProc(struct cmd_syndesc *as, void *arock) serverconns[i] = (struct rx_connection *)0; } code = ubik_ClientInit(serverconns, &client); - if (code) + if (code) { printf("Warning: could not initialize RPC interface.\n"); + return 1; + } return 0; }