mdev -d can (silently) die with "read: no buffer space available"

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Sun Dec 15 08:23:27 UTC 2019


On Sun, 15 Dec 2019 08:44:14 +1000
Alexander Zangerl <az+bb at snafu.priv.at> wrote:

> >> i think open_mdev_log() should be called in daemon_loop, not just
> >> after initial_scan() and bb_daemonize_or_rexec().  
> >
> >That would incur a considerable syscall overhead for the regular case
> >where mdev.log does not exist. Then mdev would try to open mdev.log for
> >every event it receives.  
> 
> i meant 'guarded by a stat() and inode comparison'.
> that shouldn't be too expensive i think. how about this? the patch works
> for any number of instances of mdev.log being created and removed later on,
> and costs one stat().

Well stat() is a very heavy op, i wouldn't want to do that for every
event.
Two completely unrelated remarks:
in davis_weather, fetchdavis you wrote:

> my ($dumpfhandle, $csv, $wantsheader);                                         
> if (my $dumpf = $opts{l})                                                      
> {                                                                              
>     $csv = Text::CSV->new;                                                     
>     $wantsheader = (!-f $dumpf);                                               
>     if (!open($dumpfhandle, ">>$dumpf"))                                       
>     {                                                                          
>         faillog("cannot write to logfile $dumpf: $!");                         
>         undef $dumpfhandle;     #  fall back to no logging                     
>     }                                                                          
>     $dumpfhandle->autoflush(1);                                                
> }    
which won't work too well if opening the dumpf failed. ISTM that
setting autoflush should be in an else arm. Hence i would rephrase it
like attached, fwiw.

And in davis_read() i'm not convinced that you handle sysread() errors
properly which might return undef. For clarity i would rephrase it like
in the attached, again fwiw. Both untested, but you get the idea..

cheers,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-fetchdavis-Fix-error-on-failing-to-open-logfile.patch
Type: text/x-patch
Size: 1094 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20191215/00b58d0e/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-davis_read-robustify.patch
Type: text/x-patch
Size: 1123 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20191215/00b58d0e/attachment-0001.bin>


More information about the busybox mailing list