[En-Nut-Discussion] rs232d: closing socket while other thread is write blocked on socket

Henrik Maier hmnews at proconx.com
Mon Nov 30 00:10:29 CET 2009


If Harald agrees as well it should be changed. I am sure some people build
their apps based on that example and wonder why its crashing every now and
then for no obvious reason and all they did is followed an example.

Henrik

> -----Original Message-----
> From: en-nut-discussion-bounces at egnite.de [mailto:en-nut-discussion-
> bounces at egnite.de] On Behalf Of Ole Reinhardt
> Sent: Monday, 30 November 2009 5:03 AM
> To: Ethernut User Chat (English)
> Subject: Re: [En-Nut-Discussion] rs232d: closing socket while other
> thread is write blocked on socket
> 
> Hi Henrik,
> 
> > It came to my attention that the rs232d.c demo actually closes the
> socket
> > while the other thread could still be write blocked on it. In that
> scenario
> > the socket is destroyed while being used.
> >
> > For example Receiver() is blocked in the fwrite() call while main()
> returns
> > from StreamCopy() due to connection break down and calls fclose().
> >
> > Shouldn't in such a use case fwrite and fclose be synchronised by
> mutexes?
> 
> Indeed, you are right. I would say that a mutex is needed here.
> Everywhere where a file descriptor or any other resource is shared by
> two or more threads a mutex should be used.
> 
> Bye,
> 
> Ole
> 
> --
> 
> Thermotemp GmbH, Embedded-IT
> 
> Embedded Hard-/ Software and Open Source Development,
> Integration and Consulting
> 
> Geschäftsstelle Siegen - Steinstraße 67 - D-57072 Siegen -
> tel +49 (0)271 5513597, +49 (0)271-73681 - fax +49 (0)271 736 97
> 
> Hauptsitz - Hademarscher Weg 7 - 13503 Berlin
> Tel +49 (0)30 4315205 - Fax +49 (0)30 43665002
> Geschäftsführer: Jörg Friedrichs, Ole Reinhardt
> Handelsregister Berlin Charlottenburg HRB 45978 UstID DE 156329280
> 
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion




More information about the En-Nut-Discussion mailing list