Re: Plans for mISDN? Was: [PATCH 00/14] [ISDN] ...

Bodo Eggert
2008-02-25T15:46:49Z

Andi Kleen <andi@firstfloor.org> wrote:

>> we were talking about the load order. This will solve the load order,
>> but if we have races like the kind you described, then the whole mISDN
>> design is broken.
>
> It's more a generic problem of the module code.

It's a problem of not enough synchronisation before a module load completes.

If a module provides an interface, but needs some time after being load to
initialize, it obviously MUST provide a way to wait for it. Since you'll
need some i-need-module-foo functions anyway, why not: (bar needs foo)

-foo.c---
DECLARE_COMPLETION(init_complete); /* static? */
module_foo_init_async() {
...
void complete_all(&init_complete);
}

void usemod_foo()
{
wait_for_completion(&init_complete);
}
EXPORT_SYMBOL(usemod_foo)

-bar.c---
DECLARE_COMPLETION(init_complete);
module_bar_init_async() {
usemod_foo();
...
void complete_all(&init_complete);
}

void usemod_bar()
{
wait_for_completion(&init_complete);
}
EXPORT_SYMBOL(usemod_bar)