[PATCHES] messaging iov / recvfrom

Volker Lendecke Volker.Lendecke at SerNet.DE
Tue May 27 02:27:52 MDT 2014


On Tue, May 27, 2014 at 09:51:10AM +0200, Andreas Schneider wrote:
> On Monday 26 May 2014 17:07:44 Michael Adam wrote:
> > Oops, there was a bug in the first patch.
> > Sorry for posting prematurely...
> > Attaching a fixed version.
> 
> > diff --git a/source3/lib/unix_msg/unix_msg.c
> > b/source3/lib/unix_msg/unix_msg.c index 956e3a3..bcabd28 100644
> > --- a/source3/lib/unix_msg/unix_msg.c
> > +++ b/source3/lib/unix_msg/unix_msg.c
> > @@ -233,8 +233,22 @@ static void unix_dgram_recv_handler(struct poll_watch
> > *w, int fd, short events,> 
> >  {
> >  
> >  	struct unix_dgram_ctx *ctx = (struct unix_dgram_ctx *)private_data;
> >  	ssize_t received;
> > 
> > +	struct msghdr msg;
> > +	struct iovec iov;
> > +
> > +	iov = (struct iovec) {
> > +		.iov_base = (void *)ctx->recv_buf,
> > +		.iov_len = ctx->max_msg,
> > +	};
> > +
> 
> Please use ZERO_STRUCT(msg) here!

Why? This adds an additional call to memset. This construct
zeros out everything that is not explicitly initialized
anyway. So it is equivalent to a ZERO_STRUCT(msg) and two
explicit assignments and gives the compiler the chance to
use more efficient instructions.

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de


More information about the samba-technical mailing list