[Midnightbsd-cvs] src [10369] trunk/usr.sbin/nscd: sync with freebsd

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun Jun 3 19:13:44 EDT 2018


Revision: 10369
          http://svnweb.midnightbsd.org/src/?rev=10369
Author:   laffer1
Date:     2018-06-03 19:13:43 -0400 (Sun, 03 Jun 2018)
Log Message:
-----------
sync with freebsd

Modified Paths:
--------------
    trunk/usr.sbin/nscd/Makefile
    trunk/usr.sbin/nscd/agent.c
    trunk/usr.sbin/nscd/agent.h
    trunk/usr.sbin/nscd/agents/Makefile.inc
    trunk/usr.sbin/nscd/agents/group.c
    trunk/usr.sbin/nscd/agents/group.h
    trunk/usr.sbin/nscd/agents/passwd.c
    trunk/usr.sbin/nscd/agents/passwd.h
    trunk/usr.sbin/nscd/agents/services.c
    trunk/usr.sbin/nscd/agents/services.h
    trunk/usr.sbin/nscd/cachelib.c
    trunk/usr.sbin/nscd/cachelib.h
    trunk/usr.sbin/nscd/cacheplcs.c
    trunk/usr.sbin/nscd/cacheplcs.h
    trunk/usr.sbin/nscd/config.c
    trunk/usr.sbin/nscd/config.h
    trunk/usr.sbin/nscd/debug.c
    trunk/usr.sbin/nscd/debug.h
    trunk/usr.sbin/nscd/hashtable.h
    trunk/usr.sbin/nscd/log.c
    trunk/usr.sbin/nscd/log.h
    trunk/usr.sbin/nscd/mp_rs_query.c
    trunk/usr.sbin/nscd/mp_rs_query.h
    trunk/usr.sbin/nscd/mp_ws_query.c
    trunk/usr.sbin/nscd/mp_ws_query.h
    trunk/usr.sbin/nscd/nscd.8
    trunk/usr.sbin/nscd/nscd.c
    trunk/usr.sbin/nscd/nscd.conf.5
    trunk/usr.sbin/nscd/nscdcli.c
    trunk/usr.sbin/nscd/nscdcli.h
    trunk/usr.sbin/nscd/parser.c
    trunk/usr.sbin/nscd/parser.h
    trunk/usr.sbin/nscd/protocol.c
    trunk/usr.sbin/nscd/protocol.h
    trunk/usr.sbin/nscd/query.c
    trunk/usr.sbin/nscd/query.h
    trunk/usr.sbin/nscd/singletons.c
    trunk/usr.sbin/nscd/singletons.h

Property Changed:
----------------
    trunk/usr.sbin/nscd/agents/Makefile.inc
    trunk/usr.sbin/nscd/nscd.8
    trunk/usr.sbin/nscd/nscd.conf.5

Modified: trunk/usr.sbin/nscd/Makefile
===================================================================
--- trunk/usr.sbin/nscd/Makefile	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/Makefile	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,4 +1,5 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/usr.sbin/nscd/Makefile 194098 2009-06-13 01:23:34Z des $
 
 PROG=	nscd
 MAN=	nscd.conf.5 nscd.8

Modified: trunk/usr.sbin/nscd/agent.c
===================================================================
--- trunk/usr.sbin/nscd/agent.c	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/agent.c	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/nscd/agent.c 194104 2009-06-13 13:07:56Z des $");
 
 #include <assert.h>
 #include <stdlib.h>

Modified: trunk/usr.sbin/nscd/agent.h
===================================================================
--- trunk/usr.sbin/nscd/agent.h	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/agent.h	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/nscd/agent.h 194112 2009-06-13 14:12:55Z des $
  */
 
 #ifndef __NSCD_AGENT_H__

Modified: trunk/usr.sbin/nscd/agents/Makefile.inc
===================================================================
--- trunk/usr.sbin/nscd/agents/Makefile.inc	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/agents/Makefile.inc	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/usr.sbin/nscd/agents/Makefile.inc 172344 2007-09-27 12:30:12Z bushman $
 
 SRCS += passwd.c group.c services.c


