This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
RE: BSD socket stall
- From: Bernd Edlinger <bernd dot edlinger at hotmail dot de>
- To: <henry dot mahler at timedomain dot com>, <ecos-discuss at ecos dot sourceware dot org>
- Date: Fri, 14 Sep 2012 10:21:17 +0200
- Subject: RE: [ECOS] BSD socket stall
- References: <504b83c0.056f650a.2700.0bdd@mx.google.com>,<BAY146-W727B35516EEA4449F4ECCE4910@phx.gbl>,<CAH0LssZ1+fGEESuzmZuRn0G+8D+yOcSaXu8ZBXruR36OUzdQxQ@mail.gmail.com>
Henry,
> Hi Bernd,
>
> Thank you for the reply. Our implementation did have two threads
> sending data on one socket.
> We have changed the code so that each thread has its own socket.
>
> I did look thru the modifications for the BSD stack, but I did not see
> you the spin lock was changed to a Mutex. Is that change in the diff? A
> matter of fact I do not see where the spin lock is implemented either.
>
I did not touch that code, because I do not have too much contention in that
spin lock:
int
sb_lock(sb)
register struct sockbuf *sb;
{
int error;
while (sb->sb_flags & SB_LOCK) {
sb->sb_flags |= SB_WANT;
error = tsleep((caddr_t)&sb->sb_flags,
(sb->sb_flags & SB_NOINTR) ? PSOCK : PSOCK|PCATCH,
"sblock", 0);
if (error)
return (error);
}
sb->sb_flags |= SB_LOCK;
return (0);
}
that waits for the SB_LOCK bit to clear and set the SB_LOCK again.
what might have happened would be a priority inversion here.
however this might also be a real bug...
I am not sure at the moment, if this code might be missing
the splnet mutex?
in sosend()
error = sblock(&so->so_snd, SBLOCKWAIT(so,flags));
if (error)
goto out;
=>
s = splnet();
error = sblock(&so->so_snd, SBLOCKWAIT(so,flags));
splx(s);
if (error)
goto out;
what are the priorites of your writing threads?
and are other threads in between?
> Back to changing the code so that each thread has its own socket. Is
> there any history where a socket has problem when the socket receives
> data but no thread is reading from that socket. The socket is intened
> for transmit only but another happed to send data to that socket and
> the data was allowed to stay in the socket unread.
good point, I usually allocate 1-2 megabytes for MBUFs, but that might
not always be possible.
if you are concerned that the socket accumulates Packet Buffers,
there is a socket option SO_RCVBUF, maybe you set it to zero, then
the socket should discard any garbage that is received accidentally.
> Thanks
> Henry
>
Regards
Bernd Edlinger
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss