* Stray nulls when reading from AF_UNIX sockets
@ 2007-09-06 15:48 Anders Blomdell
2007-09-06 16:09 ` Randy Dunlap
2007-09-06 19:23 ` David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Anders Blomdell @ 2007-09-06 15:48 UTC (permalink / raw)
To: linux-kernel
Hi,
With recent kernels (2.6.22.x), we are experiencing that random null characters
are read by our mySQL server (i.e. the number of bytes read by the server is
larger than the number of bytes written). I'm currently investigating the
problem (that occurs every 1-35 hours on a loaded system). A current suspect is
the following code in net/unix/af_unix.c:
static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
struct msghdr *msg, size_t size,
int flags)
{
...
return copied ? : err;
}
Shouldn't this read:
return copied ? copied : err;
Or am I missing something?
Please CC me personally.
Regards
Anders Blomdell
--
Anders Blomdell Email: anders.blomdell@control.lth.se
Department of Automatic Control
Lund University Phone: +46 46 222 4625
P.O. Box 118 Fax: +46 46 138118
SE-221 00 Lund, Sweden
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Stray nulls when reading from AF_UNIX sockets
2007-09-06 15:48 Stray nulls when reading from AF_UNIX sockets Anders Blomdell
@ 2007-09-06 16:09 ` Randy Dunlap
2007-09-06 19:23 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: Randy Dunlap @ 2007-09-06 16:09 UTC (permalink / raw)
To: Anders Blomdell; +Cc: linux-kernel
On Thu, 06 Sep 2007 17:48:07 +0200 Anders Blomdell wrote:
> Hi,
>
> With recent kernels (2.6.22.x), we are experiencing that random null characters
> are read by our mySQL server (i.e. the number of bytes read by the server is
> larger than the number of bytes written). I'm currently investigating the
> problem (that occurs every 1-35 hours on a loaded system). A current suspect is
> the following code in net/unix/af_unix.c:
>
> static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
> struct msghdr *msg, size_t size,
> int flags)
> {
> ...
> return copied ? : err;
> }
>
> Shouldn't this read:
>
> return copied ? copied : err;
>
> Or am I missing something?
>
> Please CC me personally.
It's (?:) a gcc extension. See
http://gcc.gnu.org/onlinedocs/gcc-4.2.1/gcc/Conditionals.html#Conditionals
---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Stray nulls when reading from AF_UNIX sockets
2007-09-06 15:48 Stray nulls when reading from AF_UNIX sockets Anders Blomdell
2007-09-06 16:09 ` Randy Dunlap
@ 2007-09-06 19:23 ` David Miller
2007-09-07 11:52 ` Jan Engelhardt
1 sibling, 1 reply; 4+ messages in thread
From: David Miller @ 2007-09-06 19:23 UTC (permalink / raw)
To: anders.blomdell; +Cc: linux-kernel
From: Anders Blomdell <anders.blomdell@control.lth.se>
Date: Thu, 06 Sep 2007 17:48:07 +0200
> return copied ? : err;
> }
>
> Shouldn't this read:
>
> return copied ? copied : err;
>
> Or am I missing something?
These two statements are equivalent, the first version is
a shorthand allowed by gcc.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Stray nulls when reading from AF_UNIX sockets
2007-09-06 19:23 ` David Miller
@ 2007-09-07 11:52 ` Jan Engelhardt
0 siblings, 0 replies; 4+ messages in thread
From: Jan Engelhardt @ 2007-09-07 11:52 UTC (permalink / raw)
To: David Miller; +Cc: anders.blomdell, linux-kernel
On Sep 6 2007 12:23, David Miller wrote:
>> return copied ? : err;
>> }
>>
>> Shouldn't this read:
>>
>> return copied ? copied : err;
>>
>> Or am I missing something?
>
>These two statements are equivalent, the first version is
>a shorthand allowed by gcc.
Not only that. With x?x:z, x is evaluated twice,
while with x?:z, x is only evaluated once. That's for stuff when you
want to, say [dumb example follows],
size_t my_read(..) {
return read(..) ? : -1
}
and the only other way would be to use a temporary,
size_t my_read(..) {
size_t x = read(..);
return x ? x : -1;
}
gcc should be smart enough to also do optimization in the second case..
Jan
--
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-09-07 11:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-06 15:48 Stray nulls when reading from AF_UNIX sockets Anders Blomdell
2007-09-06 16:09 ` Randy Dunlap
2007-09-06 19:23 ` David Miller
2007-09-07 11:52 ` Jan Engelhardt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.