Property changes on: trunk/usr.sbin/nscd/agents/Makefile.inc
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/nscd/agents/group.c
===================================================================
--- trunk/usr.sbin/nscd/agents/group.c	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/agents/group.c	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/nscd/agents/group.c 194104 2009-06-13 13:07:56Z des $");
 
 #include <sys/param.h>
 

Modified: trunk/usr.sbin/nscd/agents/group.h
===================================================================
--- trunk/usr.sbin/nscd/agents/group.h	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/agents/group.h	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/nscd/agents/group.h 194112 2009-06-13 14:12:55Z des $
  */
 
 #include "../agent.h"

Modified: trunk/usr.sbin/nscd/agents/passwd.c
===================================================================
--- trunk/usr.sbin/nscd/agents/passwd.c	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/agents/passwd.c	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/nscd/agents/passwd.c 194104 2009-06-13 13:07:56Z des $");
 
 #include <sys/types.h>
 

Modified: trunk/usr.sbin/nscd/agents/passwd.h
===================================================================
--- trunk/usr.sbin/nscd/agents/passwd.h	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/agents/passwd.h	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/nscd/agents/passwd.h 194112 2009-06-13 14:12:55Z des $
  */
 
 #include "../agent.h"

Modified: trunk/usr.sbin/nscd/agents/services.c
===================================================================
--- trunk/usr.sbin/nscd/agents/services.c	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/agents/services.c	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/nscd/agents/services.c 194104 2009-06-13 13:07:56Z des $");
 
 #include <sys/param.h>
 

Modified: trunk/usr.sbin/nscd/agents/services.h
===================================================================
--- trunk/usr.sbin/nscd/agents/services.h	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/agents/services.h	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/nscd/agents/services.h 194112 2009-06-13 14:12:55Z des $
  */
 
 #include "../agent.h"

Modified: trunk/usr.sbin/nscd/cachelib.c
===================================================================
--- trunk/usr.sbin/nscd/cachelib.c	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/cachelib.c	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/nscd/cachelib.c 315600 2017-03-20 00:55:24Z pfg $");
 
 #include <sys/time.h>
 
@@ -487,8 +488,8 @@
 	assert(params != NULL);
 	memcpy(&retval->params, params, sizeof(struct cache_params));
 
-	retval->entries = calloc(1,
-		sizeof(*retval->entries) * INITIAL_ENTRIES_CAPACITY);
+	retval->entries = calloc(INITIAL_ENTRIES_CAPACITY,
+		sizeof(*retval->entries));
 	assert(retval->entries != NULL);
 
 	retval->entries_capacity = INITIAL_ENTRIES_CAPACITY;
@@ -540,8 +541,8 @@
 
 		new_capacity = the_cache->entries_capacity +
 			ENTRIES_CAPACITY_STEP;
-		new_entries = calloc(1,
-			sizeof(*new_entries) * new_capacity);
+		new_entries = calloc(new_capacity,
+			sizeof(*new_entries));
 		assert(new_entries != NULL);
 
 		memcpy(new_entries, the_cache->entries,
@@ -582,8 +583,8 @@
 		else
 			policies_size = 2;
 
-		new_common_entry->policies = calloc(1,
-			sizeof(*new_common_entry->policies) * policies_size);
+		new_common_entry->policies = calloc(policies_size,
+			sizeof(*new_common_entry->policies));
 		assert(new_common_entry->policies != NULL);
 
 		new_common_entry->policies_size = policies_size;
@@ -726,6 +727,12 @@
 		TRACE_OUT(cache_read);
 		return (-1);
 	}
