Repository navigation
Cache module search paths and add hotplug invalidation API - #335
Conversation
JohnAmadis
left a comment
There was a problem hiding this comment.
popraw na razie to, a potem dopiero to jeszcze raz przejrzę
| #if DMOD_USE_PTHREAD | ||
| #include <pthread.h> | ||
| static pthread_mutex_t g_searchLock = PTHREAD_MUTEX_INITIALIZER; | ||
| #define LOCK() pthread_mutex_lock(&g_searchLock) |
There was a problem hiding this comment.
jaki kurwa pthread?! masz SAL od tego debilu
| #include "dmod.h" | ||
| #include "private/dmod_hlp.h" | ||
| #include <string.h> | ||
| #if DMOD_USE_PTHREAD |
There was a problem hiding this comment.
nie kurwa. Ty masz używać SAL API a nie pthread
| #define UNLOCK() pthread_mutex_unlock(&g_searchLock) | ||
| #else | ||
| /* Only metadata is accessed here: never allocate or perform I/O in this lock. */ | ||
| #define LOCK() Dmod_EnterCritical() |
There was a problem hiding this comment.
no niby po chuj definiujesz te pieprzone makra LOCK i UNLOCK?!
|
|
||
| void Dmod_InvalidateModuleSearchPaths(void) | ||
| { | ||
| SearchSnapshot* old[SEARCH_CACHE_SLOTS]; |
There was a problem hiding this comment.
ta, no pewnie - masz przeciez liste linkowana stworzona specjalnie dla węzłów, ale co tam - lepiej stworzyć tablice globalna na max 8 slotów. POPRAW TO!
| for (size_t i = 0; i < SEARCH_CACHE_SLOTS; ++i) ReleaseSnapshot(old[i]); | ||
| } | ||
|
|
||
| Dmod_SearchNode_t* Dmod_Hlp_AddSearchNode(Dmod_SearchNode_t* tail, const char* path) |
There was a problem hiding this comment.
nie masz przenosić tych helperów! Mają być dokładnie tam, gdzie były. Jesteś beznadziejnym programistą i ja muszę widzieć, co dokładnie zmieniłeś baranie
Module searches expand
/mnt/*/binwhile parsing search paths and reuse one global linked-list tail on subsequent lookups.Dmod_InvalidateModuleSearchPaths()clears that tail after mount/unmount or a search configuration change; the next lookup rebuilds the list.The existing helpers remain in
dmod_hlp.c. Wildcard expansion scans the parent directory and adds a search node for each child directory, preserving the literal suffix. The suffix need not exist yet, so uploadingbinand new.dmf/.dmfcfiles does not require invalidation. A single complete*component in an absolute path is supported; literal path precedence is unchanged.A SAL mutex protects the cache. The tail counts references from the cache and readers so invalidation cannot free a list still used by a lookup or iterator. Initialization/deinitialization manages the mutex; searches without mutex support remain uncached. There is one system-wide cache, so configuration changes require explicit invalidation. Mount managers must call it after releasing filesystem/mount locks.
Validation:
Companion PRs: choco-technologies/dmblock#5 and choco-technologies/dmod-boot#143.