diff options
author | Stefan Metzmacher <metze@samba.org> | 2010-03-25 15:51:51 +0100 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2010-03-30 10:33:41 +0200 |
commit | 1bc98483c2397b8d245195a255720cdfa23c789a (patch) | |
tree | c8d65c7b8e72f9cbb3115151c4447a7a95154c3a | |
parent | 0cc696632675435f2ffae7d6db37961cf0c357f3 (diff) | |
download | samba-1bc98483c2397b8d245195a255720cdfa23c789a.tar.gz |
s3:rpc_client: add set_timeout hook to rpc_cli_transport
metze
(cherry picked from commit 99664ad15460530b6fb44957b6c57823f09884bf)
(cherry picked from commit 89164eb8363ffc0b951256578be48d37ddba46b1)
-rw-r--r-- | source3/include/client.h | 1 | ||||
-rw-r--r-- | source3/rpc_client/cli_pipe.c | 25 | ||||
-rw-r--r-- | source3/rpc_client/rpc_transport_np.c | 19 | ||||
-rw-r--r-- | source3/rpc_client/rpc_transport_smbd.c | 19 | ||||
-rw-r--r-- | source3/rpc_client/rpc_transport_sock.c | 20 |
5 files changed, 64 insertions, 20 deletions
diff --git a/source3/include/client.h b/source3/include/client.h index 252d9b3ffe8..39480d3907d 100644 --- a/source3/include/client.h +++ b/source3/include/client.h @@ -112,6 +112,7 @@ struct rpc_cli_transport { uint8_t **prdata, uint32_t *prdata_len); bool (*is_connected)(void *priv); + unsigned int (*set_timeout)(void *priv, unsigned int timeout); void *priv; }; diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c index e27f8297a86..4fc36581dbf 100644 --- a/source3/rpc_client/cli_pipe.c +++ b/source3/rpc_client/cli_pipe.c @@ -3034,30 +3034,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 0fe3d026e2a..11cfc8577e0 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 47c426f120b..690314c192f 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 5132504a85f..1c49412d209 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; |