PERFORCE change 82857 for review

soc-bushman soc-bushman at FreeBSD.org
Tue Aug 30 17:38:41 GMT 2005


http://perforce.freebsd.org/chv.cgi?CH=82857

Change 82857 by soc-bushman at soc-bushman_stinger on 2005/08/30 17:37:48

	final release, I hope

Affected files ...

.. //depot/projects/soc2005/nsswitch_cached/patches/nsswitch_cached.diff#1 add
.. //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/Makefile#2 edit
.. //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/Makefile#4 edit
.. //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/cached.8#4 edit
.. //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/cached.c#4 edit
.. //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/cached.conf#5 edit
.. //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/cached.conf.5#4 edit
.. //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/config.c#4 edit
.. //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/config.h#4 edit
.. //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/mp_rs_query.c#4 edit
.. //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/mp_rs_query.h#4 edit
.. //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/mp_ws_query.c#4 edit
.. //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/mp_ws_query.h#4 edit
.. //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/query.c#4 edit
.. //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/query.h#4 edit
.. //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/samples/Makefile#2 delete
.. //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/samples/cached.conf.sample#2 delete
.. //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/startup/cached#1 add
.. //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/startup/cached.sh#2 delete
.. //depot/projects/soc2005/nsswitch_cached/src/lib/libc/net/name6.c#4 edit
.. //depot/projects/soc2005/nsswitch_cached/src/lib/libc/rpc/getrpcent.c#7 edit
.. //depot/projects/soc2005/nsswitch_cached/tests/nsdispatch_test/Makefile#5 edit
.. //depot/projects/soc2005/nsswitch_cached/tests/nsdispatch_test/nscache.c#6 edit
.. //depot/projects/soc2005/nsswitch_cached/tests/nsdispatch_test/nsdispatch.c#5 edit
.. //depot/projects/soc2005/nsswitch_cached/tests/nsdispatch_test/nsdispatch_test.c#6 edit

Differences ...

==== //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/Makefile#2 (text+ko) ====

@@ -1,4 +1,4 @@
 # $FreeBSD$
-SUBDIR+="test" "cachelib" "bin" "samples"
+SUBDIR+="test" "cachelib" "bin" 
 
 .include <bsd.subdir.mk>

==== //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/Makefile#4 (text+ko) ====

@@ -4,27 +4,21 @@
 PROGNAME=cached
 MAN=cached.conf.5 cached.8
 
-PREFIX?=/usr/local
-BINDIR?=${PREFIX}/sbin
-MANDIR?=${PREFIX}/man/man
-
 WARNS?=2
 SRCS=cached.c debug.c log.c config.c query.c mp_ws_query.c mp_rs_query.c\
 	singletons.c protocol.c parser.c
 CFLAGS+= -I${.CURDIR}/../ -DCONFIG_PATH="\"${PREFIX}/etc/cached.conf\""
 DPADD+=${LIBM} ${LIBPTHREAD}
-LDADD+=${.CURDIR}/../cachelib/libcachelib.a -lm -lpthread
+LDADD+=${.OBJDIR}/../cachelib/libcachelib.a -lm -lpthread
 
-FILESGROUPS=STARTUP
+FILESGROUPS=STARTUP CONF
 
 STARTUPDIR?=${PREFIX}/etc/rc.d
 STARTUPMODE=${BINMODE}
-STARTUP+=${.CURDIR}/../startup/cached.sh
+STARTUP+=${.CURDIR}/../startup/cached
 
-REINPLACE_CMD?=/usr/bin/sed -i.bak -e
-
-afterinstall:
-	${REINPLACE_CMD} 's!#cached_bindir#!${BINDIR}!g'\
-		${PREFIX}/etc/rc.d/cached.sh
+CONFDIR=${PREFIX}/etc
+CONFMODE=${SHAREMODE}
+CONF+=${.CURDIR}/cached.conf
 
 .include <bsd.prog.mk>

==== //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/cached.8#4 (text+ko) ====

@@ -39,6 +39,8 @@
 with 
 .Pa nsswitch
 subsystem. 
+The cache is actually per-user. It means that each user can work only with the
+cached data, that were cached by him and can't poison the cache of other users.
 .Nm
 supports 2 types of caching:
 .Bl -tag -width Pair

==== //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/cached.c#4 (text+ko) ====

