From bff2c7a5780433d815eea7a3d735ac562a0dbdf9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 3 Aug 2004 08:04:11 +0000 Subject: r1635: when a transport dies, setup errors for all pending sends and recvs, plus disalllow any more sends (This used to be commit 326fdc8c9d2848c6c08a49e34c72430fe0116d23) --- source4/libcli/raw/clitransport.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'source4/libcli/raw/clitransport.c') diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c index a33cc5e8f6..3b3c10ed01 100644 --- a/source4/libcli/raw/clitransport.c +++ b/source4/libcli/raw/clitransport.c @@ -98,6 +98,28 @@ void cli_transport_close(struct cli_transport *transport) void cli_transport_dead(struct cli_transport *transport) { cli_sock_dead(transport->socket); + + /* all pending sends become errors */ + while (transport->pending_send) { + struct cli_request *req = transport->pending_send; + req->state = CLI_REQUEST_ERROR; + req->status = NT_STATUS_NET_WRITE_FAULT; + DLIST_REMOVE(transport->pending_send, req); + if (req->async.fn) { + req->async.fn(req); + } + } + + /* as do all pending receives */ + while (transport->pending_recv) { + struct cli_request *req = transport->pending_recv; + req->state = CLI_REQUEST_ERROR; + req->status = NT_STATUS_NET_WRITE_FAULT; + DLIST_REMOVE(transport->pending_recv, req); + if (req->async.fn) { + req->async.fn(req); + } + } } @@ -478,6 +500,13 @@ BOOL cli_transport_process(struct cli_transport *transport) */ void cli_transport_send(struct cli_request *req) { + /* check if the transport is dead */ + if (req->transport->socket->fd == -1) { + req->state = CLI_REQUEST_ERROR; + req->status = NT_STATUS_NET_WRITE_FAULT; + return; + } + /* put it on the outgoing socket queue */ req->state = CLI_REQUEST_SEND; DLIST_ADD_END(req->transport->pending_send, req, struct cli_request *); -- cgit