about summary refs log tree commit diff
path: root/nscd
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-11-10 07:54:40 +0000
committerUlrich Drepper <drepper@redhat.com>2004-11-10 07:54:40 +0000
commited2ced8ae324a8a89a76ff3fc3971226b0107d3e (patch)
tree73b9742b4eddf42b5b446289837132b62552befd /nscd
parent5429ff760a5544a34c5f05f16c01a7dffa505604 (diff)
downloadglibc-ed2ced8ae324a8a89a76ff3fc3971226b0107d3e.tar.gz
glibc-ed2ced8ae324a8a89a76ff3fc3971226b0107d3e.tar.xz
glibc-ed2ced8ae324a8a89a76ff3fc3971226b0107d3e.zip
2004-11-10  Jakub Jelinek  <jakub@redhat.com>

	* Makefile (tests): Add tst-exit3.
	* tst-exit3.c: New test.
Diffstat (limited to 'nscd')
-rw-r--r--nscd/nscd_getai.c14
-rw-r--r--nscd/nscd_getgr_r.c13
-rw-r--r--nscd/nscd_gethst_r.c15
-rw-r--r--nscd/nscd_initgroups.c13
4 files changed, 26 insertions, 29 deletions
diff --git a/nscd/nscd_getai.c b/nscd/nscd_getai.c
index 390b981f99..f0b2082baa 100644
--- a/nscd/nscd_getai.c
+++ b/nscd/nscd_getai.c
@@ -33,15 +33,8 @@
 extern int __nss_not_use_nscd_hosts;
 
 
-libc_locked_map_ptr (map_handle);
-/* Note that we only free the structure if necessary.  The memory
-   mapping is not removed since it is not visible to the malloc
-   handling.  */
-libc_freeres_fn (ai_map_free)
-{
-  if (map_handle.mapped != NO_MAPPING)
-    free (map_handle.mapped);
-}
+/* We use the mapping from nscd_gethst.  */
+libc_locked_map_ptr (extern, __hst_map_handle);
 
 
 int
@@ -53,7 +46,8 @@ __nscd_getai (const char *key, struct nscd_ai_result **result, int *h_errnop)
   /* If the mapping is available, try to search there instead of
      communicating with the nscd.  */
   struct mapped_database *mapped;
-  mapped = __nscd_get_map_ref (GETFDHST, "hosts", &map_handle, &gc_cycle);
+  mapped = __nscd_get_map_ref (GETFDHST, "hosts", &__hst_map_handle,
+			       &gc_cycle);
 
  retry:;
   const ai_response_header *ai_resp = NULL;
diff --git a/nscd/nscd_getgr_r.c b/nscd/nscd_getgr_r.c
index fc10d3ea60..282912db3e 100644
--- a/nscd/nscd_getgr_r.c
+++ b/nscd/nscd_getgr_r.c
@@ -67,14 +67,18 @@ __nscd_getgrgid_r (gid_t gid, struct group *resultbuf, char *buffer,
 }
 
 
-libc_locked_map_ptr (map_handle);
+libc_locked_map_ptr (,__gr_map_handle);
 /* Note that we only free the structure if necessary.  The memory
    mapping is not removed since it is not visible to the malloc
    handling.  */
 libc_freeres_fn (gr_map_free)
 {
-  if (map_handle.mapped != NO_MAPPING)
-    free (map_handle.mapped);
+  if (__gr_map_handle.mapped != NO_MAPPING)
+    {
+      void *p = __gr_map_handle.mapped;
+      __gr_map_handle.mapped = NO_MAPPING;
+      free (p);
+    }
 }
 
 
@@ -91,7 +95,8 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type,
   /* If the mapping is available, try to search there instead of
      communicating with the nscd.  */
   struct mapped_database *mapped = __nscd_get_map_ref (GETFDGR, "group",
-						       &map_handle, &gc_cycle);
+						       &__gr_map_handle,
+						       &gc_cycle);
  retry:;
   const gr_response_header *gr_resp = NULL;
   const char *gr_name = NULL;
diff --git a/nscd/nscd_gethst_r.c b/nscd/nscd_gethst_r.c
index 64d02fedc7..5d9d569107 100644
--- a/nscd/nscd_gethst_r.c
+++ b/nscd/nscd_gethst_r.c
@@ -87,14 +87,18 @@ __nscd_gethostbyaddr_r (const void *addr, socklen_t len, int type,
 }
 
 
-libc_locked_map_ptr (map_handle);
+libc_locked_map_ptr (, __hst_map_handle);
 /* Note that we only free the structure if necessary.  The memory
    mapping is not removed since it is not visible to the malloc
    handling.  */
-libc_freeres_fn (gr_map_free)
+libc_freeres_fn (hst_map_free)
 {
-  if (map_handle.mapped != NO_MAPPING)
-    free (map_handle.mapped);
+  if (__hst_map_handle.mapped != NO_MAPPING)
+    {
+      void *p = __hst_map_handle.mapped;
+      __hst_map_handle.mapped = NO_MAPPING;
+      free (p);
+    }
 }
 
 
@@ -110,7 +114,8 @@ nscd_gethst_r (const char *key, size_t keylen, request_type type,
   /* If the mapping is available, try to search there instead of
      communicating with the nscd.  */
   struct mapped_database *mapped;
-  mapped = __nscd_get_map_ref (GETFDHST, "hosts", &map_handle, &gc_cycle);
+  mapped = __nscd_get_map_ref (GETFDHST, "hosts", &__hst_map_handle,
+			       &gc_cycle);
 
  retry:;
   const hst_response_header *hst_resp = NULL;
diff --git a/nscd/nscd_initgroups.c b/nscd/nscd_initgroups.c
index ce44f654d7..2ea9e7f862 100644
--- a/nscd/nscd_initgroups.c
+++ b/nscd/nscd_initgroups.c
@@ -29,15 +29,8 @@
 #include "nscd_proto.h"
 
 
-libc_locked_map_ptr (map_handle);
-/* Note that we only free the structure if necessary.  The memory
-   mapping is not removed since it is not visible to the malloc
-   handling.  */
-libc_freeres_fn (gr_map_free)
-{
-  if (map_handle.mapped != NO_MAPPING)
-    free (map_handle.mapped);
-}
+/* We use the same mapping as in nscd_getgr.   */
+libc_locked_map_ptr (extern, __gr_map_handle);
 
 
 int
@@ -50,7 +43,7 @@ __nscd_getgrouplist (const char *user, gid_t group, long int *size,
   /* If the mapping is available, try to search there instead of
      communicating with the nscd.  */
   struct mapped_database *mapped;
-  mapped = __nscd_get_map_ref (GETFDGR, "group", &map_handle, &gc_cycle);
+  mapped = __nscd_get_map_ref (GETFDGR, "group", &__gr_map_handle, &gc_cycle);
 
  retry:;
   const initgr_response_header *initgr_resp = NULL;