@@ -61,7 +61,7 @@
 
 static struct timeval	s_time;
 static pthread_rwlock_t	s_time_lock = PTHREAD_RWLOCK_INITIALIZER;
-static pthread_t		s_time_thread;
+static pthread_t s_time_thread;
 
 static void accept_connection(struct kevent *, struct runtime_env *, 
 	struct configuration *);
@@ -170,7 +170,12 @@
 	size = configuration_get_entries_size(config);
 	for (i = 0; i < size; ++i) {
 		config_entry = configuration_get_entry(config, i);
-		register_cache_entry(retval, config_entry->c_params);
+	    	/* 
+	    	 * we should register common entries now - multipart entries
+	    	 * would be registered automatically during the queries
+	    	 */
+	    	if (config_entry->c_params->entry_type == CET_COMMON)
+			register_cache_entry(retval, config_entry->c_params);		
 	}
 	
 	TRACE_OUT(init_cache_);
@@ -346,7 +351,8 @@
 					if (qstate->io_buffer_p == 
 					    	qstate->io_buffer + 
 						qstate->io_buffer_size) {
-						qstate->io_buffer_p = qstate->io_buffer;
+						qstate->io_buffer_p = 
+						    qstate->io_buffer;
 						qstate->use_alternate_io = 0;
 					}
 				}				
@@ -552,17 +558,17 @@
 int 
 main(int argc, char *argv[])
 {
-	char const	*config_file;
-	char const	*error_str;
-	int			error_line;
-	int			i, res;
+	char const *config_file;
+	char const *error_str;
+	int error_line;
+	int i, res;
 	
-	int			trace_mode_enabled;
-	int			force_single_threaded;
-	int			do_not_daemonize;
+	int trace_mode_enabled;
+	int force_single_threaded;
+	int do_not_daemonize;
 	
-	struct processing_thread_args	*thread_args;
-	pthread_t	*threads;
+	struct processing_thread_args *thread_args;
+	pthread_t *threads;
 	
 	/* by default all debug messages are omitted */	
 	TRACE_OFF();	
@@ -597,7 +603,7 @@
 		
 	/* daemonization */
 	if (do_not_daemonize == 0) {
-		res = daemon(1, trace_mode_enabled == 0 ? 0 : 1);
+		res = daemon(0, trace_mode_enabled == 0 ? 0 : 1);
 		if (res != 0) {
 			LOG_ERR_1("main", "can't daemonize myself: %s", 
 		    		strerror(errno));
@@ -633,8 +639,8 @@
 		LOG_ERR_1("main", "error in configuration file(%s, %d): %s\n", 
 			config_file, error_line, error_str);
 		} else {
-		LOG_ERR_1("main", 
-			"no configuration file found - was looking for %s and %s",
+		LOG_ERR_1("main", "no configuration file found "
+		    	"- was looking for %s and %s",
 			CONFIG_PATH, DEFAULT_CONFIG_PATH);
 		}
 		destroy_configuration(s_configuration);

==== //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/cached.conf#5 (text+ko) ====

@@ -6,26 +6,28 @@
 	type = common
 	policy = lru
 	max_lifetime = 43200
-	max_elemsize = 1000
+	max_elemsize = 10000
 }
 
 entry "passwd" {
 	type = common
 	policy = lru
 	max_lifetime = 43200
-	max_elemsize = 1000
+	max_elemsize = 10000
 	euid = 0
 }
 
 entry "passwd_mp" {
 	type = multipart
 	max_lifetime = 43200
+	max_elemsize = 5000
 	timeout = 60
 }
 
 entry "passwd_mp" {
 	type = multipart
 	max_lifetime = 43200
+	max_elemsize = 5000
 	timeout = 60
 	euid = 0
 }
@@ -34,26 +36,28 @@
 	type = common
 	policy = lru
 	max_lifetime = 43200
-	max_elemsize = 1000
+	max_elemsize = 10000
 }
 
 entry "group" {
 	type = common
 	policy = lru
 	max_lifetime = 43200
-	max_elemsize = 1000
+	max_elemsize = 10000
 	euid = 0
 }
 
 entry "group_mp" {
 	type = multipart
 	max_lifetime = 43200
+	max_elemsize = 5000
 	timeout = 60
 }
 
 entry "group_mp" {
 	type = multipart
 	max_lifetime = 43200
+	max_elemsize = 5000
 	timeout = 60
 	euid = 0
 }
@@ -62,26 +66,28 @@
 	type = common
 	policy = lru
 	max_lifetime = 43200
-	max_elemsize = 1000
+	max_elemsize = 10000
 }
 
 entry "services" {
 	type = common
 	policy = lru
 	max_lifetime = 43200
-	max_elemsize = 1000
+	max_elemsize = 10000
 	euid = 0
 }
 
 entry "services_mp" {
 	type = multipart
 	max_lifetime = 43200
+	max_elemsize = 5000
 	timeout = 60
 }
 
 entry "services_mp" {
 	type = multipart
 	max_lifetime = 43200
+	max_elemsize = 5000
 	timeout = 60
 	euid = 0
 }
