This is the mail archive of the mailing list for the eCos project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Sockets and synch primitive question

Byron Jacquot wrote:
> I'm working on an application that includes a sporadically connected
> Ethernet server - a portable device that's used standalone most of the
> time, but is occasionally returned to the home base, where it may be
> connected for data downlaoding.  It's implemented with two threads.
> The first thread polls the "LinkOK" bit in a Cirrus CS8900a.  When the
> link is OK, it spawns the second thread, which initializes the interface
> and acts as a TCP server.
> When the LinkOK bit disappears, the first thread notifies the stack by
> clearing the IFF_UP bit.  The second thread (usually blocked in an
> accept() or read() call) gets a status of "operation interrupted" and
> cleans up its active resources.  I've got all of this working, and it's
> no longer leaking file descriptors.  
> However, getting the server thread to wake up when the interface goes
> down requires that the first thread call cyg_thread_release().  Can
> anyone explain why it requires this extra kick?  Shouldn't the ioctl
> removing IFF_UP give the stack sufficient stimulus to unblock the
> server?

I don't think it's supposed to work like you want it to.
Having the link go away, and hence the interface shut down,
is normally treated like an indeterminate pause.  At least
on my Linux desktop, if I have some TCP connection going
along and I unplug the cable, it will happily resume once
I plug the cable back in.  Only if the interface is down
a sufficiently long time (measured in minutes) does the
connection actually close down.

If you want it to be instantaneous, I think you need some
out-of-band signaling, much like you are doing now.

Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world

Before posting, please read the FAQ:
and search the list archive:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]