nwritten = writev_recv(subreq, &err);
TALLOC_FREE(subreq);
if (nwritten == -1) {
- if (state->cli->fd != -1) {
- close(state->cli->fd);
- state->cli->fd = -1;
- }
+ cli_state_disconnect(state->cli);
tevent_req_nterror(req, map_nt_error_from_unix(err));
return;
}
received = read_smb_recv(subreq, talloc_tos(), &inbuf, &err);
TALLOC_FREE(subreq);
if (received == -1) {
- if (cli->fd != -1) {
- close(cli->fd);
- cli->fd = -1;
- }
+ cli_state_disconnect(cli);
status = map_nt_error_from_unix(err);
goto fail;
}
DEBUG(10, ("cli_check_sign_mac failed\n"));
TALLOC_FREE(inbuf);
status = NT_STATUS_ACCESS_DENIED;
- close(cli->fd);
- cli->fd = -1;
+ cli_state_disconnect(cli);
goto fail;
}
data_blob_free(&cli->secblob);
data_blob_free(&cli->user_session_key);
- if (cli->fd != -1) {
- close(cli->fd);
- }
- cli->fd = -1;
+ cli_state_disconnect(cli);
/*
* Need to free pending first, they remove themselves