@@ -90,26 +96,28 @@
 	type = common
 	policy = lru
 	max_lifetime = 43200
-	max_elemsize = 1000
+	max_elemsize = 10000
 }
 
 entry "protocols" {
 	type = common
 	policy = lru
 	max_lifetime = 43200
-	max_elemsize = 1000
+	max_elemsize = 10000
 	euid = 0
 }
 
 entry "protocols_mp" {
 	type = multipart
 	max_lifetime = 43200
+	max_elemsize = 5000
 	timeout = 60
 }
 
 entry "protocols_mp" {
 	type = multipart
 	max_lifetime = 43200
+	max_elemsize = 5000
 	timeout = 60
 	euid = 0
 }
@@ -118,26 +126,28 @@
 	type = common
 	policy = lru
 	max_lifetime = 43200
-	max_elemsize = 1000
+	max_elemsize = 10000
 }
 
 entry "rpc" {
 	type = common
 	policy = lru
 	max_lifetime = 43200
-	max_elemsize = 1000
+	max_elemsize = 10000
 	euid = 0
 }
 
 entry "rpc_mp" {
 	type = multipart
 	max_lifetime = 43200
+	max_elemsize = 5000
 	timeout = 60
 }
 
 entry "rpc_mp" {
 	type = multipart
 	max_lifetime = 43200
+	max_elemsize = 5000
 	timeout = 60
 	euid = 0
 }
@@ -146,13 +156,13 @@
 	type = common
 	policy = lru
 	max_lifetime = 43200
-	max_elemsize = 1000
+	max_elemsize = 10000
 }
 
 entry "hosts" {
 	type = common
 	policy = lru
 	max_lifetime = 43200
-	max_elemsize = 1000
+	max_elemsize = 10000
 	euid = 0
 }

==== //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/cached.conf.5#4 (text+ko) ====


==== //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/config.c#4 (text+ko) ====

@@ -522,6 +522,30 @@
 }
 
 void
+configuration_lock_rdlock(struct configuration *config)
+{
+    TRACE_IN(configuration_lock_rdlock);
+    pthread_rwlock_rdlock(&config->rwlock);
+    TRACE_OUT(configuration_lock_rdlock);
+}
+
+void
+configuration_lock_wrlock(struct configuration *config)
+{
+    TRACE_IN(configuration_lock_wrlock);
+    pthread_rwlock_wrlock(&config->rwlock);
+    TRACE_OUT(configuration_lock_wrlock);
+}
+
+void 
+configuration_unlock(struct configuration *config)
+{
+    TRACE_IN(configuration_unlock);
+    pthread_rwlock_unlock(&config->rwlock);
+    TRACE_OUT(configuration_unlock);
+}
+
+void
 configuration_lock_entry(struct configuration_entry *entry)
 {
 	TRACE_IN(configuration_lock_entry);
@@ -542,7 +566,7 @@
 struct configuration *
 init_configuration(void)
 {
-	struct configuration	*retval;
+	struct configuration	*retval;	   
 		
 	TRACE_IN(init_configuration);
 	retval = (struct configuration *)malloc(sizeof(struct configuration));
@@ -555,7 +579,9 @@
 		retval->entries_capacity);
 	assert(retval->entries != NULL);
 	memset(retval->entries, 0, sizeof(struct configuration_entry *) *
-		retval->entries_capacity);		
+		retval->entries_capacity);
+
+	pthread_rwlock_init(&retval->rwlock, NULL);
 	
 	TRACE_OUT(init_configuration);	
 	return (retval);
