Pedro Alves
2006-09-11 21:47:23 UTC
Hi all,
In librapi2/src/invoke.c, at:
static HRESULT CeRapiInvokeBuffers(...)
{
(...)
/* XXX: is this really the right way? */
shutdown(synce_socket_get_descriptor(context->socket), SHUT_WR);
if ( !rapi_buffer_recv(context->recv_buffer, context->socket) ) //
******* This fails on me on current trunk.
{
synce_error("rapi_buffer_recv failed");
hr = E_FAIL;
goto exit;
}
(...)
}
The rapi_buffer_recv fails on me on current trunk, because
shutdown(SHUT_WR) was
called, which I guess sends a FIN, that ends up returning
EVENT_READ|EVENT_ERROR,
from the poll inside synce_socket_wait. The EVENT_ERROR is normal in
this case AFAIK,
and the data associated with the EVENT_READ is valid data.
librapi2/src/support/rapi_buffer.c:
bool rapi_buffer_recv(RapiBuffer* buffer, SynceSocket* socket)
{
uint32_t size_le = 0;
size_t size = 0;
unsigned char* data = NULL;
short events = EVENT_READ;
if (!synce_socket_wait(socket, 15, &events))
{
rapi_buffer_error("Failed to wait for event");
goto fail;
}
if (events != EVENT_READ) // ******** wrong, valid data discarded.
{
rapi_buffer_error("Nothing to read. Events = %i", events);
goto fail;
}
(...)
}
The attached proposed patches fixes this, and my app is now returning
correct data
from CeRapiInvoke block/buffer mode, whatever it is called these days.
Cheers,
Pedro Alves
In librapi2/src/invoke.c, at:
static HRESULT CeRapiInvokeBuffers(...)
{
(...)
/* XXX: is this really the right way? */
shutdown(synce_socket_get_descriptor(context->socket), SHUT_WR);
if ( !rapi_buffer_recv(context->recv_buffer, context->socket) ) //
******* This fails on me on current trunk.
{
synce_error("rapi_buffer_recv failed");
hr = E_FAIL;
goto exit;
}
(...)
}
The rapi_buffer_recv fails on me on current trunk, because
shutdown(SHUT_WR) was
called, which I guess sends a FIN, that ends up returning
EVENT_READ|EVENT_ERROR,
from the poll inside synce_socket_wait. The EVENT_ERROR is normal in
this case AFAIK,
and the data associated with the EVENT_READ is valid data.
librapi2/src/support/rapi_buffer.c:
bool rapi_buffer_recv(RapiBuffer* buffer, SynceSocket* socket)
{
uint32_t size_le = 0;
size_t size = 0;
unsigned char* data = NULL;
short events = EVENT_READ;
if (!synce_socket_wait(socket, 15, &events))
{
rapi_buffer_error("Failed to wait for event");
goto fail;
}
if (events != EVENT_READ) // ******** wrong, valid data discarded.
{
rapi_buffer_error("Nothing to read. Events = %i", events);
goto fail;
}
(...)
}
The attached proposed patches fixes this, and my app is now returning
correct data
from CeRapiInvoke block/buffer mode, whatever it is called these days.
Cheers,
Pedro Alves