fontconfig: Branch 'master' - 3 commits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 doc/fccache.fncs |   18 +++++++++++++++++-
 src/fccache.c    |    7 ++++++-
 src/fchash.c     |   37 ++++++++++++++++++++++++++++++++-----
 src/fcint.h      |    4 ++++
 test/run-test.sh |   43 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 102 insertions(+), 7 deletions(-)

New commits:
commit c1e48b0c1439007b41887177ef7b34e4d75e3a31
Author: Akira TAGOH <akira@xxxxxxxxx>
Date:   Mon Dec 18 20:05:44 2017 +0900

    Add a test case for uuid creation

diff --git a/test/run-test.sh b/test/run-test.sh
index be2cc92..4154dd3 100644
--- a/test/run-test.sh
+++ b/test/run-test.sh
@@ -121,6 +121,49 @@ mkdir $FONTDIR/a
 cp $FONT2 $FONTDIR/a
 check
 
+dotest "Re-creating .uuid"
+prep
+cp $FONT1 $FONTDIR
+$FCCACHE $FONTDIR
+cat $FONTDIR/.uuid > out1
+$FCCACHE -f $FONTDIR
+cat $FONTDIR/.uuid > out2
+if cmp out1 out2 > /dev/null ; then : ; else
+  echo "*** Test failed: $TEST"
+  echo "*** .uuid was modified unexpectedly"
+  exit 1
+fi
+$FCCACHE -r $FONTDIR
+cat $FONTDIR/.uuid > out2
+if cmp out1 out2 > /dev/null ; then
+  echo "*** Test failed: $TEST"
+  echo "*** .uuid wasn't modified"
+  exit 1
+fi
+rm out1 out2
+
+dotest "Consistency between .uuid and cache name"
+prep
+cp $FONT1 $FONTDIR
+$FCCACHE $FONTDIR
+cat $FONTDIR/.uuid
+$FCCACHE -r $FONTDIR
+uuid=`cat $FONTDIR/.uuid`
+ls $CACHEDIR/$uuid*
+if [ $? != 0 ]; then
+  echo "*** Test failed: $TEST"
+  echo "No cache for $uuid"
+  ls $CACHEDIR
+  exit 1
+fi
+n=`ls -1 $CACHEDIR/*cache-* | wc -l`
+if [ $n != 1 ]; then
+  echo "*** Test failed: $TEST"
+  echo "Unexpected cache was created"
+  ls $CACHEDIR
+  exit 1
+fi
+
 if [ x"$BWRAP" != "x" ]; then
 dotest "Basic functionality with the bind-mounted cache dir"
 prep
commit 8ab4d679959815feb0c383e1e17953fe1c46091f
Author: Akira TAGOH <akira@xxxxxxxxx>
Date:   Mon Dec 18 20:05:14 2017 +0900

    Replace uuid in the table properly when -r

