This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: [PATCH] ada/35953: Guard against empty buffers and end-of-connection


Thomas:

| > In Read for Stream_Socket_Stream_Type, if the connection was closed by
| > the peer before all the requested data has been received, Last was set to
| > Item'First - 1 (as returned by Receive_Socket) instead of the index of the
| > latest received byte. This patch fixes this.
| 
|  From code reading I don't see that happening.

Right, it will contain First - 1, I had read too fast, not Item'First - 1.

| > It also removes network-related system calls when a Read or Write of length
| > 0 is requested. Although GNAT will not generate such calls while expanding
| > Read/Write/Input/Output attributes, the user may directly call Read and
| > Write on sockets stream types through dispatching.
|        
| This optimization looks unnecessary to me. Could you clarify the
| rationale here ?

Reading or writing 0 bytes on a socket will cost a system call. If we
are using datagrams, it will consume or send an IP packet.

As you say, this is an optimization. Why do more job when we can do
less?

| > The reason for an unsuccessful Write is also given: either "connection
| > closed by peer" or "packet too large for datagram".
| 
| There is a non-compatible change in behaviour here, with your proposed change
| an exception is raised where previously a zero result (which could be
| tested by the caller) was returned, so this change is not acceptable.

How would one test for a "zero result" in a Write, when there are no "out"
parameter (except the stream which is "in out")? What do you mean?


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