[haiku-commits] r34238 - haiku/trunk/src/system/kernel

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 25 Nov 2009 12:50:45 +0100 (CET)

Author: axeld
Date: 2009-11-25 12:50:45 +0100 (Wed, 25 Nov 2009)
New Revision: 34238
Changeset: http://dev.haiku-os.org/changeset/34238/haiku

Modified:
   haiku/trunk/src/system/kernel/syscalls.cpp
Log:
* Introduced a flag to decide whether it's still okay to call a certain
  syscall.


Modified: haiku/trunk/src/system/kernel/syscalls.cpp
===================================================================
--- haiku/trunk/src/system/kernel/syscalls.cpp  2009-11-25 11:48:39 UTC (rev 
34237)
+++ haiku/trunk/src/system/kernel/syscalls.cpp  2009-11-25 11:50:45 UTC (rev 
34238)
@@ -62,6 +62,7 @@
        uint32                  version;
        uint32                  flags;
        int32                   use_count;
+       bool                    valid;
        generic_syscall *previous;
 };
 
@@ -140,17 +141,19 @@
        while (syscall != NULL) {
                generic_syscall* next;
 
-               syscall->use_count++;
-               locker.Unlock();
+               if (syscall->valid) {
+                       syscall->use_count++;
+                       locker.Unlock();
 
-               status_t status
-                       = syscall->hook(subsystem, function, buffer, 
bufferSize);
+                       status_t status
+                               = syscall->hook(subsystem, function, buffer, 
bufferSize);
 
-               locker.Lock();
-               syscall->use_count--;
+                       locker.Lock();
+                       syscall->use_count--;
 
-               if (status != B_BAD_HANDLER)
-                       return status;
+                       if (status != B_BAD_HANDLER)
+                               return status;
+               }
 
                // the syscall may have been removed in the mean time
                next = find_generic_syscall(subsystem);
@@ -264,6 +267,7 @@
        syscall->version = version;
        syscall->flags = flags;
        syscall->use_count = 0;
+       syscall->valid = true;
        syscall->previous = previous;
        list_add_item(&sGenericSyscalls, syscall);
 
@@ -286,6 +290,8 @@
                if (syscall == NULL)
                        return B_NAME_NOT_FOUND;
 
+               syscall->valid = false;
+
                if (syscall->use_count != 0) {
                        // TODO: we could use a condition variable here instead
                        locker.Unlock();


Other related posts:

  • » [haiku-commits] r34238 - haiku/trunk/src/system/kernel - axeld