1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-25 06:04:04 +03:00

r1635: when a transport dies, setup errors for all pending sends and recvs, plus disalllow any more sends

This commit is contained in:
Andrew Tridgell 2004-08-03 08:04:11 +00:00 committed by Gerald (Jerry) Carter
parent 81c450b434
commit 326fdc8c9d

View File

@ -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 *);