On Mon, Feb 24 2020 15:33:35 -0500, Ted Unangst wrote:
> Martin Pieuchot wrote:
> > On 24/02/20(Mon) 11:29, Lauri Tirkkonen wrote:
> > > On Mon, Feb 24 2020 10:24:53 +0100, Martin Pieuchot wrote:
> > > > On 23/02/20(Sun) 14:48, Lauri Tirkkonen wrote:
> > > > > I was working on a make jobserver implementation that uses POSIX
> > > > > semaphores as job tokens instead of a complicated socket-based 
> > > > > approach.
> > > > > Initially I used named semaphores, which work fine, except if child
> > > > > processes with less privileges need to also open the named semaphore
> > > > > (eg. 'make build' as root executing 'su build -c make'). For that 
> > > > > reason
> > > > > I wanted to use an unnamed semaphore (sem_init()) which is stored in 
> > > > > shm
> > > > > -- that way I could leave the shm fd open and pass it to children.
> > > > > 
> > > > > But unfortunately, sem_t is currently just a pointer to the opaque
> > > > > struct __sem, and sem_int() always calloc()s the storage for the 
> > > > > struct.
> > > > 
> > > > That's by design.
> > > 
> > > Ok - could you elaborate what the design is?
> > 
> > If the size of a descriptor change, because some fields are added and/or
> > removed, it doesn't matter for the application because it only manipulates
> > pointers.  That means we can change the data types without creating an ABI
> > break.
> 
> I think we are approaching the point where we can settle on fixed sized types
> now. If we want to be cautious, we can add a reserved padding field, too. But
> there are some edge cases which I think can be removed by eliminating the
> dynamic allocation paths.
> 
> > > See the followup patch -- sharing the semaphore between processes does
> > > work with it.
> > 
> > Well ignoring the `pshared' argument is questionable.  Why don't you
> > remove the "#if notyet" and start playing with the existing code and
> > try to figure out if something is missing for your use case?
> 
> I'm not sure the code in notyet will work. It was based on a misunderstanding
> I had of the requirements. Returning control of the sem_t placement to the
> application is the right approach.

Thanks for the input, and ping - is there still something about this
diff that I should fix?

-- 
Lauri Tirkkonen | lotheac @ IRCnet

Reply via email to