lkml.org 
[lkml]   [2002]   [Sep]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [RFC] Raceless module interface
Date
On Friday 13 September 2002 08:51, Rusty Russell wrote:
> If you split registration interfaces into reserve (can fail) and
> use (can't fail), then you do:
>
> int my_module_init(void)
> {
> int ret;
> ret = reserve_foo();
> if (ret != 0)
> return ret;
> ret = reserve_bar();
> if (ret != 0)
> unreserve_foo();
> return ret;
> }
>
> void my_module_start(void)
> {
> use_foo();
> use_bar();
> }

Why is that different from:

int my_module_init(void)
{
int ret;
ret = reserve_foo();
if (ret != 0)
return ret;
ret = reserve_bar();
if (ret != 0) {
unreserve_foo();
return ret;
}
use_foo();
use_bar();
return 0;
}

> Note the symmetry here with the exit case: noone can actually use the
> module until my_module_start is called, so even if the reserve_bar()
> fails, we're safe.

And in my example above, nobody can actually use the module until
use_foo(). What's the difference?

> > Sure, I know it's not going to change, but I'd like to know what the
> > thinking was, and especially, if there's a non-bogus reason, I'd
> > like to know it.
>
> You should probably start playing with my code if you're really
> interested.

Of course, and you might consider actually reading my [RFC]. We still
disagree on whether your fat interface or my thin one is the right way
to go. Don't forget that the Unix way has traditionally been to use
the simplest interface that will do the job; if you propose a fat
interface you need to prove that the thin one cannot do the job.

--
Daniel
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:22    [W:0.144 / U:0.396 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site