Beispiel #1
0
/*
  terminate a task service
*/
void task_server_terminate(struct task_server *task, const char *reason, bool fatal)
{
	struct tevent_context *event_ctx = task->event_ctx;
	const struct model_ops *model_ops = task->model_ops;
	DEBUG(0,("task_server_terminate: [%s]\n", reason));

	if (fatal && task->msg_ctx != NULL) {
		struct dcerpc_binding_handle *irpc_handle;
		struct samba_terminate r;

		irpc_handle = irpc_binding_handle_by_name(task, task->msg_ctx,
							  "samba", &ndr_table_irpc);
		if (irpc_handle != NULL) {
			/* Note: this makes use of nested event loops... */
			dcerpc_binding_handle_set_sync_ev(irpc_handle, event_ctx);
			r.in.reason = reason;
			dcerpc_samba_terminate_r(irpc_handle, task, &r);
		}
	}

	imessaging_cleanup(task->msg_ctx);

	model_ops->terminate(event_ctx, task->lp_ctx, reason);
	
	/* don't free this above, it might contain the 'reason' being printed */
	talloc_free(task);
}
Beispiel #2
0
/*
  close the socket and shutdown a stream_connection
*/
void stream_terminate_connection(struct stream_connection *srv_conn, const char *reason)
{
	struct tevent_context *event_ctx = srv_conn->event.ctx;
	const struct model_ops *model_ops = srv_conn->model_ops;

	if (!reason) reason = "unknown reason";

	DEBUG(3,("Terminating connection - '%s'\n", reason));

	srv_conn->terminate = reason;

	if (srv_conn->processing) {
		/* 
		 * if we're currently inside the stream_io_handler(),
		 * defer the termination to the end of stream_io_hendler()
		 *
		 * and we don't want to read or write to the connection...
		 */
		tevent_fd_set_flags(srv_conn->event.fde, 0);
		return;
	}

	talloc_free(srv_conn->event.fde);
	srv_conn->event.fde = NULL;
	imessaging_cleanup(srv_conn->msg_ctx);
	model_ops->terminate(event_ctx, srv_conn->lp_ctx, reason);
	talloc_free(srv_conn);
}