@@ -666,6 +692,7 @@
 		destroy_configuration_entry(config->entries[i]);
 	free(config->entries);
 	
+	pthread_rwlock_destroy(&config->rwlock);
 	free(config);
 	TRACE_OUT(destroy_configuration);
 }

==== //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/config.h#4 (text+ko) ====

@@ -55,12 +55,13 @@
 	size_t	entries_capacity;
 	size_t	entries_size;
 
+	pthread_rwlock_t rwlock;
+
 	mode_t	socket_mode;
 	int	force_unlink;	
 	int	query_timeout;
 
 	int	threads_num;	
-	
 };
 
 extern struct configuration *init_configuration(void);
@@ -74,7 +75,11 @@
 	struct configuration *, size_t);
 extern struct configuration_entry *configuration_find_entry(
 	struct configuration *, struct configuration_entry const *);
-		
+	    
+extern void configuration_lock_rdlock(struct configuration *config);
+extern void configuration_lock_wrlock(struct configuration *config);
+extern void configuration_unlock(struct configuration *config);
+	
 extern void configuration_lock_entry(struct configuration_entry *);
 extern void configuration_unlock_entry(struct configuration_entry *);
 

==== //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/mp_rs_query.c#4 (text+ko) ====

@@ -32,6 +32,7 @@
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
+#include <stdio.h>
 
 #include <cachelib/include/cachelib.h>
 #include "config.h"
@@ -140,6 +141,7 @@
 	struct cache_mp_read_session_response	*c_mp_rs_response;
 	cache_mp_read_session	rs;
 	cache_entry	c_entry;
+	char	*dec_cache_entry_name;
 	
 	TRACE_IN(on_mp_read_session_request_process);
 	init_comm_element(&qstate->response, CET_MP_READ_SESSION_RESPONSE);
@@ -156,8 +158,15 @@
 		return (-1);
 	}
 
-	c_entry = find_cache_entry_by_config_entry(s_cache, 
-		qstate->config_entry);	
+	asprintf(&dec_cache_entry_name, "%s%s", qstate->euid_str,
+		qstate->config_entry->c_params->entry_name);
+	assert(dec_cache_entry_name != NULL);	
+	
+	configuration_lock_rdlock(s_configuration);
+	c_entry = find_cache_entry(s_cache, dec_cache_entry_name);
+	configuration_unlock(s_configuration);
+	free(dec_cache_entry_name);
+	
 	if (c_entry != INVALID_CACHE_ENTRY) {
 		configuration_lock_entry(qstate->config_entry);
 		rs = open_cache_mp_read_session(c_entry);

==== //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/mp_rs_query.h#4 (text+ko) ====


==== //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/mp_ws_query.c#4 (text+ko) ====

@@ -32,6 +32,7 @@
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
+#include <stdio.h>
 
 #include <cachelib/include/cachelib.h>
 #include "config.h"
@@ -143,6 +144,7 @@
 	struct cache_mp_write_session_response	*c_mp_ws_response;
 	cache_mp_write_session	ws;
 	cache_entry	c_entry;
+	char	*dec_cache_entry_name, *en_bkp;
 	
 	TRACE_IN(on_mp_write_session_request_process);
 	init_comm_element(&qstate->response, CET_MP_WRITE_SESSION_RESPONSE);
@@ -159,26 +161,48 @@
 		return (-1);
 	}
 
