Beispiel #1
0
static int	reforwardStrandedBundles()
{
	Sdr	sdr = getIonsdr();
	BpDB	*bpConstants = getBpConstants();
	Object	elt;
	Object	nextElt;

	CHKERR(sdr_begin_xn(sdr));
	for (elt = sdr_list_first(sdr, bpConstants->limboQueue); elt;
			elt = nextElt)
	{
		nextElt = sdr_list_next(sdr, elt);
		if (releaseFromLimbo(elt, 0) < 0)
		{
			putErrmsg("Failed releasing bundle from limbo.", NULL);
			sdr_cancel_xn(sdr);
			return -1;
		}
	}

	if (sdr_end_xn(sdr) < 0)
	{
		putErrmsg("brss failed limbo release on client connect.", NULL);
		return -1;
	}

	return 0;
}
Beispiel #2
0
Datei: bpclock.c Projekt: b/ION
int	bpclock(int a1, int a2, int a3, int a4, int a5,
		int a6, int a7, int a8, int a9, int a10)
{
#else
int	main(int argc, char *argv[])
{
#endif
	Sdr	sdr;
	BpDB	*bpConstants;
	int	state = 1;
	time_t	currentTime;

	if (bpAttach() < 0)
	{
		putErrmsg("bpclock can't attach to BP.", NULL);
		return 1;
	}

	sdr = getIonsdr();
	bpConstants = getBpConstants();
	isignal(SIGTERM, shutDown);

	/*	Main loop: wait for event occurrence time, then
	 *	execute applicable events.				*/

	oK(_running(&state));
	writeMemo("[i] bpclock is running.");
	while (_running(NULL))
	{
		/*	Sleep for 1 second, then dispatch all events
		 *	whose executions times have now been reached.	*/

		snooze(1);
		currentTime = getUTCTime();
		if (dispatchEvents(sdr, bpConstants->timeline, currentTime) < 0)
		{
			putErrmsg("Can't dispatch events.", NULL);
			state = 0;	/*	Terminate loop.		*/
			oK(_running(&state));
			continue;
		}

		/*	Also adjust throttles in response to rate
		 *	changes noted in the shared ION database.	*/

		if (adjustThrottles() < 0)
		{
			putErrmsg("Can't adjust throttles.", NULL);
			state = 0;	/*	Terminate loop.		*/
			oK(_running(&state));
			continue;
		}

		/*	Then apply rate control.			*/

		applyRateControl(sdr);
	}

	writeErrmsgMemos();
	writeMemo("[i] bpclock has ended.");
	ionDetach();
	return 0;
}
Beispiel #3
0
Datei: brsscla.c Projekt: b/ION
static int	reforwardStrandedBundles(int nodeNbr)
{
	Sdr	sdr = getIonsdr();
	BpDB	*bpConstants = getBpConstants();
	Object	elt;
	Object	eventObj;
		OBJ_POINTER(BpEvent, event);
		OBJ_POINTER(Bundle, bundle);

	sdr_begin_xn(sdr);
	for (elt = sdr_list_first(sdr, bpConstants->timeline); elt;
			elt = sdr_list_next(sdr, elt))
	{
		eventObj = sdr_list_data(sdr, elt);
		GET_OBJ_POINTER(sdr, BpEvent, event, eventObj);
		if (event->type != expiredTTL)
		{
			continue;
		}

		/*	Have got a bundle that still exists.		*/

		GET_OBJ_POINTER(sdr, Bundle, bundle, event->ref);
		if (bundle->dlvQueueElt || bundle->fragmentElt
		|| bundle->fwdQueueElt || bundle->overdueElt
		|| bundle->ctDueElt || bundle->xmitsNeeded > 0)
		{
			/*	No need to reforward.			*/

			continue;
		}

		/*	A stranded bundle, awaiting custody acceptance.
		 *	Might be for a neighbor other than the one
		 *	that just reconnected, but in that case the
		 *	bundle will be reforwarded and requeued and
		 *	go into the bit bucket again; no harm.  Note,
		 *	though, that this means that a BRS server
		 *	would be a bad candidate for gateway into a
		 *	space subnet: due to long OWLTs, there might
		 *	be a lot of bundles sent via LTP that are
		 *	awaiting custody acceptance, so reconnection
		 *	of a BRS client might trigger retransmission
		 *	of a lot of bundles on the space link in
		 *	addition to the ones to be issued via brss.	*/

		if (bpReforwardBundle(event->ref) < 0)
		{
			sdr_cancel_xn(sdr);
			putErrmsg("brss reforward failed.", NULL);
			return -1;
		}
	}

	if (sdr_end_xn(sdr) < 0)
	{
		putErrmsg("brss reforwarding failed.", NULL);
		return -1;
	}

	return 0;
}