Ticket #3447: legacy_drivers.diff
File legacy_drivers.diff, 3.2 KB (added by , 16 years ago) |
---|
-
src/system/kernel/device_manager/legacy_drivers.cpp
185 185 static DriverWatcher sDriverWatcher; 186 186 static int32 sDriverEvents; 187 187 static DoublyLinkedList<path_entry> sDriversToAdd; 188 static DoublyLinkedList<path_entry> sDriversToRemove; 189 static mutex sDriversListLock = MUTEX_INITIALIZER("driversList"); 188 190 static DirectoryWatcher sDirectoryWatcher; 189 191 static DirectoryNodeHash sDirectoryNodeHash; 190 192 static recursive_lock sLock; … … 620 622 // something happened, let's see what it was 621 623 622 624 RecursiveLocker locker(sLock); 625 MutexLocker _(sDriversListLock); 623 626 624 627 while (true) { 625 628 path_entry* path = sDriversToAdd.RemoveHead(); 626 629 if (path == NULL) 627 630 break; 628 631 629 legacy_driver_add(path->path); 632 legacy_driver* driver = (legacy_driver*)hash_lookup(sDriverHash, 633 get_leaf(path->path)); 634 if (driver == NULL) 635 legacy_driver_add(path->path); 636 else if (get_priority(path->path) >= driver->priority) 637 driver->binary_updated = true; 630 638 delete path; 631 639 } 640 while (true) { 641 path_entry* path = sDriversToRemove.RemoveHead(); 642 if (path == NULL) 643 break; 632 644 645 legacy_driver* driver = (legacy_driver*)hash_lookup(sDriverHash, 646 get_leaf(path->path)); 647 if (driver != NULL && get_priority(path->path) >= driver->priority) 648 driver->binary_updated = true; 649 delete path; 650 } 651 633 652 hash_iterator iterator; 634 653 hash_open(sDriverHash, &iterator); 635 654 legacy_driver *driver; … … 648 667 } 649 668 650 669 651 static void652 driver_added(const char* path)653 {654 int32 priority = get_priority(path);655 RecursiveLocker locker(sLock);656 657 legacy_driver* driver = (legacy_driver*)hash_lookup(sDriverHash,658 get_leaf(path));659 660 if (driver == NULL) {661 // Add the driver to our list662 path_entry* entry = new(std::nothrow) path_entry;663 if (entry == NULL)664 return;665 666 strlcpy(entry->path, path, sizeof(entry->path));667 sDriversToAdd.Add(entry);668 } else {669 // Update the driver if it is affected by the new entry670 if (priority < driver->priority)671 return;672 673 driver->binary_updated = true;674 }675 676 atomic_add(&sDriverEvents, 1);677 }678 679 680 static void681 driver_removed(const char* path)682 {683 int32 priority = get_priority(path);684 RecursiveLocker locker(sLock);685 686 legacy_driver* driver = (legacy_driver*)hash_lookup(sDriverHash,687 get_leaf(path));688 if (driver == NULL || priority < driver->priority)689 return;690 691 driver->binary_updated = true;692 atomic_add(&sDriverEvents, 1);693 }694 695 696 670 // #pragma mark - DriverWatcher 697 671 698 672 … … 974 948 dprintf("driver \"%s\" %s\n", path.Leaf(), 975 949 opcode == B_ENTRY_CREATED ? "added" : "removed"); 976 950 951 path_entry* entry = new(std::nothrow) path_entry; 952 if (entry == NULL) 953 return; 954 955 strlcpy(entry->path, path.Path(), sizeof(entry->path)); 956 MutexLocker _(sDriversListLock); 957 977 958 switch (opcode) { 978 959 case B_ENTRY_CREATED: 979 driver_added(path.Path());960 sDriversToAdd.Add(entry); 980 961 break; 981 962 case B_ENTRY_REMOVED: 982 driver_removed(path.Path());963 sDriversToRemove.Add(entry); 983 964 break; 984 965 } 966 atomic_add(&sDriverEvents, 1); 985 967 } 986 968 987 969