summaryrefslogtreecommitdiff
path: root/net/irda/irqueue.c
diff options
context:
space:
mode:
authorJean Tourrilhes <jt@hpl.hp.com>2002-09-18 10:49:02 -0400
committerJeff Garzik <jgarzik@mandrakesoft.com>2002-09-18 10:49:02 -0400
commit57dd59ee67f9462d558ae15d054e2783fbc01aeb (patch)
tree1cb4acfd47aac88174c0dac772fdbee20e1c8730 /net/irda/irqueue.c
parent5f761bd3d04f12d0cf163544b8ef09677a0b0c2e (diff)
irda update 1/6:
o [CRITICA] Remove correct IAS Attribute/Object even if name is dup'ed o [CORRECT] Make irqueue 64 bit compliant (__u32 -> long) o [FEATURE] Don't use random handle for IrLMP handle, use self Remove dependancy on random generator in stack init
Diffstat (limited to 'net/irda/irqueue.c')
-rw-r--r--net/irda/irqueue.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/net/irda/irqueue.c b/net/irda/irqueue.c
index dd891f2d6481..463c21651b80 100644
--- a/net/irda/irqueue.c
+++ b/net/irda/irqueue.c
@@ -34,6 +34,21 @@
*
********************************************************************/
+/*
+ * NOTE :
+ * There are various problems with this package :
+ * o the hash function for ints is pathetic (but could be changed)
+ * o locking is sometime suspicious (especially during enumeration)
+ * o most users have only a few elements (== overhead)
+ * o most users never use seach, so don't benefit from hashing
+ * Problem already fixed :
+ * o not 64 bit compliant (most users do hashv = (int) self)
+ * o hashbin_remove() is broken => use hashbin_remove_this()
+ * I think most users would be better served by a simple linked list
+ * (like include/linux/list.h) with a global spinlock per list.
+ * Jean II
+ */
+
#include <net/irda/irda.h>
#include <net/irda/irqueue.h>
@@ -148,7 +163,7 @@ int hashbin_delete( hashbin_t* hashbin, FREE_FUNC free_func)
* Insert an entry into the hashbin
*
*/
-void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, __u32 hashv, char* name)
+void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv, char* name)
{
unsigned long flags = 0;
int bin;
@@ -209,7 +224,7 @@ void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, __u32 hashv, char*
* Find item with the given hashv or name
*
*/
-void* hashbin_find( hashbin_t* hashbin, __u32 hashv, char* name )
+void* hashbin_find( hashbin_t* hashbin, long hashv, char* name )
{
int bin, found = FALSE;
unsigned long flags = 0;
@@ -300,8 +315,16 @@ void *hashbin_remove_first( hashbin_t *hashbin)
*
* Remove entry with the given name
*
+ * The use of this function is highly discouraged, because the whole
+ * concept behind hashbin_remove() is broken. In many cases, it's not
+ * possible to guarantee the unicity of the index (either hashv or name),
+ * leading to removing the WRONG entry.
+ * The only simple safe use is :
+ * hashbin_remove(hasbin, (int) self, NULL);
+ * In other case, you must think hard to guarantee unicity of the index.
+ * Jean II
*/
-void* hashbin_remove( hashbin_t* hashbin, __u32 hashv, char* name)
+void* hashbin_remove( hashbin_t* hashbin, long hashv, char* name)
{
int bin, found = FALSE;
unsigned long flags = 0;
@@ -404,7 +427,7 @@ void* hashbin_remove_this( hashbin_t* hashbin, irda_queue_t* entry)
{
unsigned long flags = 0;
int bin;
- __u32 hashv;
+ long hashv;
IRDA_DEBUG( 4, __FUNCTION__ "()\n");