* amd/nfs_subr.c (nfsproc_getattr_2_svc): initialize 'retry', just before-clocktime-fixes
authorErez Zadok <ezk@cs.sunysb.edu>
Thu, 15 Sep 2005 23:12:56 +0000 (23:12 +0000)
committerErez Zadok <ezk@cs.sunysb.edu>
Thu, 15 Sep 2005 23:12:56 +0000 (23:12 +0000)
in case.
(fh_to_mp3): increment amd_stats.d_stale counter only if we are
actually returning ESTALE.

* amd/info_exec.c (exec_parse_qanswer), amd/info_file.c
(file_search_or_reload), amd/info_hesiod.c (hesiod_search),
amd/info_ldap.c (amu_ldap_search), amd/info_ndbm.c (search_ndbm),
amd/info_nis.c (nis_search), amd/info_nisplus.c (nisplus_search,
nisplus_search): don't dereference mnt_map->cfm which may be null
if we're not using an amd.conf file.

* libamu/xutil.c (unregister_amq): if failed to de-register Amd
from portmapper, report it under dlog (debugging), not as an
annoying plog that always shows up.

ChangeLog
amd/amfs_generic.c
amd/info_exec.c
amd/info_file.c
amd/info_hesiod.c
amd/info_ldap.c
amd/info_ndbm.c
amd/info_nis.c
amd/info_nisplus.c
amd/nfs_subr.c
libamu/xutil.c

index c4f89771f6517f4e37d2c0304ea83089b7749df2..0cdbc26c34cc192e50b739d19ca53cbc6e5d36fd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2005-09-15  Erez Zadok  <ezk@cs.sunysb.edu>
+
+       * amd/nfs_subr.c (nfsproc_getattr_2_svc): initialize 'retry', just
+       in case.
+       (fh_to_mp3): increment amd_stats.d_stale counter only if we are
+       actually returning ESTALE.
+
+       * amd/info_exec.c (exec_parse_qanswer), amd/info_file.c
+       (file_search_or_reload), amd/info_hesiod.c (hesiod_search),
+       amd/info_ldap.c (amu_ldap_search), amd/info_ndbm.c (search_ndbm),
+       amd/info_nis.c (nis_search), amd/info_nisplus.c (nisplus_search,
+       nisplus_search): don't dereference mnt_map->cfm which may be null
+       if we're not using an amd.conf file.
+
+2005-09-14  Erez Zadok  <ezk@cs.sunysb.edu>
+
+       * libamu/xutil.c (unregister_amq): if failed to de-register Amd
+       from portmapper, report it under dlog (debugging), not as an
+       annoying plog that always shows up.
+
 2005-09-13  Erez Zadok  <ezk@cs.sunysb.edu>
 
        * mk-amd-map/mk-amd-map.c (read_file_file), libamu/util.c
index 09e8d4ec814a127d272526dda479041d5f7f9b09..8aa47a38d253b0bbec8ba711ccafe8b8304ebe05 100644 (file)
@@ -240,7 +240,7 @@ amfs_lookup_node(am_node *mp, char *fname, int *error_return)
    */
   new_mp = get_ap_child(mp, expanded_fname);
   XFREE(expanded_fname);
-  if (new_mp == 0)
+  if (new_mp == NULL)
     ereturn(ENOSPC);
 
   *error_return = -1;
index 9e0894362fe9f1a2811801eb79a6feaca76cc358..cebd91d949dcddca163628801ab34a653c476187 100644 (file)
@@ -207,7 +207,7 @@ exec_parse_qanswer(mnt_map *m, int fd, char *map, char *key, char **pval, time_t
     /*
      * Return a copy of the data
      */
-    if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)
+    if (m->cfm && (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX))
       dc = sun_entry2amd(key, cp);
     else
       dc = strdup(cp);
