public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Bernd Edlinger <bernd.edlinger@hotmail.de>
To: <henry.mahler@timedomain.com>, <ecos-discuss@ecos.sourceware.org>
Subject: RE: [ECOS] BSD socket stall
Date: Fri, 14 Sep 2012 08:21:00 -0000	[thread overview]
Message-ID: <BAY146-W9C5D5C6B2F90532E65A51E4900@phx.gbl> (raw)
In-Reply-To: <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

  parent reply	other threads:[~2012-09-14  8:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-08 17:43 henry mahler
2012-09-13 13:14 ` Bernd Edlinger
2012-09-13 21:02   ` Lambrecht Jürgen
     [not found] ` <BAY146-W727B35516EEA4449F4ECCE4910@phx.gbl>
     [not found]   ` <CAH0LssZ1+fGEESuzmZuRn0G+8D+yOcSaXu8ZBXruR36OUzdQxQ@mail.gmail.com>
2012-09-14  8:21     ` Bernd Edlinger [this message]
2012-09-14 14:19       ` Bernd Edlinger
     [not found]         ` <CAH0LssbJX2f5U6wtxe+KjbqPZXDTJqPm8Awua6KC+o5oOxQx8Q@mail.gmail.com>
2012-09-15 17:44           ` Bernd Edlinger
2012-09-14  8:21     ` Bernd Edlinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BAY146-W9C5D5C6B2F90532E65A51E4900@phx.gbl \
    --to=bernd.edlinger@hotmail.de \
    --cc=ecos-discuss@ecos.sourceware.org \
    --cc=henry.mahler@timedomain.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).