[PATCH] Remove potential reference count races
max at mtew.isa-geek.net
max at mtew.isa-geek.net
Sat Oct 27 20:59:35 CDT 2012
From: Max TenEyck Woodbury <max at mtew.isa-geek.net>
---
server/object.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/server/object.c b/server/object.c
index d2a3930..a5d6aac 100644
--- a/server/object.c
+++ b/server/object.c
@@ -295,7 +295,7 @@ struct object *grab_object( void *ptr )
{
struct object *obj = (struct object *)ptr;
assert( obj->refcount < INT_MAX );
- obj->refcount++;
+ InterlockedIncrement(&obj->refcount);
return obj;
}
@@ -304,7 +304,7 @@ void release_object( void *ptr )
{
struct object *obj = (struct object *)ptr;
assert( obj->refcount );
- if (!--obj->refcount)
+ if (!InterlockedDecrement(&obj->refcount))
{
/* if the refcount is 0, nobody can be in the wait queue */
assert( list_empty( &obj->wait_queue ));
@@ -353,7 +353,7 @@ struct object *find_object_index( const struct namespace *namespace, unsigned in
unsigned int i;
/* FIXME: not efficient at all */
- for (i = 0; i < namespace->hash_size; i++)
+ for (i = 0; i < namespace->hash_size; ++i)
{
const struct object_name *ptr;
LIST_FOR_EACH_ENTRY( ptr, &namespace->names[i], const struct object_name, entry )
@@ -375,7 +375,7 @@ struct namespace *create_namespace( unsigned int hash_size )
if (namespace)
{
namespace->hash_size = hash_size;
- for (i = 0; i < hash_size; i++) list_init( &namespace->names[i] );
+ for (i = 0; i < hash_size; ++i) list_init( &namespace->names[i] );
}
return namespace;
}
--
1.7.7.6
More information about the wine-patches
mailing list