Exemplo n.º 1
0
int
ndmca_test_data_stop (struct ndm_session *sess, ndmp9_error expect_err)
{
	struct ndmconn *	conn = sess->plumb.data;
	int			rc;

	/* close previous test if there is one */
	ndmca_test_close (sess);

	rc = ndmca_data_stop (sess);

	rc = ndmca_test_check_expect (conn, rc, expect_err);

	return rc;
}
Exemplo n.º 2
0
int
ndmca_monitor_shutdown_tape_tcp (struct ndm_session *sess)
{
	struct ndm_control_agent *ca = sess->control_acb;
	ndmp9_data_state	ds;
	ndmp9_data_halt_reason	dhr;
	int			count;
	int			finish;

	ndmalogf (sess, 0, 3, "Waiting for operation to halt");

	for (count = 0; count < 10; count++) {
		ndmca_mon_wait_for_something (sess, 2);

		if (ndmca_monitor_get_states (sess) < 0)
		    break;

#if 0
		if (count > 2)
			ndmca_mon_show_states(sess);
#endif

		ds = ca->data_state.state;

		if (ds == NDMP9_DATA_STATE_HALTED) {
		        dhr = ca->data_state.halt_reason;
			break;
		}

		if (count > 2) {
			if (ds != NDMP9_DATA_STATE_HALTED)
				ndmca_data_abort(sess);
		}
	}

	if (count >= 10) {
		ndmalogf (sess, 0, 0,
			"Operation did not halt, something wrong");
	}

	ndmalogf (sess, 0, 2, "Operation halted, stopping");

	ds = ca->data_state.state;
	dhr = ca->data_state.halt_reason;

	if (ds == NDMP9_DATA_STATE_HALTED) {
	    if (dhr == NDMP9_DATA_HALT_SUCCESSFUL) {
		/* Successful operation */
		ndmalogf (sess, 0, 0, "Operation ended OKAY");
		finish = 0;
	    } else {
		/* Questionable success */
		ndmalogf (sess, 0, 0, "Operation ended questionably");
		finish = 1;
	    }
	} else {
	    ndmalogf (sess, 0, 0, "Operation ended in failure");
	    finish = -1;
	}

	ndmca_data_stop (sess);

	for (count = 0; count < 10; count++) {
		if (ndmca_monitor_get_states(sess) < 0)
		    break;

#if 0
		if (count > 2)
			ndmca_mon_show_states(sess);
#endif

		ds = ca->data_state.state;

		if (ds == NDMP9_DATA_STATE_IDLE) {
			break;
		}
	}

	if (count >= 10) {
		ndmalogf (sess, 0, 0,
			"Operation did not stop, something wrong");
		return -1;
	}

	return finish;
}
Exemplo n.º 3
0
/*
 * Just make sure things get finished
 */
int
ndmca_monitor_shutdown (struct ndm_session *sess)
{
	struct ndm_control_agent *ca = sess->control_acb;
	ndmp9_data_state	ds;
	ndmp9_data_halt_reason	dhr;
	ndmp9_mover_state	ms;
	ndmp9_mover_halt_reason	mhr;
	int			count;
	int			finish;

	if (ca->job.tape_tcp) {
		return ndmca_monitor_shutdown_tape_tcp(sess);
	}
	ndmalogf (sess, 0, 3, "Waiting for operation to halt");

	for (count = 0; count < 10; count++) {
		ndmca_mon_wait_for_something (sess, 2);

		if (ndmca_monitor_get_states (sess) < 0)
		    break;

#if 0
		if (count > 2)
			ndmca_mon_show_states(sess);
#endif

		ds = ca->data_state.state;
		ms = ca->mover_state.state;

		if (ds == NDMP9_DATA_STATE_HALTED
		 && ms == NDMP9_MOVER_STATE_HALTED) {
		        dhr = ca->data_state.halt_reason;
			mhr = ca->mover_state.halt_reason;
			break;
		}

		if (count > 2) {
			if (ds != NDMP9_DATA_STATE_HALTED)
				ndmca_data_abort(sess);
			if (ms != NDMP9_MOVER_STATE_HALTED)
				ndmca_mover_abort(sess);
		}
	}

	if (ca->tape_state.error == NDMP9_NO_ERR) {
		ndmca_monitor_unload_last_tape (sess);
	}

	if (count >= 10) {
		ndmalogf (sess, 0, 0,
			"Operation did not halt, something wrong");
	}

	ndmalogf (sess, 0, 2, "Operation halted, stopping");

	ds = ca->data_state.state;
	ms = ca->mover_state.state;
	dhr = ca->data_state.halt_reason;
	mhr = ca->mover_state.halt_reason;

	if ((ds == NDMP9_DATA_STATE_HALTED)
	    && (ms == NDMP9_MOVER_STATE_HALTED)) {
	    if ((dhr == NDMP9_DATA_HALT_SUCCESSFUL) &&
		(mhr == NDMP9_MOVER_HALT_CONNECT_CLOSED)) {
		/* Successful operation */
		ndmalogf (sess, 0, 0, "Operation ended OKAY");
		finish = 0;
	    } else {
		/* Questionable success */
		ndmalogf (sess, 0, 0, "Operation ended questionably");
		finish = 1;
	    }
	} else {
	    ndmalogf (sess, 0, 0, "Operation ended in failure");
	    finish = -1;
	}

	ndmca_data_stop (sess);
	ndmca_mover_stop (sess);

	for (count = 0; count < 10; count++) {
		if (ndmca_monitor_get_states(sess) < 0)
		    break;

#if 0
		if (count > 2)
			ndmca_mon_show_states(sess);
#endif

		ds = ca->data_state.state;
		ms = ca->mover_state.state;

		if (ds == NDMP9_DATA_STATE_IDLE
		 && ms == NDMP9_MOVER_STATE_IDLE) {
			break;
		}
	}

	if (count >= 10) {
		ndmalogf (sess, 0, 0,
			"Operation did not stop, something wrong");
		return -1;
	}

	ndmca_connect_close (sess);

	return finish;
}