Hi Bernhard,

On Sun, Apr 10, 2022 at 5:29 PM Bernhard Reutner-Fischer
<rep.dot....@gmail.com> wrote:
> > > Also seed_dir et al are only used in main so i'd move them there and
> > > not have them static. Doesn't make much difference though.
> >
> > seed_dir isn't only used from main. It doesn't impact binary size.
>
> I'd argue that it should only be used from main.
> There's no benefit to have additional code dealing with the dir if what
> you really want and operate on is the respective seed file, no?
>
> What is that fsync(dfd) supposed to achieve? I'd remove all this, i
> don't really see why it's needed.

When you tell me to remove things just on the basis of not
understanding it, you greatly diminish your credibility in this
discussion, maintainer or not. It's one thing to ask why it's needed.
It's another thing to say remove it because you don't know why. So
I'll pretend you only asked the question, but didn't also issue that
removal request. :)

The reason the fsync(dfd) is there is so that the file is removed from
the file system after we read the file, but importantly before we
seed, so that the same seed is never credited twice. Removing
fsync()ing, like removing flock()ing is highly problematic. I'm not
going to remove that.

> > Sometimes it's tmpfs, sometimes it isn't. And sometimes programs get
> > oom'd mid-execution and can't cleanup files. O_EXCL is not the right
> > way of doing this.
>
> Yea, so if this is supposed to be run even after the initial invocation
> at boot, i.e. anytime via timers, then yes.
> The lockfile is conceptually not much different than a pidfile i
> suppose. But there is probably no benefit in creating a pidfile and
> locking that as opposed to what you manually do now. Hmm.

Pids are racey. A lock file is a lock on the exact resource we want.

> Btw, you seem to be touching errno a lot and you do that in addition to
> ret.
> Maybe this can be simplified a little bit?

In v4 I went back to making the helpers act like libc functions, so I
could use perror, resulting in less code size. And I checked in IDA
that this indeed does result in less code size. The reason is that all
those helpers except one get inlined by the compiler, and then the
errno handling elides. This also has the benefit of making the code
easier to read, because there's a consistent error path.

Anyway, have a look at v4. I think based on the above, it's mergeable?

Jason
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to