summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-08-03 08:04:11 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:57:45 -0500
commitbff2c7a5780433d815eea7a3d735ac562a0dbdf9 (patch)
tree81daf79a061a33afb9eb48da9762d1b9de9c1d99 /source4/libcli
parent682a02d7d41b7653e5c9e90e65d290a8314045f0 (diff)
downloadsamba-bff2c7a5780433d815eea7a3d735ac562a0dbdf9.tar.gz
samba-bff2c7a5780433d815eea7a3d735ac562a0dbdf9.tar.bz2
samba-bff2c7a5780433d815eea7a3d735ac562a0dbdf9.zip
r1635: when a transport dies, setup errors for all pending sends and recvs, plus disalllow any more sends
(This used to be commit 326fdc8c9d2848c6c08a49e34c72430fe0116d23)
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/raw/clitransport.c29
1 files changed, 29 insertions, 0 deletions
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 *);