index 1af24156fb12f2823fbb1fb975e7eefbf551c315..db0192408a83df6bcad23f35627355c099c99233 100644 (file)
@@ -160,7 +160,8 @@ file_search_or_reload(mnt_map *m,
         * Return a copy of the data
         */
        char *dc;
-       if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)
+       /* if m->cfm == NULL, not using amd.conf file */
+       if (m->cfm && (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX))
          dc = sun_entry2amd(kp, cp);
        else
          dc = strdup(cp);
index 73ea04bff6cf8b4c87abde4428420149e652d17c..50c470d35abe9b50382028a84d1b5fa55602244f 100644 (file)
@@ -128,7 +128,7 @@ hesiod_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp)
    * it (and free subsequent replies)
    */
   if (rvec && *rvec) {
-    if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX) {
+    if (m->cfm && (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)) {
       *pval = sun_entry2amd(key, *rvec);
       XFREE(*rvec);
     } else
index 71fcfe42c3e8413c799c0820a0dca9cda8cc6cc8..376a04622298c07cbcb7c9a031022c2bd4766826 100644 (file)
@@ -528,7 +528,7 @@ amu_ldap_search(mnt_map *m, char *map, char *key, char **pval, time_t *ts)
   }
   dlog("Map %s, %s => %s\n", map, key, vals[0]);
   if (vals[0]) {
-    if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)
+    if (m->cfm && (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX))
       *pval = sun_entry2amd(key, vals[0]);
     else
       *pval = strdup(vals[0]);
index ebd0b9516461cb1cd0207886fa570723824c2dee..5eac3c89769eb630ef1a3df06d3cc6169e1f2edf 100644 (file)
@@ -67,7 +67,7 @@ search_ndbm(mnt_map *m, DBM *db, char *key, char **val)
   k.dsize = strlen(key) + 1;
   v = dbm_fetch(db, k);
   if (v.dptr) {
-    if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)
+    if (m->cfm && (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX))
       *val = sun_entry2amd(key, v.dptr);
     else
       *val = strdup(v.dptr);
index 131ca67ebac9c21d8909f7b0b98f555c1c1f9598..af17bab71fcffb8cfdd058a5380047ece70c4d06 100644 (file)
@@ -303,7 +303,7 @@ nis_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp)
    * Lookup key
    */
   res = yp_match(gopt.nis_domain, map, key, strlen(key), pval, &outlen);