diff --git a/src/fccache.c b/src/fccache.c
index c9e7256..dfe9520 100644
--- a/src/fccache.c
+++ b/src/fccache.c
@@ -62,6 +62,7 @@ FcDirCacheCreateUUID (FcChar8  *dir,
 	int fd;
 	uuid_t uuid;
 	char out[37];
+	FcBool (* hash_add) (FcHashTable *, void*, void*);
 
 	atomic = FcAtomicCreate (uuidname);
 	if (!atomic)
@@ -81,7 +82,11 @@ FcDirCacheCreateUUID (FcChar8  *dir,
 	    goto bail3;
 	}
 	uuid_generate_random (uuid);
-	if (!FcHashTableAdd (config->uuid_table, dir, uuid))
+	if (force)
+	    hash_add = FcHashTableReplace;
+	else
+	    hash_add = FcHashTableAdd;
+	if (!hash_add (config->uuid_table, dir, uuid))
 	{
 	    ret = FcFalse;
 	    goto bail3;
diff --git a/src/fchash.c b/src/fchash.c
index 54e2334..32e59c5 100644
--- a/src/fchash.c
+++ b/src/fchash.c
@@ -137,10 +137,11 @@ FcHashTableFind (FcHashTable  *table,
     return FcFalse;
 }
 
-FcBool
-FcHashTableAdd (FcHashTable *table,
-		void        *key,
-		void        *value)
+static FcBool
+FcHashTableAddInternal (FcHashTable *table,
+			void        *key,
+			void        *value,
+			FcBool       replace)
 {
     FcHashBucket **prev, *bucket, *b;
     FcChar32 hash = table->hash_func (key);
@@ -167,17 +168,43 @@ FcHashTableAdd (FcHashTable *table,
 	    table->value_destroy_func (bucket->value);
 	free (bucket);
 
-	return FcFalse;
+	return !ret;
     }
   retry:
     for (prev = &table->buckets[hash % FC_HASH_SIZE];
 	 (b = fc_atomic_ptr_get (prev)); prev = &(b->next))
     {
 	if (!table->compare_func (bucket->key, key))
+	{
+	    if (replace)
+	    {
+		if (!fc_atomic_ptr_cmpexch (prev, b, bucket))
+		    goto retry;
+		bucket = b;
+	    }
+	    else
+		ret = FcTrue;
 	    goto destroy;
+	}
     }
     if (!fc_atomic_ptr_cmpexch (prev, b, bucket))
 	goto retry;
 
     return FcTrue;
 }
+
+FcBool
+FcHashTableAdd (FcHashTable *table,
+		void        *key,
+		void        *value)
+{
+    return FcHashTableAddInternal (table, key, value, FcFalse);
+}
+
+FcBool
+FcHashTableReplace (FcHashTable *table,
+		    void        *key,
+		    void        *value)
+{
+    return FcHashTableAddInternal (table, key, value, FcTrue);
+}
diff --git a/src/fcint.h b/src/fcint.h
index 3559ad6..6185f5a 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -1335,5 +1335,9 @@ FcHashTableAdd (FcHashTable *table,
 		void        *key,
 		void        *value);
 
+FcPrivate FcBool
+FcHashTableReplace (FcHashTable *table,
+		    void        *key,
+		    void        *value);
 
 #endif /* _FC_INT_H_ */
commit 0378790ca362757061bff83c8a344991f1f829c6
Author: Akira TAGOH <akira@xxxxxxxxx>
Date:   Mon Dec 18 20:04:13 2017 +0900

    Add missing doc of FcDirCacheCreateUUID

diff --git a/doc/fccache.fncs b/doc/fccache.fncs
index 34ce63f..17e74fe 100644
--- a/doc/fccache.fncs
+++ b/doc/fccache.fncs
@@ -71,7 +71,8 @@ FcCacheCopySet.
 @FUNC@		FcDirCacheClean
 @TYPE1@		const FcChar8 *			@ARG1@		cache_dir
 @TYPE2@		FcBool				@ARG2@		verbose
-@PURPOSE@
+@PURPOSE@	Clean up a cache directory
+@DESC@
 This tries to clean up the cache directory of <parameter>cache_dir</parameter>.
 This returns FcTrue if the operation is successfully complete. otherwise FcFalse.
 @SINCE@		2.9.91
@@ -86,3 +87,18 @@ This tries to create CACHEDIR.TAG file at the cache directory registered
 to <parameter>config</parameter>.
 @SINCE@		2.9.91
 @@
+
+@RET@		FcBool
+@FUNC@		FcDirCacheCreateUUID
+@TYPE1@		FcChar8 *			@ARG1@		dir
+@TYPE2@		FcBool				@ARG2@		force
+@TYPE3@		FcConfig			@ARG3@		config
+@PURPOSE@	Create .uuid file at a directory
+@DESC@
+This is to create .uuid file containing an UUID at a font directory of
+<parameter>dir</parameter>.
+The UUID will be used to identify the font directory and is used to determine
+the cache filename if available.
+@SINCE@		2.12.92
+@@
+
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/fontconfig




[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux