mdev race conditions

Mike Frysinger vapier at gentoo.org
Tue Jun 3 20:08:43 UTC 2008


On Tuesday 03 June 2008, Denys Vlasenko wrote:
> On Tuesday 03 June 2008 18:47, Mike Frysinger wrote:
> > > > Would this be all it takes? Anyone with more than half an hour's
> > > > experience of looking at udev's source code willing to comment? :)
> > >
> > > Didn't look at udev yet.
> > >
> > > What about just storing current seq # in a file, and if you see wrong
> > > number in that file, just want for correct one to appear (or time out
> > > in "reasonable time")?
> >
> > how do you time out without running as a daemon?  have the mdev binary
> > sleep()?
>
> More or less. mdev can have an option where to store seqfile:
> mdev -l <SEQFILE>, and then it does:
>
> seqnum = atoi(getenv("SEQNUM"));
> timeout = 300/2 + 1; /* 3 seconds */
> while (--timeout && read_num(SEQFILE) + 1 != seqnum)
> 	usleep(20*1000);
> <do normal mdev stuff>
> write_num(SEQFILE, seqnum); /* atomically */
>
> In other words, mdev's will be started asyncronously but will wait
> until they see that mdev with preceding seqnum have finished.

a single hotplug event will trigger many messages  (iirc, you can easily get 
bursts of ~10 or so with a single network interface).  which means you'll 
have many mdev processes all hanging out.  hopefully that flurry doesnt cause 
the delays to stretch out of sequence again.

you'll also need to make sure you do this somewhere which has temporary 
storage ... otherwise you'll wreck embedded flash systems

> > then you may have multiple mdev's sleeping which means you need to
> > do process management, or implement some method for shared communication,
> > or ...
>
> Above looks like pretty simple shared communication to me.

*shrug* anything not daemon/netlink based looks like a hack to me ... which 
means i still dont understand why people dont go use udevd if they need a 
real setup.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: This is a digitally signed message part.
Url : http://lists.busybox.net/pipermail/busybox/attachments/20080603/1d750d5e/attachment-0002.pgp 


More information about the busybox mailing list