-	c_entry = find_cache_entry_by_config_entry(s_cache, 
-		qstate->config_entry);
-	if (c_entry != INVALID_CACHE_ENTRY) {
-		configuration_lock_entry(qstate->config_entry);
-		ws = open_cache_mp_write_session(c_entry);
-		if (ws == INVALID_CACHE_MP_WRITE_SESSION)
-			c_mp_ws_response->error_code = -1;
-		else {
-			qstate->mdata = ws;	
-			qstate->destroy_func = on_mp_write_session_destroy;			
+	asprintf(&dec_cache_entry_name, "%s%s", qstate->euid_str,
+		qstate->config_entry->c_params->entry_name);
+	assert(dec_cache_entry_name != NULL);	
+	
+	configuration_lock_rdlock(s_configuration);
+	c_entry = find_cache_entry(s_cache, 
+		dec_cache_entry_name);
+	configuration_unlock(s_configuration);
+	if (c_entry == INVALID_CACHE_ENTRY) {
+		configuration_lock_wrlock(s_configuration);
+	    	configuration_lock_entry(qstate->config_entry);
+	    	en_bkp = qstate->config_entry->c_params->entry_name;
+	    	qstate->config_entry->c_params->entry_name = 
+	    		dec_cache_entry_name;
+	    	register_cache_entry(s_cache, qstate->config_entry->c_params);
+		qstate->config_entry->c_params->entry_name = en_bkp;	    
+	    	configuration_unlock_entry(qstate->config_entry);
+	    	configuration_unlock(s_configuration);
+		
+	    	configuration_lock_rdlock(s_configuration);
+		c_entry = find_cache_entry(s_cache, 
+			dec_cache_entry_name);
+		configuration_unlock(s_configuration);
+	}
+	free(dec_cache_entry_name);
+
+	assert(c_entry != NULL);
+	configuration_lock_entry(qstate->config_entry);
+	ws = open_cache_mp_write_session(c_entry);
+	if (ws == INVALID_CACHE_MP_WRITE_SESSION)
+		c_mp_ws_response->error_code = -1;
+	else {
+		qstate->mdata = ws;	
+		qstate->destroy_func = on_mp_write_session_destroy;			
 			
-			if ((qstate->config_entry->query_timeout.tv_sec != 0) || 
-			    (qstate->config_entry->query_timeout.tv_usec != 0))
-				memcpy(&qstate->timeout, 
-					&qstate->config_entry->query_timeout, 
-					sizeof(struct timeval));
-		}
-		configuration_unlock_entry(qstate->config_entry);
-	} else
-		c_mp_ws_response->error_code = -1;
+		if ((qstate->config_entry->query_timeout.tv_sec != 0) || 
+		    (qstate->config_entry->query_timeout.tv_usec != 0))
+			memcpy(&qstate->timeout, 
+				&qstate->config_entry->query_timeout, 
+				sizeof(struct timeval));
+	}
+	configuration_unlock_entry(qstate->config_entry);
 
 	qstate->process_func = on_mp_write_session_response_write1;
 	qstate->kevent_watermark = sizeof(int);

==== //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/mp_ws_query.h#4 (text+ko) ====


==== //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/query.c#4 (text+ko) ====

@@ -67,7 +67,7 @@
 {
 	struct msghdr	cred_hdr;
 	struct iovec	iov;
-	int				elem_type;
+	int	elem_type;
 
 	struct {
 		struct cmsghdr	hdr;
@@ -104,6 +104,12 @@
 	qstate->euid = cmsg.creds.cmcred_euid;
 	qstate->pid = cmsg.creds.cmcred_pid;
 	
+	if (asprintf(&qstate->euid_str, "%d_", qstate->euid) == -1) {
+	    TRACE_OUT(on_query_startup);
+	    return (-1);
+	}
+	qstate->euid_str_length = strlen(qstate->euid_str);
+	
 	TRACE_INT(qstate->uid);
 	TRACE_INT(qstate->euid);
 	TRACE_INT(qstate->pid);
@@ -218,9 +224,12 @@
 		memset(write_request->entry, 0, write_request->entry_length + 1);
 		
 		write_request->cache_key = (char *)malloc(
-			write_request->cache_key_length + 1);
+			write_request->cache_key_length + 
+			qstate->euid_str_length + 1);
 		assert(write_request->cache_key != NULL);
-		memset(write_request->cache_key, 0, 
+		memcpy(write_request->cache_key, qstate->euid_str, 
+			qstate->euid_str_length);
+		memset(write_request->cache_key + qstate->euid_str_length, 0, 
 			write_request->cache_key_length + 1);
 		
 		write_request->data = (char *)malloc(write_request->data_size);
@@ -248,8 +257,8 @@
 	
 	result = qstate->read_func(qstate, write_request->entry, 
 		write_request->entry_length);
-	result += qstate->read_func(qstate, write_request->cache_key, 
-		write_request->cache_key_length);
+	result += qstate->read_func(qstate, write_request->cache_key + 
+		qstate->euid_str_length, write_request->cache_key_length);
 	result += qstate->read_func(qstate, write_request->data, 
 		write_request->data_size);
 	
@@ -292,8 +301,10 @@
 		return (-1);
 	}
 
-	c_entry = find_cache_entry_by_config_entry(s_cache, 
-		qstate->config_entry);	
+	configuration_lock_rdlock(s_configuration);
+	c_entry = find_cache_entry(s_cache, 
+    		qstate->config_entry->c_params->entry_name);	
+	configuration_unlock(s_configuration);
 	if (c_entry != NULL) {
 		TRACE_STR(write_request->cache_key);
 		configuration_lock_entry(qstate->config_entry);
@@ -380,13 +391,16 @@
 			read_request->entry_length + 1);
 		assert(read_request->entry != NULL);
 		memset(read_request->entry, 0, read_request->entry_length + 1);
-		
+				
 		read_request->cache_key = (char *)malloc(
-			read_request->cache_key_length + 1);
+			read_request->cache_key_length + 
+			qstate->euid_str_length + 1);
 		assert(read_request->cache_key != NULL);