+	/* pretend that entry was not found if confidence is below threshold*/
+	if (find_res->confidence < 
+	    common_entry->common_params.confidence_threshold) {
+		TRACE_OUT(cache_read);
+		return (-1);
+	}
 
 	if ((common_entry->common_params.max_lifetime.tv_sec != 0) ||
 		(common_entry->common_params.max_lifetime.tv_usec != 0)) {
@@ -826,6 +833,24 @@
 	item = HASHTABLE_GET_ENTRY(&(common_entry->items), hash);
 	find_res = HASHTABLE_ENTRY_FIND(cache_ht_, item, &item_data);
 	if (find_res != NULL) {
+		if (find_res->confidence < common_entry->common_params.confidence_threshold) {
+		  	/* duplicate entry is no error, if confidence is low */
+			if ((find_res->value_size == value_size) &&
+			    (memcmp(find_res->value, value, value_size) == 0)) {
+				/* increase confidence on exact match (key and values) */
+				find_res->confidence++;
+			} else {
+				/* create new entry with low confidence, if value changed */
+				free(item_data.value);
+				item_data.value = malloc(value_size);
+				assert(item_data.value != NULL);
+				memcpy(item_data.value, value, value_size);
+				item_data.value_size = value_size;
+				find_res->confidence = 1;
+			}
+			TRACE_OUT(cache_write);
+			return (0);
+		}
 		TRACE_OUT(cache_write);
 		return (-1);
 	}
@@ -839,6 +864,8 @@
 	memcpy(item_data.value, value, value_size);
 	item_data.value_size = value_size;
 
+	item_data.confidence = 1;
+
 	policy_item = common_entry->policies[0]->create_item_func();
 	policy_item->key = item_data.key;
 	policy_item->key_size = item_data.key_size;

Modified: trunk/usr.sbin/nscd/cachelib.h
===================================================================
--- trunk/usr.sbin/nscd/cachelib.h	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/cachelib.h	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/nscd/cachelib.h 238094 2012-07-04 09:02:12Z se $
  */
 
 #ifndef __NSCD_CACHELIB_H__
@@ -92,6 +93,7 @@
 	size_t	satisf_elemsize;	/* if entry size is exceeded,
 					 * this number of elements will be left,
 					 * others will be deleted */
+	int	confidence_threshold;	/* number matching replies required */
 	struct timeval	max_lifetime;	/* if 0 then no check is made */
 	enum cache_policy_t policy;	/* policy used for transformations */
 };
@@ -116,6 +118,7 @@
 	size_t	value_size;
 
 	struct cache_policy_item_ *fifo_policy_item;
