[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 10/75: libihash: prefer performance degradation over failure
From: |
Samuel Thibault |
Subject: |
[hurd] 10/75: libihash: prefer performance degradation over failure |
Date: |
Thu, 14 Jan 2016 01:04:02 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch dde
in repository hurd.
commit 226a9d9c34a2d187f978a25874488e5b07986d7c
Author: Justus Winter <address@hidden>
Date: Sun Jun 7 00:58:36 2015 +0200
libihash: prefer performance degradation over failure
* libihash/ihash.c (hurd_ihash_add): Add the item even though we are
above the load factor if resizing failed.
---
libihash/ihash.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/libihash/ihash.c b/libihash/ihash.c
index a97de3e..87d7abf 100644
--- a/libihash/ihash.c
+++ b/libihash/ihash.c
@@ -301,12 +301,14 @@ hurd_ihash_add (hurd_ihash_t ht, hurd_ihash_key_t key,
hurd_ihash_value_t item)
{
struct hurd_ihash old_ht = *ht;
int was_added;
+ int fatal = 0; /* bail out on allocation errors */
unsigned int i;
if (ht->size)
{
/* Only fill the hash table up to its maximum load factor. */
if (hurd_ihash_get_load (ht) <= ht->max_load)
+ add_one:
if (add_one (ht, key, item))
return 0;
}
@@ -324,7 +326,15 @@ hurd_ihash_add (hurd_ihash_t ht, hurd_ihash_key_t key,
hurd_ihash_value_t item)
if (ht->items == NULL)
{
*ht = old_ht;
- return ENOMEM;
+ if (fatal || ht->size == 0)
+ return ENOMEM;
+
+ /* We prefer performance degradation over failure. Therefore,
+ we add the item even though we are above the load factor. If
+ the table is full, this will fail. We set the fatal flag to
+ avoid looping. */
+ fatal = 1;
+ goto add_one;
}
/* We have to rehash the old entries. */
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] branch dde updated (c7fdc30 -> cb08549), Samuel Thibault, 2016/01/13
- [hurd] 04/75: random: fix odd formatting, Samuel Thibault, 2016/01/13
- [hurd] 06/75: random: use /servers/startup to register for shutdown notifications, Samuel Thibault, 2016/01/13
- [hurd] 07/75: random: satisfy arbitrarily-sized reads, Samuel Thibault, 2016/01/13
- [hurd] 08/75: libihash: add hurd_ihash_value_valid, Samuel Thibault, 2016/01/13
- [hurd] 10/75: libihash: prefer performance degradation over failure,
Samuel Thibault <=
- [hurd] 11/75: Make dde conditionally built under presence of libpciaccess, Samuel Thibault, 2016/01/13
- [hurd] 13/75: Clean debugging macro, Samuel Thibault, 2016/01/13
- [hurd] 09/75: libihash: optimize lookup-or-insert operations, Samuel Thibault, 2016/01/13
- [hurd] 03/75: Remove unused variables, Samuel Thibault, 2016/01/13
- [hurd] 17/75: Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/hurd into dde, Samuel Thibault, 2016/01/13
- [hurd] 19/75: Add devnode documentation, Samuel Thibault, 2016/01/13
- [hurd] 23/75: Add missing menus, Samuel Thibault, 2016/01/13
- [hurd] 20/75: Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/hurd into dde, Samuel Thibault, 2016/01/13
- [hurd] 12/75: Merge branch 'dde' of ssh://git.savannah.gnu.org/srv/git/hurd/incubator into dde, Samuel Thibault, 2016/01/13
- [hurd] 02/75: libtrivfs: remove deprecated static class vectors, Samuel Thibault, 2016/01/13