-		memset(read_request->cache_key, 0,
+		memcpy(read_request->cache_key, qstate->euid_str, 
+			qstate->euid_str_length);
+		memset(read_request->cache_key + qstate->euid_str_length, 0, 
 			read_request->cache_key_length + 1);
-		
+
 		qstate->kevent_watermark = read_request->entry_length + 
 			read_request->cache_key_length;
 		qstate->process_func = on_read_request_read2;
@@ -407,7 +421,8 @@
 
 	result = qstate->read_func(qstate, read_request->entry, 
 		read_request->entry_length);
-	result += qstate->read_func(qstate, read_request->cache_key, 
+	result += qstate->read_func(qstate, 
+		read_request->cache_key + qstate->euid_str_length,
 		read_request->cache_key_length);
 	
 	if (result != qstate->kevent_watermark) {
@@ -449,8 +464,10 @@
 		return (-1);
 	}
 
-	c_entry = find_cache_entry_by_config_entry(s_cache, 
-		qstate->config_entry);	
+	configuration_lock_rdlock(s_configuration);
+	c_entry = find_cache_entry(s_cache, 
+    		qstate->config_entry->c_params->entry_name);	
+	configuration_unlock(s_configuration);
 	if (c_entry != NULL) {
 		TRACE_POINT();
 		TRACE_STR(read_request->cache_key);
@@ -594,18 +611,6 @@
 	return (config_lookup_result);	
 }
 
-cache_entry
-find_cache_entry_by_config_entry(cache the_cache, 
-	struct configuration_entry *config_entry)
-{
-	cache_entry	c_entry;
-	TRACE_IN(find_cache_entry_by_config_entry);
-	c_entry = find_cache_entry(the_cache, 
-    		config_entry->c_params->entry_name);
-	TRACE_OUT(finc_cache_entry_by_config_entry);
-	return (c_entry);
-}
-
 ssize_t 
 query_io_buffer_read(struct query_state *qstate, void *buf, size_t nbytes)
 {
@@ -738,7 +743,10 @@
 void	
 destroy_query_state(struct query_state *qstate)
 {
-	TRACE_IN(destroy_query_state);	
+	TRACE_IN(destroy_query_state);
+	if (qstate->euid_str != NULL)
+	    free(qstate->euid_str);
+    
 	if (qstate->io_buffer != NULL)
 		free(qstate->io_buffer);
 	

==== //depot/projects/soc2005/nsswitch_cached/release/cached-0.1/bin/query.h#4 (text+ko) ====

@@ -64,7 +64,10 @@
 	query_write_func write_func;		/* data write function */
 	query_read_func read_func;		/* data read function */
 
-	uid_t	euid;	/* euid of the caller, recevied via credentials */
+	char	*euid_str;	/* string version of the euid */
+	size_t	euid_str_length;
+	
+	uid_t	euid;	/* euid of the caller, recevied via credentials */	
 	uid_t	uid;	/* uid of the caller, recevied via credentials */
 	pid_t	pid;	/* pid of the caller, recevied via credentials */
 
@@ -93,7 +96,5 @@
 	
 extern struct configuration_entry *find_config_entry_by_name_and_euid(
 	struct configuration *, char *, uid_t);
-extern cache_entry find_cache_entry_by_config_entry(cache, 
-	struct configuration_entry *);
 
 #endif

==== //depot/projects/soc2005/nsswitch_cached/src/lib/libc/net/name6.c#4 (text+ko) ====

@@ -594,7 +594,7 @@
 #ifdef ICMPNL
 		{ NSSRC_ICMP, _icmp_ghbyaddr, NULL },
 #endif
-#ifdef
+#ifdef NS_CACHING
 		NS_CACHE_CB(&cache_info)
 #endif
 		{ 0 }

==== //depot/projects/soc2005/nsswitch_cached/src/lib/libc/rpc/getrpcent.c#7 (text+ko) ====

@@ -524,7 +524,7 @@
 		}
 				
 		/*
-		 * rpcent_unpack expects lines terminated with \n -- make it happy */
+		 * rpcent_unpack expects lines terminated with \n -- make it happy
 		 */
 		memcpy(buffer, resultbuf, resultbuflen);
 		buffer[resultbuflen] = '\n';

==== //depot/projects/soc2005/nsswitch_cached/tests/nsdispatch_test/Makefile#5 (text+ko) ====

@@ -4,7 +4,10 @@
 PROGNAME=nsdispatch_test
 MAN=
 
-SRCS=nsdispatch_test.c nsdispatch.c getservent.c nscache.c nscachedcli.c getrpcent.c getprotoent.c getpwent.c getgrent.c name6.c gethostnamadr.c gethostbynis.c gethostbyht.c gethostbydns.c getaddrinfo.c
+SRCS=nsdispatch_test.c nsdispatch.c getservent.c nscache.c nscachedcli.c\
+getrpcent.c getprotoent.c getpwent.c getgrent.c 
+#gethostnamadr.c
+#gethostbynis.c gethostbyht.c gethostbydns.c getaddrinfo.c
 WARNS?=2
 LDADD+=${.CURDIR}/../common/libtest.a
 CFLAGS+= -DNS_CACHING

==== //depot/projects/soc2005/nsswitch_cached/tests/nsdispatch_test/nscache.c#6 (text+ko) ====


==== //depot/projects/soc2005/nsswitch_cached/tests/nsdispatch_test/nsdispatch.c#5 (text+ko) ====


==== //depot/projects/soc2005/nsswitch_cached/tests/nsdispatch_test/nsdispatch_test.c#6 (text+ko) ====

@@ -251,7 +251,7 @@
 	return T_PASSED;
 }
 
-#include <netdb.h>
+/*#include <netdb.h>
 int
 DECORATED(getaddrinfo)(const char *, const char *, const struct addrinfo *, struct addrinfo **);
 struct hostent *
@@ -359,7 +359,7 @@
      struct hostent *hp;
      char **p;
 
-     /* argv[1] can be a pointer to a hostname or literal IP address */
+     // argv[1] can be a pointer to a hostname or literal IP address 
      hp = DECORATED(getipnodebyname)(sname, AF_INET6, AI_ALL | AI_ADDRCONFIG |
         AI_V4MAPPED, &error_num);
      if (hp == NULL) {
@@ -397,7 +397,7 @@
 	test_getipnodebyname("rsu.ru");
 	
 	return T_PASSED;	
-}
+}*/
 
 int 
 main(int argc, char *argv[])
@@ -415,9 +415,9 @@
 	assert(tinfo != NULL);
 	__register_test_info(tsystem, tinfo);*/
 	
-/*	tinfo = __create_test_info("getpwnam_test", getpwnam_test, 1);
+	tinfo = __create_test_info("getpwnam_test", getpwnam_test, 1);
 	assert(tinfo != NULL);
-	__register_test_info(tsystem, tinfo);*/
+	__register_test_info(tsystem, tinfo);
 
 /*	tinfo = __create_test_info("getgrnam_test", getgrnam_test, 1);
 	assert(tinfo != NULL);	
@@ -431,9 +431,9 @@
 	assert(tinfo != NULL);	
 	__register_test_info(tsystem, tinfo);*/
 	
-	tinfo = __create_test_info("getipnodebyname_test", getipnodebyname_test, 1);
+/*	tinfo = __create_test_info("getipnodebyname_test", getipnodebyname_test, 1);
 	assert(tinfo != NULL);	
-	__register_test_info(tsystem, tinfo);	
+	__register_test_info(tsystem, tinfo);	*/
 	
 /*	tinfo = __create_test_info("getprotoent_test", getprotoent_test, 1);
 	assert(tinfo != NULL);


More information about the p4-projects mailing list