[Pvfs2-cvs] commit by nlmills in pvfs2/src/common/misc: tcache.c
tcache.h
CVS commit program
cvs at parl.clemson.edu
Mon Jul 7 15:09:00 EDT 2008
Update of /anoncvs/pvfs2/src/common/misc
In directory parlweb1:/tmp/cvs-serv18844
Modified Files:
Tag: cu-security-branch
tcache.c tcache.h
Log Message:
updated tcache to support setting the timeout during insert
Index: tcache.c
===================================================================
RCS file: /anoncvs/pvfs2/src/common/misc/tcache.c,v
diff -p -u -r1.9 -r1.9.30.1
--- tcache.c 1 Aug 2006 00:37:37 -0000 1.9
+++ tcache.c 7 Jul 2008 19:09:00 -0000 1.9.30.1
@@ -1,9 +1,11 @@
/*
- * Copyright © Acxiom Corporation, 2005
+ * Copyright Acxiom Corporation, 2005
+ * (C) 2008 Clemson University and The University of Chicago
*
* See COPYING in top-level directory.
*/
+#include <string.h>
#include <assert.h>
#include "tcache.h"
@@ -260,14 +262,31 @@ int PINT_tcache_set_info(
}
/**
- * Adds an entry to the tcache. Caller must not retain a pointer to the
- * payload; it could be destroyed at any time.
+ * Adds an entry to the tcache. The caller must not retain a pointer
+ * to the payload; it could be destroyed at any time. The default
+ * timeout value is used.
* \return 0 on success, -PVFS_error on failure
*/
int PINT_tcache_insert_entry(
struct PINT_tcache* tcache, /**< pointer to tcache instance */
+ void* key, /**< uniquely identifies the payload */
+ void* payload, /**< data to store in the cache */
+ int* purged) /**< number of entries purged to make room */
+{
+ return PINT_tcache_insert_entry_ex(tcache, key, payload, NULL, purged);
+}
+
+/**
+ * Adds an entry to the tcache with the given expiration date.
+ * The caller must not retain a pointer to the payload; it could
+ * be destroyed at any time.
+ * \return 0 on success, -PVFS_error on failure
+ */
+int PINT_tcache_insert_entry_ex(
+ struct PINT_tcache* tcache, /**< pointer to tcache instance */
void* key, /**< that uniquely identifies the payload */
void* payload, /**< data to store in the cache */
+ struct timeval* expiration, /**< when the entry will expire */
int* purged) /**< number of entries purged to make room */
{
struct PINT_tcache_entry* tmp_entry = NULL;
@@ -332,11 +351,19 @@ int PINT_tcache_insert_entry(
tmp_entry->payload = payload;
/* set expiration date */
- ret = PINT_tcache_refresh_entry(tcache, tmp_entry);
- if(ret < 0)
+ if(expiration)
+ {
+ memcpy(&tmp_entry->expiration_date, expiration,
+ sizeof(struct timeval));
+ }
+ else
{
- free(tmp_entry);
- return(ret);
+ ret = PINT_tcache_refresh_entry(tcache, tmp_entry);
+ if(ret < 0)
+ {
+ free(tmp_entry);
+ return(ret);
+ }
}
/* add to hash table */
Index: tcache.h
===================================================================
RCS file: /anoncvs/pvfs2/src/common/misc/tcache.h,v
diff -p -u -r1.3 -r1.3.38.1
--- tcache.h 13 Jun 2006 15:56:51 -0000 1.3
+++ tcache.h 7 Jul 2008 19:09:00 -0000 1.3.38.1
@@ -1,5 +1,6 @@
/*
- * Copyright © Acxiom Corporation, 2005
+ * Copyright Acxiom Corporation, 2005
+ * (C) 2008 Clemson University and The University of Chicago
*
* See COPYING in top-level directory.
*/
@@ -152,6 +153,13 @@ int PINT_tcache_insert_entry(
struct PINT_tcache* tcache,
void* key,
void* payload,
+ int* purged);
+
+int PINT_tcache_insert_entry_ex(
+ struct PINT_tcache* tcache,
+ void* key,
+ void* payload,
+ struct timeval* expiration,
int* purged);
int PINT_tcache_lookup(
More information about the Pvfs2-cvs
mailing list