* Introduced a flag to decide whether it's still okay to call a certain

syscall.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34238 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-11-25 11:50:45 +00:00
parent 23f179da55
commit 40fddd06d6

View File

@ -62,6 +62,7 @@ struct generic_syscall {
uint32 version; uint32 version;
uint32 flags; uint32 flags;
int32 use_count; int32 use_count;
bool valid;
generic_syscall *previous; generic_syscall *previous;
}; };
@ -140,17 +141,19 @@ _user_generic_syscall(const char* userSubsystem, uint32 function,
while (syscall != NULL) { while (syscall != NULL) {
generic_syscall* next; generic_syscall* next;
syscall->use_count++; if (syscall->valid) {
locker.Unlock(); syscall->use_count++;
locker.Unlock();
status_t status status_t status
= syscall->hook(subsystem, function, buffer, bufferSize); = syscall->hook(subsystem, function, buffer, bufferSize);
locker.Lock(); locker.Lock();
syscall->use_count--; syscall->use_count--;
if (status != B_BAD_HANDLER) if (status != B_BAD_HANDLER)
return status; return status;
}
// the syscall may have been removed in the mean time // the syscall may have been removed in the mean time
next = find_generic_syscall(subsystem); next = find_generic_syscall(subsystem);
@ -264,6 +267,7 @@ register_generic_syscall(const char* subsystem, syscall_hook hook,
syscall->version = version; syscall->version = version;
syscall->flags = flags; syscall->flags = flags;
syscall->use_count = 0; syscall->use_count = 0;
syscall->valid = true;
syscall->previous = previous; syscall->previous = previous;
list_add_item(&sGenericSyscalls, syscall); list_add_item(&sGenericSyscalls, syscall);
@ -286,6 +290,8 @@ unregister_generic_syscall(const char* subsystem, uint32 version)
if (syscall == NULL) if (syscall == NULL)
return B_NAME_NOT_FOUND; return B_NAME_NOT_FOUND;
syscall->valid = false;
if (syscall->use_count != 0) { if (syscall->use_count != 0) {
// TODO: we could use a condition variable here instead // TODO: we could use a condition variable here instead
locker.Unlock(); locker.Unlock();