From: megacz Date: Tue, 8 Apr 2008 20:08:20 +0000 (-0400) Subject: v1.05: fail-fast if network is likely to be down X-Git-Tag: 1.05 X-Git-Url: https://git.hcoop.net/hcoop/debian/libnss-afs.git/commitdiff_plain/43d1801e7ebb08fe927747e1de8eefa0ae294957 v1.05: fail-fast if network is likely to be down --- diff --git a/debian/changelog b/debian/changelog index 1e05f4c..f7a50d3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +libnss-afs (1.05) unstable; urgency=low + + * set rx_SetRxDeadTime to 5 seconds to avoid stalling forever + * deliberately fail all lookups if stat("/afs/$CELL/") does not succeed + so we don't delay bootup/shutdown when the network is unreachable. + + -- megacz Tue, 08 Apr 2008 15:59:23 -0400 + libnss-afs (1.04) unstable; urgency=medium * librx expects to be able to mutate the char*'s we pass it so strcpy() diff --git a/nss_afs.c b/nss_afs.c index 2d6eaf4..11d9fb3 100644 --- a/nss_afs.c +++ b/nss_afs.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -87,6 +88,7 @@ extern struct ubik_client *pruclient; int afs_initialized = 0; char cellname[MAXCELLNAMELEN]; char homedir_prefix[MAXPATHLEN]; +char cell_root[MAXPATHLEN]; int homedir_prefix_len=0; char homedirs_method=0; char shells_method=0; @@ -193,9 +195,14 @@ enum nss_status ptsname2id(char *name, uid_t* uid) { int init_afs() { FILE *thiscell; int len; + struct stat statbuf; - if (afs_initialized) return 0; - + if (afs_initialized) { + /* wait until /afs/@cell/ appears as a proxy for "the network is up" */ + if (stat(cell_root, &statbuf)) return -1; + return 0; + } + if (pthread_mutex_lock(&mutex)) return -1; do { homedirs_method=HOMEDIR_PREFIX; @@ -219,9 +226,17 @@ int init_afs() { if (cellname[len-1] == '\n') len--; cellname[len]='\0'; + + /* wait until /afs/@cell/ appears as a proxy for "the network is up" */ + sprintf(cell_root,"/afs/%s/",cellname); + if (stat(cell_root, &statbuf)) break; + sprintf(homedir_prefix,"/afs/%s/user/",cellname); homedir_prefix_len=strlen(homedir_prefix); - + + /* time out requests after 5 seconds to avoid hanging things */ + rx_SetRxDeadTime(5); + if (pr_Initialize(0L,AFSDIR_CLIENT_ETC_DIRPATH, 0)) break; afs_initialized = 1;