Ejemplo n.º 1
0
/*
 * Use this function to force a close of a peer session
 */
static void peer_session_forceshutdown(struct stream * stream)
{
	struct stream_interface *oldsi = NULL;
	struct appctx *appctx = NULL;
	int i;

	for (i = 0; i <= 1; i++) {
		appctx = objt_appctx(stream->si[i].end);
		if (!appctx)
			continue;
		if (appctx->applet != &peer_applet)
			continue;

		oldsi = &stream->si[i];
		break;
	}

	if (!appctx)
		return;

	/* call release to reinit resync states if needed */
	peer_session_release(oldsi);
	appctx->st0 = PEER_SESS_ST_END;
	appctx->ctx.peers.ptr = NULL;
	task_wakeup(stream->task, TASK_WOKEN_MSG);
}
Ejemplo n.º 2
0
/*
 * Use this function to force a close of a peer session
 */
static void peer_session_forceshutdown(struct stream * stream)
{
	struct appctx *appctx = NULL;
	struct peer_session *ps;
	int i;

	for (i = 0; i <= 1; i++) {
		appctx = objt_appctx(stream->si[i].end);
		if (!appctx)
			continue;
		if (appctx->applet != &peer_applet)
			continue;
		break;
	}

	if (!appctx)
		return;

	ps = (struct peer_session *)appctx->ctx.peers.ptr;
	/* we're killing a connection, we must apply a random delay before
	 * retrying otherwise the other end will do the same and we can loop
	 * for a while.
	 */
	if (ps)
		ps->reconnect = tick_add(now_ms, MS_TO_TICKS(50 + random() % 2000));

	/* call release to reinit resync states if needed */
	peer_session_release(appctx);
	appctx->st0 = PEER_SESS_ST_END;
	appctx->ctx.peers.ptr = NULL;
	task_wakeup(stream->task, TASK_WOKEN_MSG);
}
Ejemplo n.º 3
0
/*
 * Use this function to force a close of a peer session
 */
static void peer_session_forceshutdown(struct session * session)
{
	struct stream_interface *oldsi;

	if (objt_applet(session->si[0].conn->target) == &peer_applet) {
		oldsi = &session->si[0];
	}
	else {
		oldsi = &session->si[1];
	}

	/* call release to reinit resync states if needed */
	peer_session_release(oldsi);
	oldsi->applet.st0 = PEER_SESSION_END;
	oldsi->conn->xprt_ctx = NULL;
	task_wakeup(session->task, TASK_WOKEN_MSG);
}