You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by Manjula Peiris <ma...@wso2.com> on 2008/06/20 07:57:25 UTC

writting the request buffer to the socket at client side

Hi devs,

In src/core/transport/http/sender/http_client.c loop segment starting
from line 370 is responsible for writing the request buffer to the
socket at the client side. 

while (written < client->req_body_size)
{
	written = axutil_stream_write(client->data_stream, env,
                                              client->req_body,
                                              client->req_body_size);
        if (-1 == written)
        {
        	status = AXIS2_FAILURE;
                break;
        }
 }

As you can see this logic only works for one iteration. If the loop
condition holds after the first iteration, during second iteration
writing to the socket will start from the beginning of the buffer. Which
is wrong. I think we didn't encounter this because all the time this may
had gone through just one iteration, which we can't guarantee every
time. I think following piece of code should be the correct logic.

int len = 0;
written = 0;

while (written < client->req_body_size)
{
	len = 0;
        len = axutil_stream_write(client->data_stream, env,
              client->req_body + written,
              client->req_body_size - written);

        if (-1 == len)
        {
        	status = AXIS2_FAILURE;
                break;
        }
        else
        {
        	written += len;
        }
}

WDYT ?

Thanks,
-Manjula.



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-dev-help@ws.apache.org


Re: writting the request buffer to the socket at client side

Posted by Supun Kamburugamuva <su...@gmail.com>.
Your changes are not going to break the current functionality and implements
support for the rare cases as well. So I don't seen an objection for this
code not to go the trunk.

Supun,

On Thu, Jun 19, 2008 at 10:57 PM, Manjula Peiris <ma...@wso2.com> wrote:

> Hi devs,
>
> In src/core/transport/http/sender/http_client.c loop segment starting
> from line 370 is responsible for writing the request buffer to the
> socket at the client side.
>
> while (written < client->req_body_size)
> {
>        written = axutil_stream_write(client->data_stream, env,
>                                              client->req_body,
>                                              client->req_body_size);
>        if (-1 == written)
>        {
>                status = AXIS2_FAILURE;
>                break;
>        }
>  }
>
> As you can see this logic only works for one iteration. If the loop
> condition holds after the first iteration, during second iteration
> writing to the socket will start from the beginning of the buffer. Which
> is wrong. I think we didn't encounter this because all the time this may
> had gone through just one iteration, which we can't guarantee every
> time. I think following piece of code should be the correct logic.
>
> int len = 0;
> written = 0;
>
> while (written < client->req_body_size)
> {
>        len = 0;
>        len = axutil_stream_write(client->data_stream, env,
>              client->req_body + written,
>              client->req_body_size - written);
>
>        if (-1 == len)
>        {
>                status = AXIS2_FAILURE;
>                break;
>        }
>        else
>        {
>                written += len;
>        }
> }
>
> WDYT ?
>
> Thanks,
> -Manjula.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-c-dev-help@ws.apache.org
>
>