From defd84d0fb43a068d2b9ae88a103ffea266c8d95 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Fri, 3 Sep 2010 10:59:45 -0500 Subject: [PATCH] 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 --- src/venus/cacheout.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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; } -- 2.39.5