summaryrefslogtreecommitdiff
path: root/source4/librpc/rpc
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-10-28 04:00:43 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:04:52 -0500
commitc6888da1487ab301292c3d4d05d0464833f3ce57 (patch)
tree35660282f621edb23885c40bfc4634489def3d6d /source4/librpc/rpc
parent9d1e2b29ebf14beae4fc63b2cb85f4e2d1798021 (diff)
downloadsamba-c6888da1487ab301292c3d4d05d0464833f3ce57.tar.gz
samba-c6888da1487ab301292c3d4d05d0464833f3ce57.tar.bz2
samba-c6888da1487ab301292c3d4d05d0464833f3ce57.zip
r3304: changed the API to lib/socket/ a little.
The main change is to make socket_recv() take a pre-allocated buffer, rather than allocating one itself. This allows non-blocking users of this API to avoid a memcpy(). As a result our messaging code is now about 10% faster, and the ncacn_ip_tcp and ncalrpc code is also faster. The second change was to remove the unused mem_ctx argument from socket_send(). Having it there implied that memory could be allocated, which meant the caller had to worry about freeing that memory (if for example it is sending in a tight loop using the same memory context). Removing that unused argument keeps life simpler for users. (This used to be commit a16e4756cd68ca8aab4ffc59d4d9db0b6e44dbd1)
Diffstat (limited to 'source4/librpc/rpc')
-rw-r--r--source4/librpc/rpc/dcerpc_sock.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/source4/librpc/rpc/dcerpc_sock.c b/source4/librpc/rpc/dcerpc_sock.c
index fa2d565084..819d5698b1 100644
--- a/source4/librpc/rpc/dcerpc_sock.c
+++ b/source4/librpc/rpc/dcerpc_sock.c
@@ -83,7 +83,7 @@ static void sock_process_send(struct dcerpc_pipe *p)
struct sock_blob *blob = sock->pending_send;
NTSTATUS status;
size_t sent;
- status = socket_send(sock->sock, blob, &blob->data, &sent, 0);
+ status = socket_send(sock->sock, &blob->data, &sent, 0);
if (NT_STATUS_IS_ERR(status)) {
sock_dead(p, NT_STATUS_NET_WRITE_FAULT);
break;
@@ -116,7 +116,7 @@ static void sock_process_recv(struct dcerpc_pipe *p)
{
struct sock_private *sock = p->transport.private;
NTSTATUS status;
- DATA_BLOB blob;
+ size_t nread;
if (sock->recv.data.data == NULL) {
sock->recv.data = data_blob_talloc(sock, NULL, MIN_HDR_SIZE);
@@ -126,19 +126,19 @@ static void sock_process_recv(struct dcerpc_pipe *p)
if (sock->recv.received < MIN_HDR_SIZE) {
uint32_t frag_length;
- status = socket_recv(sock->sock, sock, &blob, MIN_HDR_SIZE - sock->recv.received, 0);
+ status = socket_recv(sock->sock,
+ sock->recv.data.data + sock->recv.received,
+ MIN_HDR_SIZE - sock->recv.received,
+ &nread, 0);
if (NT_STATUS_IS_ERR(status)) {
sock_dead(p, NT_STATUS_NET_WRITE_FAULT);
return;
}
- if (blob.length == 0) {
+ if (nread == 0) {
return;
}
- memcpy(sock->recv.data.data + sock->recv.received,
- blob.data, blob.length);
- sock->recv.received += blob.length;
- talloc_free(blob.data);
+ sock->recv.received += nread;
if (sock->recv.received != MIN_HDR_SIZE) {
return;
@@ -155,18 +155,18 @@ static void sock_process_recv(struct dcerpc_pipe *p)
}
/* read in the rest of the packet */
- status = socket_recv(sock->sock, sock, &blob, sock->recv.data.length - sock->recv.received, 0);
+ status = socket_recv(sock->sock,
+ sock->recv.data.data + sock->recv.received,
+ sock->recv.data.length - sock->recv.received,
+ &nread, 0);
if (NT_STATUS_IS_ERR(status)) {
sock_dead(p, NT_STATUS_NET_WRITE_FAULT);
return;
}
- if (blob.length == 0) {
+ if (nread == 0) {
return;
}
- memcpy(sock->recv.data.data + sock->recv.received,
- blob.data, blob.length);
- sock->recv.received += blob.length;
- talloc_free(blob.data);
+ sock->recv.received += nread;
if (sock->recv.received != sock->recv.data.length) {
return;