+	int	confidence;	/* incremented for each verification */
 };
 
 struct cache_ht_item_ {

Modified: trunk/usr.sbin/nscd/cacheplcs.c
===================================================================
--- trunk/usr.sbin/nscd/cacheplcs.c	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/cacheplcs.c	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/nscd/cacheplcs.c 194104 2009-06-13 13:07:56Z des $");
 
 #include <sys/time.h>
 

Modified: trunk/usr.sbin/nscd/cacheplcs.h
===================================================================
--- trunk/usr.sbin/nscd/cacheplcs.h	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/cacheplcs.h	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/nscd/cacheplcs.h 194112 2009-06-13 14:12:55Z des $
  */
 
 #ifndef __NSCD_CACHEPLCS_H__

Modified: trunk/usr.sbin/nscd/config.c
===================================================================
--- trunk/usr.sbin/nscd/config.c	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/config.c	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/nscd/config.c 315600 2017-03-20 00:55:24Z pfg $");
 
 #include <sys/stat.h>
 #include <sys/time.h>
@@ -209,6 +210,7 @@
 	positive_params.max_elemsize = DEFAULT_POSITIVE_ELEMENTS_SIZE;
 	positive_params.satisf_elemsize = DEFAULT_POSITIVE_ELEMENTS_SIZE / 2;
 	positive_params.max_lifetime.tv_sec = DEFAULT_POSITIVE_LIFETIME;
+	positive_params.confidence_threshold = DEFAULT_POSITIVE_CONF_THRESH;
 	positive_params.policy = CPT_LRU;
 
 	memcpy(&negative_params, &positive_params,
@@ -216,6 +218,7 @@
 	negative_params.max_elemsize = DEFAULT_NEGATIVE_ELEMENTS_SIZE;
 	negative_params.satisf_elemsize = DEFAULT_NEGATIVE_ELEMENTS_SIZE / 2;
 	negative_params.max_lifetime.tv_sec = DEFAULT_NEGATIVE_LIFETIME;
+	negative_params.confidence_threshold = DEFAULT_NEGATIVE_CONF_THRESH;
 	negative_params.policy = CPT_FIFO;
 
 	memset(&default_common_timeout, 0, sizeof(struct timeval));
@@ -272,9 +275,8 @@
 		struct configuration_entry **new_entries;
 
 		config->entries_capacity *= 2;
-		new_entries = calloc(1,
-			sizeof(*new_entries) *
-			config->entries_capacity);
+		new_entries = calloc(config->entries_capacity,
+			sizeof(*new_entries));
 		assert(new_entries != NULL);
 		memcpy(new_entries, config->entries,
 			sizeof(struct configuration_entry *) *
@@ -520,9 +522,8 @@
 	assert(retval != NULL);
 
 	retval->entries_capacity = INITIAL_ENTRIES_CAPACITY;
-	retval->entries = calloc(1,
-		sizeof(*retval->entries) *
-		retval->entries_capacity);
+	retval->entries = calloc(retval->entries_capacity,
+		sizeof(*retval->entries));
 	assert(retval->entries != NULL);
 
 	pthread_rwlock_init(&retval->rwlock, NULL);

Modified: trunk/usr.sbin/nscd/config.h
===================================================================
--- trunk/usr.sbin/nscd/config.h	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/config.h	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/nscd/config.h 238094 2012-07-04 09:02:12Z se $
  */
 
 #ifndef __NSCD_CONFIG_H__
@@ -44,9 +45,11 @@
 
 #define DEFAULT_POSITIVE_ELEMENTS_SIZE	(2048)
 #define DEFAULT_POSITIVE_LIFETIME 	(3600)
+#define DEFAULT_POSITIVE_CONF_THRESH 	(1)
 
 #define DEFAULT_NEGATIVE_ELEMENTS_SIZE	(2048)
 #define DEFAULT_NEGATIVE_LIFETIME	(60)
+#define DEFAULT_NEGATIVE_CONF_THRESH 	(1) /* (2) ??? */
 
 #define DEFAULT_MULTIPART_ELEMENTS_SIZE	(1024 * 8)
 #define DEFAULT_MULITPART_SESSIONS_SIZE	(1024)

Modified: trunk/usr.sbin/nscd/debug.c
===================================================================
--- trunk/usr.sbin/nscd/debug.c	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/debug.c	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2004 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/nscd/debug.c 194093 2009-06-13 00:43:56Z des $");
 
 #include <stdio.h>
 

Modified: trunk/usr.sbin/nscd/debug.h
===================================================================
--- trunk/usr.sbin/nscd/debug.h	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/debug.h	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2004 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/nscd/debug.h 194112 2009-06-13 14:12:55Z des $
  */
 
 #ifndef __NSCD_DEBUG_H__

Modified: trunk/usr.sbin/nscd/hashtable.h
===================================================================
--- trunk/usr.sbin/nscd/hashtable.h	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/hashtable.h	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/nscd/hashtable.h 315600 2017-03-20 00:55:24Z pfg $
  */
 
 #ifndef __CACHELIB_HASHTABLE_H__
@@ -75,8 +76,8 @@
 #define HASHTABLE_INIT(table, type, field, _entries_size)		\
 	do {								\
 		hashtable_index_t var;					\
-		(table)->entries = calloc(1,				\
-			sizeof(*(table)->entries) * (_entries_size));	\
+		(table)->entries = calloc(_entries_size,		\
+			sizeof(*(table)->entries));			\
 		(table)->entries_size = (_entries_size);		\
 		for (var = 0; var < HASHTABLE_ENTRIES_COUNT(table); ++var) {\
 			(table)->entries[var].field.capacity = 		\

Modified: trunk/usr.sbin/nscd/log.c
===================================================================
--- trunk/usr.sbin/nscd/log.c	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/log.c	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/nscd/log.c 194093 2009-06-13 00:43:56Z des $");
 
 #include <assert.h>
 #include <stdarg.h>

Modified: trunk/usr.sbin/nscd/log.h
===================================================================
--- trunk/usr.sbin/nscd/log.h	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/log.h	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/nscd/log.h 194112 2009-06-13 14:12:55Z des $
  */
 
 #ifndef __NSCD_LOG_H__

Modified: trunk/usr.sbin/nscd/mp_rs_query.c
===================================================================
--- trunk/usr.sbin/nscd/mp_rs_query.c	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/mp_rs_query.c	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/nscd/mp_rs_query.c 194104 2009-06-13 13:07:56Z des $");
 
 #include <sys/types.h>
 #include <sys/event.h>

Modified: trunk/usr.sbin/nscd/mp_rs_query.h
===================================================================
--- trunk/usr.sbin/nscd/mp_rs_query.h	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/mp_rs_query.h	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/nscd/mp_rs_query.h 194112 2009-06-13 14:12:55Z des $
  */
 
 #ifndef __NSCD_MP_RS_QUERY_H__

Modified: trunk/usr.sbin/nscd/mp_ws_query.c
===================================================================
--- trunk/usr.sbin/nscd/mp_ws_query.c	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/mp_ws_query.c	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/nscd/mp_ws_query.c 194104 2009-06-13 13:07:56Z des $");
 
 #include <sys/types.h>
 #include <sys/event.h>

Modified: trunk/usr.sbin/nscd/mp_ws_query.h
===================================================================
--- trunk/usr.sbin/nscd/mp_ws_query.h	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/mp_ws_query.h	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/nscd/mp_ws_query.h 194112 2009-06-13 14:12:55Z des $
  */
 
 #ifndef __NSCD_MP_WS_QUERY_H__

Modified: trunk/usr.sbin/nscd/nscd.8
===================================================================
--- trunk/usr.sbin/nscd/nscd.8	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/nscd.8	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
 .\" All rights reserved.
 .\"
@@ -22,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.sbin/nscd/nscd.8 208291 2010-05-19 08:57:53Z uqs $
 .\"
 .Dd October 20, 2005
 .Dt NSCD 8


Property changes on: trunk/usr.sbin/nscd/nscd.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/nscd/nscd.c
===================================================================
--- trunk/usr.sbin/nscd/nscd.c	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/nscd.c	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/nscd/nscd.c 315600 2017-03-20 00:55:24Z pfg $");
 
 #include <sys/param.h>
 #include <sys/event.h>
@@ -828,8 +829,8 @@
 	}
 
 	if (s_configuration->threads_num > 1) {
-		threads = calloc(1, sizeof(*threads) *
-			s_configuration->threads_num);
+		threads = calloc(s_configuration->threads_num,
+			sizeof(*threads));
 		for (i = 0; i < s_configuration->threads_num; ++i) {
 			thread_args = malloc(
 				sizeof(*thread_args));

Modified: trunk/usr.sbin/nscd/nscd.conf.5
===================================================================
--- trunk/usr.sbin/nscd/nscd.conf.5	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/nscd.conf.5	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
 .\" All rights reserved.
 .\"
@@ -22,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.sbin/nscd/nscd.conf.5 238095 2012-07-04 10:17:02Z joel $
 .\"
 .Dd April 30, 2006
 .Dt NSCD.CONF 5
@@ -102,6 +103,17 @@
 elements of the given
 .Ar cachename .
 The default policy is fifo.
+.It Va negative-confidence-threshold Oo Ar cachename Oc Op Ar value
+The number of times a query must have failed before the cache accepts
+that the element can not be found.
+At the default value of 1 each negative query result is cached and
+immediately returned from the cache on further queries.
+Higher numbers cause queries to be retried at the configured data
+sources the given number of times, before the negative result is
+returned from the cache on further queries.
+This allows to probe for the existence of an entry, and then to create
+it if it did not exist, without the negative probe result preventing
+access to the new entry for the duration of the negative TTL.
 .It Va suggested-size Oo Ar cachename Oc Op Ar value
 This is the internal hash table size.
 The value should be a prime number for optimum performance.


Property changes on: trunk/usr.sbin/nscd/nscd.conf.5
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/nscd/nscdcli.c
===================================================================
--- trunk/usr.sbin/nscd/nscdcli.c	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/nscdcli.c	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/nscd/nscdcli.c 194104 2009-06-13 13:07:56Z des $");
 
 #include <sys/types.h>
 

Modified: trunk/usr.sbin/nscd/nscdcli.h
===================================================================
--- trunk/usr.sbin/nscd/nscdcli.h	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/nscdcli.h	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2004 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/nscd/nscdcli.h 194112 2009-06-13 14:12:55Z des $
  */
 
 #ifndef __NSCD_NSCDCLI_H__

Modified: trunk/usr.sbin/nscd/parser.c
===================================================================
--- trunk/usr.sbin/nscd/parser.c	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/parser.c	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/nscd/parser.c 238094 2012-07-04 09:02:12Z se $");
 
 #include <sys/time.h>
 
@@ -167,6 +168,38 @@
 	TRACE_OUT(set_negative_time_to_live);
 }
 
+static void
+set_positive_confidence_threshold(struct configuration *config,
+	const char *entry_name, int conf_thresh)
+{
+	struct configuration_entry *entry;
+
+	TRACE_IN(set_positive_conf_thresh);
+	assert(conf_thresh > 0);
+	assert(entry_name != NULL);
+
+	entry = find_create_entry(config, entry_name);
+	assert(entry != NULL);
+	entry->positive_cache_params.confidence_threshold = conf_thresh;
+
+	TRACE_OUT(set_positive_conf_thresh);
+}
+
+static void
+set_negative_confidence_threshold(struct configuration *config,
+	const char *entry_name, int conf_thresh)
+{
+	struct configuration_entry *entry;
+
+	TRACE_IN(set_negative_conf_thresh);
+	assert(conf_thresh > 0);
+	assert(entry_name != NULL);
+	entry = find_create_entry(config, entry_name);
+	assert(entry != NULL);
+	entry->negative_cache_params.confidence_threshold = conf_thresh;
+	TRACE_OUT(set_negative_conf_thresh);
+}
+
 /*
  * Hot count is actually the elements size limit.
  */
@@ -393,6 +426,12 @@
 					fields[1], value);
 				continue;
 			} else if ((field_count == 3) &&
+			(strcmp(fields[0], "positive-confidence-threshold") == 0) &&
+			((value = get_number(fields[2], 1, -1)) != -1)) {
+				set_positive_confidence_threshold(config,
+					fields[1], value);
+				continue;
+			} else if ((field_count == 3) &&
 			(strcmp(fields[0], "positive-policy") == 0) &&
 			(check_cachename(fields[1]) == 0) &&
 			((value = get_policy(fields[2])) != -1)) {
@@ -416,6 +455,12 @@
 					fields[1], value);
 				continue;
 			} else if ((field_count == 3) &&
+			(strcmp(fields[0], "negative-confidence-threshold") == 0) &&
+			((value = get_number(fields[2], 1, -1)) != -1)) {
+				set_negative_confidence_threshold(config,
+					fields[1], value);
+				continue;
+			} else if ((field_count == 3) &&
 			(strcmp(fields[0], "negative-policy") == 0) &&
 			(check_cachename(fields[1]) == 0) &&
 			((value = get_policy(fields[2])) != -1)) {

Modified: trunk/usr.sbin/nscd/parser.h
===================================================================
--- trunk/usr.sbin/nscd/parser.h	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/parser.h	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/nscd/parser.h 194112 2009-06-13 14:12:55Z des $
  */
 
 #ifndef __NSCD_PARSER_H__

Modified: trunk/usr.sbin/nscd/protocol.c
===================================================================
--- trunk/usr.sbin/nscd/protocol.c	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/protocol.c	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/nscd/protocol.c 194093 2009-06-13 00:43:56Z des $");
 
 #include <assert.h>
 #include <stdlib.h>

Modified: trunk/usr.sbin/nscd/protocol.h
===================================================================
--- trunk/usr.sbin/nscd/protocol.h	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/protocol.h	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/nscd/protocol.h 228990 2011-12-30 10:58:14Z uqs $
  */
 
 #ifndef __NSCD_PROTOCOL_H__
@@ -67,7 +68,7 @@
 };
 
 enum transformation_type {
-	TT_USER = 0,	// tranform only the entries of the caller
+	TT_USER = 0,	// transform only the entries of the caller
 	TT_ALL = 1	// transform all entries
 };
 

Modified: trunk/usr.sbin/nscd/query.c
===================================================================
--- trunk/usr.sbin/nscd/query.c	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/query.c	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/nscd/query.c 319178 2017-05-30 03:30:53Z cy $");
 
 #include <sys/types.h>
 #include <sys/event.h>
@@ -725,7 +726,7 @@
 		if (read_response->error_code == -2) {
 			read_response->data = malloc(
 				read_response->data_size);
-			assert(read_response != NULL);
+			assert(read_response->data != NULL);
 			read_response->error_code = cache_read(c_entry,
 				read_request->cache_key,
 		    		read_request->cache_key_size,
@@ -743,9 +744,14 @@
 				&read_response->data_size);
 
 			if (read_response->error_code == -2) {
-				read_response->error_code = 0;
-				read_response->data = NULL;
-				read_response->data_size = 0;
+				read_response->data = malloc(
+					read_response->data_size);
+				assert(read_response->data != NULL);
+				read_response->error_code = cache_read(neg_c_entry,
+					read_request->cache_key,
+		    			read_request->cache_key_size,
+		    			read_response->data,
+		    			&read_response->data_size);
 			}
 		}
 		configuration_unlock_entry(qstate->config_entry, CELT_NEGATIVE);
@@ -1253,8 +1259,8 @@
 	retval->read_func = query_socket_read;
 
 	get_time_func(&retval->creation_time);
-	memcpy(&retval->timeout, &s_configuration->query_timeout,
-		sizeof(struct timeval));
+	retval->timeout.tv_sec = s_configuration->query_timeout;
+	retval->timeout.tv_usec = 0;
 
 	TRACE_OUT(init_query_state);
 	return (retval);

Modified: trunk/usr.sbin/nscd/query.h
===================================================================
--- trunk/usr.sbin/nscd/query.h	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/query.h	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/nscd/query.h 194112 2009-06-13 14:12:55Z des $
  */
 
 #ifndef __NSCD_QUERY_H__

Modified: trunk/usr.sbin/nscd/singletons.c
===================================================================
--- trunk/usr.sbin/nscd/singletons.c	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/singletons.c	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/nscd/singletons.c 194089 2009-06-13 00:06:52Z des $");
 
 #include <sys/time.h>
 

Modified: trunk/usr.sbin/nscd/singletons.h
===================================================================
--- trunk/usr.sbin/nscd/singletons.h	2018-06-03 23:11:42 UTC (rev 10368)
+++ trunk/usr.sbin/nscd/singletons.h	2018-06-03 23:13:43 UTC (rev 10369)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/nscd/singletons.h 172344 2007-09-27 12:30:12Z bushman $
  */
 
 #ifndef __NSCD_SINGLETONS_H__



More information about the Midnightbsd-cvs mailing list