summaryrefslogtreecommitdiff
path: root/source3/rpc_client
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2010-03-25 15:51:51 +0100
committerStefan Metzmacher <metze@samba.org>2010-03-29 18:11:17 +0200
commit99664ad15460530b6fb44957b6c57823f09884bf (patch)
tree5a1afb487013b2e3ce28ccaf407100cd6d85020b /source3/rpc_client
parent4f41b53487ac9bc96c7960e8edab464558656373 (diff)
downloadsamba-99664ad15460530b6fb44957b6c57823f09884bf.tar.gz
samba-99664ad15460530b6fb44957b6c57823f09884bf.tar.bz2
samba-99664ad15460530b6fb44957b6c57823f09884bf.zip
s3:rpc_client: add set_timeout hook to rpc_cli_transport
metze
Diffstat (limited to 'source3/rpc_client')
-rw-r--r--source3/rpc_client/cli_pipe.c25
-rw-r--r--source3/rpc_client/rpc_transport_np.c19
-rw-r--r--source3/rpc_client/rpc_transport_smbd.c19
-rw-r--r--source3/rpc_client/rpc_transport_sock.c20
4 files changed, 63 insertions, 20 deletions
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index 551516bb5b..5ee6dcb2b5 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -3067,30 +3067,15 @@ NTSTATUS rpc_pipe_bind(struct rpc_pipe_client *cli,
unsigned int rpccli_set_timeout(struct rpc_pipe_client *rpc_cli,
unsigned int timeout)
{
- struct cli_state *cli;
-
- if (rpc_cli->transport->transport == NCACN_NP) {
- cli = rpc_pipe_np_smb_conn(rpc_cli);
- if (cli == NULL) {
- return 0;
- }
- return cli_set_timeout(cli, timeout);
- }
-
- if (rpc_cli->transport->transport == NCACN_IP_TCP ||
- rpc_cli->transport->transport == NCALRPC) {
- return rpccli_set_sock_timeout(rpc_cli, timeout);
+ if (rpc_cli->transport == NULL) {
+ return 0;
}
- if (rpc_cli->transport->transport == NCACN_INTERNAL) {
- cli = rpc_pipe_smbd_smb_conn(rpc_cli);
- if (!cli) {
- return 0;
- }
- return cli_set_timeout(cli, timeout);
+ if (rpc_cli->transport->set_timeout == NULL) {
+ return 0;
}
- return 0;
+ return rpc_cli->transport->set_timeout(rpc_cli->transport->priv, timeout);
}
bool rpccli_is_connected(struct rpc_pipe_client *rpc_cli)
diff --git a/source3/rpc_client/rpc_transport_np.c b/source3/rpc_client/rpc_transport_np.c
index ab67fc550e..cf659da592 100644
--- a/source3/rpc_client/rpc_transport_np.c
+++ b/source3/rpc_client/rpc_transport_np.c
@@ -47,6 +47,24 @@ static bool rpc_np_is_connected(void *priv)
return true;
}
+static unsigned int rpc_np_set_timeout(void *priv, unsigned int timeout)
+{
+ struct rpc_transport_np_state *np_transport = talloc_get_type_abort(
+ priv, struct rpc_transport_np_state);
+ bool ok;
+
+ if (np_transport->cli == NULL) {
+ return false;
+ }
+
+ ok = rpc_np_is_connected(np_transport);
+ if (!ok) {
+ return 0;
+ }
+
+ return cli_set_timeout(np_transport->cli, timeout);
+}
+
static int rpc_transport_np_state_destructor(struct rpc_transport_np_state *s)
{
if (!rpc_np_is_connected(s)) {
@@ -447,6 +465,7 @@ NTSTATUS rpc_transport_np_init_recv(struct tevent_req *req,
state->transport->trans_send = rpc_np_trans_send;
state->transport->trans_recv = rpc_np_trans_recv;
state->transport->is_connected = rpc_np_is_connected;
+ state->transport->set_timeout = rpc_np_set_timeout;
*presult = talloc_move(mem_ctx, &state->transport);
return NT_STATUS_OK;
diff --git a/source3/rpc_client/rpc_transport_smbd.c b/source3/rpc_client/rpc_transport_smbd.c
index 47c426f120..690314c192 100644
--- a/source3/rpc_client/rpc_transport_smbd.c
+++ b/source3/rpc_client/rpc_transport_smbd.c
@@ -464,6 +464,24 @@ static bool rpc_smbd_is_connected(void *priv)
return true;
}
+static unsigned int rpc_smbd_set_timeout(void *priv, unsigned int timeout)
+{
+ struct rpc_transport_smbd_state *transp = talloc_get_type_abort(
+ priv, struct rpc_transport_smbd_state);
+ bool ok;
+
+ ok = rpc_smbd_is_connected(transp);
+ if (!ok) {
+ return 0;
+ }
+
+ if (transp->sub_transp->set_timeout == NULL) {
+ return 0;
+ }
+
+ return transp->sub_transp->set_timeout(transp->sub_transp->priv, timeout);
+}
+
struct rpc_smbd_write_state {
struct rpc_transport_smbd_state *transp;
ssize_t written;
@@ -709,6 +727,7 @@ NTSTATUS rpc_transport_smbd_init_recv(struct tevent_req *req,
state->transport->trans_send = NULL;
state->transport->trans_recv = NULL;
state->transport->is_connected = rpc_smbd_is_connected;
+ state->transport->set_timeout = rpc_smbd_set_timeout;
*presult = talloc_move(mem_ctx, &state->transport);
return NT_STATUS_OK;
diff --git a/source3/rpc_client/rpc_transport_sock.c b/source3/rpc_client/rpc_transport_sock.c
index 5132504a85..1c49412d20 100644
--- a/source3/rpc_client/rpc_transport_sock.c
+++ b/source3/rpc_client/rpc_transport_sock.c
@@ -53,6 +53,25 @@ static bool rpc_sock_is_connected(void *priv)
return true;
}
+static unsigned int rpc_sock_set_timeout(void *priv, unsigned int timeout)
+{
+ struct rpc_transport_sock_state *sock_transp = talloc_get_type_abort(
+ priv, struct rpc_transport_sock_state);
+ int orig_timeout;
+ bool ok;
+
+ ok = rpc_sock_is_connected(sock_transp);
+ if (!ok) {
+ return 0;
+ }
+
+ orig_timeout = sock_transp->timeout;
+
+ sock_transp->timeout = timeout;
+
+ return orig_timeout;
+}
+
struct rpc_sock_read_state {
struct rpc_transport_sock_state *transp;
ssize_t received;
@@ -241,6 +260,7 @@ NTSTATUS rpc_transport_sock_init(TALLOC_CTX *mem_ctx, int fd,
result->read_send = rpc_sock_read_send;
result->read_recv = rpc_sock_read_recv;
result->is_connected = rpc_sock_is_connected;
+ result->set_timeout = rpc_sock_set_timeout;
*presult = result;
return NT_STATUS_OK;