Damjan Jovanovic wrote:
On 9/22/06, Robert Shearman rob@codeweavers.com wrote:
Using WSAEVENTs is an interesting approach, but I'd rather see Unix sockets being used with a thread that select's on the socket and sets a Win32 event instead. Also, I think this amount of nesting is confusing and could be avoided.
Are you working on that approach, or am I free to try it?
No, I am not working on that so you are free to try it. (You would be free to try it anyway, since your implementation might be better than an implementation I was working on.)
static int rpcrt4_conn_tcp_read(RpcConnection *Connection, void *buffer, unsigned int count) { RpcConnection_tcp *tcpc = (RpcConnection_tcp *) Connection;
- int r = recv(tcpc->sock, buffer, count, MSG_WAITALL);
- TRACE("%d %p %u -> %d\n", tcpc->sock, buffer, count, r);
- return r;
- int rtotal = 0;
- int r = 0;
- do
- {
- r = recv(tcpc->sock, buffer, count, 0);
- if (r > 0)
rtotal += r;
- else
break;
- } while (rtotal < count);
- if (r < 0)
- rtotal = r;
- TRACE("%d %p %u -> %d\n", tcpc->sock, buffer, count, rtotal);
- return rtotal;
}
Hmmm. Is the MSG_WAITALL flag not supported in winsock? I think that should be fixed there.
It isn't supported in the native winsock either. You think too highly of winsock - remeber it was made by Microsoft ;-).
Both MSDN and dlls/ws2_32/socket.c suggest that it is supported, although only in non-blocking mode. Is that the problem?
static int rpcrt4_conn_tcp_write(RpcConnection *Connection, const void *buffer, unsigned int
count)
{ RpcConnection_tcp *tcpc = (RpcConnection_tcp *) Connection;
- int r = write(tcpc->sock, buffer, count);
- int r = send(tcpc->sock, buffer, count, 0); TRACE("%d %p %u -> %d\n", tcpc->sock, buffer, count, r); return r;
}
This is a good change. Please submit this as a separate fix.
But if we use UNIX sockets, it shouldn't matter?
Correct. This won't make any difference either way, so we should use send.