struct tstream_smbXcli_np *cli_nps;
};
-static void tstream_smbXcli_np_close_free(struct tevent_req *subreq);
-
static int tstream_smbXcli_np_destructor(struct tstream_smbXcli_np *cli_nps)
{
- struct tevent_context *ev;
- struct tevent_req *subreq;
+ NTSTATUS status;
if (cli_nps->conn_ref != NULL) {
cli_nps->conn_ref->cli_nps = NULL;
}
/*
+ * TODO: do not use a sync call with a destructor!!!
+ *
* This only happens, if a caller does talloc_free(),
* while the everything was still ok.
*
* never be called.
*
* We use a maximun timeout of 1 second == 1000 msec.
- *
- * We allocate the close request under cli_nps->tcon,
- * which means that the close will arrive on the
- * server as long as the tcon, session and connection
- * is still valid. At this we don't care about any failures.
*/
-
cli_nps->timeout = MIN(cli_nps->timeout, 1000);
- ev = samba_tevent_context_init(cli_nps->tcon);
- if (ev == NULL) {
- return 0;
- }
-
if (cli_nps->is_smb1) {
- subreq = smb1cli_close_send(ev, ev, cli_nps->conn,
- cli_nps->timeout,
- cli_nps->pid,
- cli_nps->tcon,
- cli_nps->session,
- cli_nps->fnum, UINT32_MAX);
+ status = smb1cli_close(cli_nps->conn,
+ cli_nps->timeout,
+ cli_nps->pid,
+ cli_nps->tcon,
+ cli_nps->session,
+ cli_nps->fnum, UINT32_MAX);
} else {
- subreq = smb2cli_close_send(ev, ev, cli_nps->conn,
- cli_nps->timeout,
- cli_nps->session,
- cli_nps->tcon,
- 0, /* flags */
- cli_nps->fid_persistent,
- cli_nps->fid_volatile);
+ status = smb2cli_close(cli_nps->conn,
+ cli_nps->timeout,
+ cli_nps->session,
+ cli_nps->tcon,
+ 0, /* flags */
+ cli_nps->fid_persistent,
+ cli_nps->fid_volatile);
}
- if (subreq == NULL) {
- TALLOC_FREE(ev);
- return 0;
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("tstream_smbXcli_np_destructor: cli_close "
+ "failed on pipe %s. Error was %s\n",
+ cli_nps->npipe, nt_errstr(status)));
}
- tevent_req_set_callback(subreq, tstream_smbXcli_np_close_free, ev);
-
- /*
- * Make sure we don't send any requests anymore.
- */
- cli_nps->conn = NULL;
-
/*
* We can't do much on failure
*/
return 0;
}
-static void tstream_smbXcli_np_close_free(struct tevent_req *subreq)
-{
- struct tevent_context *ev =
- tevent_req_callback_data(subreq,
- struct tevent_context);
-
- /*
- * We don't care about the result
- */
- TALLOC_FREE(subreq);
-
- /*
- * We don't need the event context anymore.
- */
- TALLOC_FREE(ev);
-}
-
static int tstream_smbXcli_np_ref_destructor(struct tstream_smbXcli_np_ref *ref)
{
if (ref->cli_nps == NULL) {