-  if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX) {
+  if (m->cfm && (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)) {
     char *oldval = *pval;
     *pval = sun_entry2amd(key, oldval);
     XFREE(*pval);              /* yp_match malloc's *pval above */
index 107109f0fc2d58e796695af917df71da31eeefbb..4241f9a62c12939e4182ea185d3b712a9afbce45 100644 (file)
@@ -220,7 +220,7 @@ nisplus_search(mnt_map *m, char *map, char *key, char **val, time_t *tp)
        data.value = strnsave(ENTRY_VAL(value, 1), ENTRY_LEN(value, 1));
     }
 
-    if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX) {
+    if (m->cfm && (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)) {
       *val = sun_entry2amd(key, data.value);
       XFREE(data.value);       /* strnsave malloc'ed it above */
     } else
index b03173e424311a4445fcebe582cb7053debea4c2..099e0b945c1e2762540237eae1121fd1069dc27e 100644 (file)
@@ -99,7 +99,7 @@ do_readlink(am_node *mp, int *error_return)
   if (mp->am_mnt->mf_ops->readlink) {
     int retry = 0;
     mp = (*mp->am_mnt->mf_ops->readlink) (mp, &retry);
-    if (mp == 0) {
+    if (mp == NULL) {
       *error_return = retry;
       return 0;
     }
@@ -130,14 +130,14 @@ nfsproc_getattr_2_svc(am_nfs_fh *argp, struct svc_req *rqstp)
 {
   static nfsattrstat res;
   am_node *mp;
-  int retry;
+  int retry = 0;
   time_t now = clocktime();
 
   if (amuDebug(D_TRACE))
     plog(XLOG_DEBUG, "getattr:");
 
   mp = fh_to_mp3(argp, &retry, VLOOK_CREATE);
-  if (mp == 0) {
+  if (mp == NULL) {
     if (amuDebug(D_TRACE))
       plog(XLOG_DEBUG, "\tretry=%d", retry);
 
@@ -208,7 +208,7 @@ nfsproc_lookup_2_svc(nfsdiropargs *argp, struct svc_req *rqstp)
   sprintf(opt_gid, "%d", (int) gid);
 
   mp = fh_to_mp3(&argp->da_fhandle, &retry, VLOOK_CREATE);
-  if (mp == 0) {
+  if (mp == NULL) {
     if (retry < 0) {
       amd_stats.d_drops++;
       return 0;
@@ -300,7 +300,7 @@ nfsproc_readlink_2_svc(am_nfs_fh *argp, struct svc_req *rqstp)
     plog(XLOG_DEBUG, "readlink:");
 
   mp = fh_to_mp3(argp, &retry, VLOOK_CREATE);
-  if (mp == 0) {
+  if (mp == NULL) {
   readlink_retry:
     if (retry < 0) {
       amd_stats.d_drops++;
@@ -378,7 +378,7 @@ unlink_or_rmdir(nfsdiropargs *argp, struct svc_req *rqstp, int unlinkp)
   int retry;
 
   am_node *mp = fh_to_mp3(&argp->da_fhandle, &retry, VLOOK_DELETE);
-  if (mp == 0) {
+  if (mp == NULL) {
     if (retry < 0) {
       amd_stats.d_drops++;
       return 0;
@@ -396,7 +396,7 @@ unlink_or_rmdir(nfsdiropargs *argp, struct svc_req *rqstp, int unlinkp)
     plog(XLOG_DEBUG, "\tremove(%s, %s)", mp->am_path, argp->da_name);
 
   mp = mp->am_mnt->mf_ops->lookup_child(mp, argp->da_name, &retry, VLOOK_DELETE);
-  if (mp == 0) {
+  if (mp == NULL) {
     /*
      * Ignore retries...
      */
@@ -509,7 +509,7 @@ nfsproc_readdir_2_svc(nfsreaddirargs *argp, struct svc_req *rqstp)
     plog(XLOG_DEBUG, "readdir:");
 
   mp = fh_to_mp3(&argp->rda_fhandle, &retry, VLOOK_CREATE);
-  if (mp == 0) {
+  if (mp == NULL) {
     if (retry < 0) {
       amd_stats.d_drops++;
       return 0;
@@ -540,7 +540,7 @@ nfsproc_statfs_2_svc(am_nfs_fh *argp, struct svc_req *rqstp)
     plog(XLOG_DEBUG, "statfs:");
 
   mp = fh_to_mp3(argp, &retry, VLOOK_CREATE);
-  if (mp == 0) {
+  if (mp == NULL) {
     if (retry < 0) {
       amd_stats.d_drops++;
       return 0;
@@ -760,9 +760,10 @@ drop:
      */
     if (amd_state == Finishing)
       *rp = ENOENT;
-    else
+    else {
       *rp = ESTALE;
-    amd_stats.d_stale++;
+      amd_stats.d_stale++;
+    }
   }
 
   return ap;
index 524fe6bbe3fd5fc2feff000953c2e273539efc0a..eab3be44792b0fd179d96f06ec562fcbe83dbcaf 100644 (file)
@@ -861,7 +861,7 @@ unregister_amq(void)
     u_long amd_prognum = get_amd_program_number();
 
     if (pmap_unset(amd_prognum, AMQ_VERSION) == 1)
-      plog(XLOG_ERROR, "failed to de-register Amd program %lu, version %lu",
+      dlog("failed to de-register Amd program %lu, version %lu",
           amd_prognum, AMQ_VERSION);
   }
 }