This is the mail archive of the ecos-discuss@sources.redhat.com 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: simultaneous socket write/close causes panic?


Grant Edwards <grante@visi.com> writes:

> On Tue, Oct 29, 2002 at 07:38:22AM -0700, Gary Thomas wrote:
> 
> > > > Correct me if I'm wrong (because I might be), but isn't this
> > > > inherently a race condition in the first place?  These seems
> > > > like an application programmer error to me, not an error of
> > > > eCos.
> > > 
> > > It should not cause a panic. Either the write should succeed,
> > > or it should return an err code saying the file is closed.
> > > These operations should be atomic with respect to each other.
> > 
> > I agree, which is why I said that it would be nice to see if it
> > still happens with the new stack.  Spending any time/effort debugging
> > the old stack is wasteful (IMO).
> 
> The customer reported that in their "normal" app it only
> happened once every few days.  They created a special stress
> test app where one thread streamed data out a socket and
> another thread closed the socket at random intervals.  They
> reported that it would happen about once an hour or so.
> 
> I don't have their "stress test" code.  
> 
> Someday, in my spare time, I'll build an eCos binary with the
> new stack and see if they have time to test it.
> 

I take it from this that they are using the old stack. Which API are
they using -- the FILEIO package or the API that comes with the stack?
The locking and reference counting in the FILEIO package should either
delay the close() until after the write() completes, or cause the
write() to get an EBADF error, depending on the order in which they
happen. The stack's own API is less robust in this respect. The new
stack only uses the FILEIO API, so it should be safer.

However, this only fixes this particular problem, it does not solve
races in other concurrent operations.

-- 
Nick Garnett - eCos Kernel Architect
http://www.eCosCentric.com/

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


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