[PATCH 1/6] Make winbind client library thread-safe by adding context

Matthew Newton mcn4 at leicester.ac.uk
Tue Feb 24 06:17:00 MST 2015


On Tue, Feb 24, 2015 at 12:20:41PM +0100, Volker Lendecke wrote:
> On Mon, Feb 23, 2015 at 01:19:37AM +0000, Matthew Newton wrote:
> > +
> > +	ctx = malloc(sizeof(struct winbindd_context));
> > +
> > +	if (!ctx) {
> > +		return NULL;
> > +	}
> > +
> > +	ctx->winbindd_fd = -1;
> > +	ctx->is_privileged = 0;
> > +	ctx->our_pid = 0;
> 
> Maybe call calloc and just set winbindd_fd?

Ack - will update that, thanks.

> > +	if (ctx) {
> > +		free(ctx);
> > +	}
> 
> free() deals fine with a NULL pointer, so the if-statement
> is not necessary here.

Good point, thanks!


> >  
> > +/* Winbind context */
> > +
> > +struct winbindd_context {
> > +	int winbindd_fd;	/* winbind file descriptor */
> > +	bool is_privileged;	/* using the privileged socket? */
> > +	pid_t our_pid;		/* calling process pid */
> > +};
> 
> Is it possible to not expose the internals of the struct
> here? Just an anonymous
> 
> struct winbindd_context;
> 
> in winbind_client.h, and the real struct definition where
> it's needed?

OK, that sounds good - I'll move the actual definition to the top
of wb_common.c.

Thanks!

Matthew


-- 
Matthew Newton, Ph.D. <mcn4 at le.ac.uk>

Systems Specialist, Infrastructure Services,
I.T. Services, University of Leicester, Leicester LE1 7RH, United Kingdom

For IT help contact helpdesk extn. 2253, <ithelp at le.ac.uk>


More information about the samba-technical mailing list