Skip to content

Commit

Permalink
Align BPv6 handling of serialized bundle ZCOs with BPv7.
Browse files Browse the repository at this point in the history
  • Loading branch information
sburleig committed Jun 1, 2020
1 parent e4bdf48 commit 0a7f444
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 271 deletions.
48 changes: 8 additions & 40 deletions bpv6/bssp/bsspcli.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ int acquireBundle(AcqWorkArea *work, BsspSessionId *sessionId,
zco_start_receiving(zco, &reader);
CHKERR(sdr_begin_xn(sdr));
result = zco_receive_source(sdr, &reader, length, *buffer);

if (sdr_end_xn(sdr) < 0 || result < 0)
{
putErrmsg("Failed reading bssp block data.", NULL);
Expand Down Expand Up @@ -118,7 +117,6 @@ static void *handleNotices(void *parm)
unsigned char reasonCode;
unsigned int dataLength;
Object data; /* ZCO reference. */
int result;
unsigned int buflen = 0;
char *buffer = NULL;

Expand Down Expand Up @@ -156,65 +154,35 @@ static void *handleNotices(void *parm)

switch (type)
{
case BsspXmitSuccess: /* Xmit success. */
case BsspXmitSuccess: /* Xmit success. */
if (data == 0) /* Ignore it. */
{
break; /* Out of switch. */
}

result = bpHandleXmitSuccess(data, 0);
if (result < 0)
if (bpHandleXmitSuccess(data, 0) < 0)
{
putErrmsg("Crashed on xmit success.", NULL);
ionKillMainThread(procName);
rtp->running = 0;
break; /* Out of switch. */
}

if (result == 1)
{
CHKNULL(sdr_begin_xn(sdr));
zco_destroy(sdr, data);
if (sdr_end_xn(sdr) < 0)
{
putErrmsg("Crashed on data cleanup.",
NULL);
ionKillMainThread(procName);
rtp->running = 0;
}
}

break; /* Out of switch. */
break; /* Out of switch. */

case BsspXmitFailure: /* Xmit failure. */
case BsspXmitFailure: /* Xmit failure. */
if (data == 0) /* Ignore it. */
{
break; /* Out of switch. */
}

result = bpHandleXmitFailure(data);
if (result < 0)
if (bpHandleXmitFailure(data) < 0)
{
putErrmsg("Crashed on xmit failure.", NULL);
ionKillMainThread(procName);
rtp->running = 0;
break; /* Out of switch. */
}

if (result == 1)
{
CHKNULL(sdr_begin_xn(sdr));
zco_destroy(sdr, data);
if (sdr_end_xn(sdr) < 0)
{
putErrmsg("Crashed on data cleanup.",
NULL);
ionKillMainThread(procName);
rtp->running = 0;
}
}

break; /* Out of switch. */
break; /* Out of switch. */

case BsspRecvSuccess:
if (acquireBundle(work, &sessionId, dataLength,
Expand All @@ -236,11 +204,11 @@ static void *handleNotices(void *parm)
rtp->running = 0;
}

break; /* Out of switch. */
break; /* Out of switch. */


default:
break; /* Out of switch. */
break; /* Out of switch. */
}

/* Make sure other tasks have a chance to run. */
Expand Down
33 changes: 3 additions & 30 deletions bpv6/dccp/dccpclo.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,27 +224,14 @@ return NULL;
int handleDccpFailure(char* ductname, struct sockaddr *sn, Object *bundleZco)
{
Sdr sdr = getIonsdr();
int result;

/* Handle the de-queued bundle. */
result = bpHandleXmitFailure(*bundleZco);
if (result < 0)
if (bpHandleXmitFailure(*bundleZco) < 0)
{
putErrmsg("Can't handle DCCP xmit failure.", NULL);
return -1;
}

if (result == 1)
{
CHKERR(sdr_begin_xn(sdr));
zco_destroy(sdr, *bundleZco);
if (sdr_end_xn(sdr) < 0 )
{
putErrmsg("Can't destroy bundle ZCO.", NULL);
return -1;
}
}

return 0;
}

Expand All @@ -256,7 +243,6 @@ int sendBundleByDCCP(clo_state* itp, Object* bundleZco,
int bytesSent;
int bytesToSend;
int bundleLength;
int result;

/* Connect socket */
if (!itp->active)
Expand Down Expand Up @@ -314,28 +300,15 @@ int sendBundleByDCCP(clo_state* itp, Object* bundleZco,
}
itp->active = 1;
break; /*sent successfully */
}while(1);
} while(1);

/* Notify BP of success transmitting */
result = bpHandleXmitSuccess(*bundleZco, 0);
if (result < 0)
if (bpHandleXmitSuccess(*bundleZco, 0) < 0)
{
putErrmsg("Can't handle xmit success.", NULL);
bytesSent=-1;
}

if (result == 1)
{
/* Cleanup ZCO */
CHKERR(sdr_begin_xn(sdr));
zco_destroy(sdr, *bundleZco);
if (sdr_end_xn(sdr) < 0)
{
putErrmsg("Can't destroy bundle ZCO.", NULL);
bytesSent=-1;
}
}

return bytesSent;
}

Expand Down
33 changes: 3 additions & 30 deletions bpv6/dgr/dgrcli.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ static void *receiveBundles(void *parm)
int length;
int errnbr;
Object bundleZco;
int result;
char hostName[MAXHOSTNAMELEN + 1];

snooze(1); /* Let main thread become interruptable. */
Expand Down Expand Up @@ -119,27 +118,14 @@ temporary ZCO.", NULL);
continue;
}

result = bpHandleXmitSuccess(bundleZco,
0);
if (result < 0)
if (bpHandleXmitSuccess(bundleZco, 0)
< 0)
{
threadRunning = 0;
putErrmsg("Crashed handling \
success.", NULL);
}

if (result == 1)
{
CHKNULL(sdr_begin_xn(sdr));
zco_destroy(sdr, bundleZco);
if (sdr_end_xn(sdr) < 0)
{
threadRunning = 0;
putErrmsg("Failed \
destroying bundle ZCO.", NULL);
}
}

if (threadRunning == 0)
{
break; /* Switch. */
Expand Down Expand Up @@ -171,26 +157,13 @@ temporary ZCO.", NULL);
continue;
}

result = bpHandleXmitFailure(bundleZco);
if (result < 0)
if (bpHandleXmitFailure(bundleZco) < 0)
{
threadRunning = 0;
putErrmsg("Crashed handling \
failure.", NULL);
}

if (result == 1)
{
CHKNULL(sdr_begin_xn(sdr));
zco_destroy(sdr, bundleZco);
if (sdr_end_xn(sdr) < 0)
{
threadRunning = 0;
putErrmsg("Failed \
destroying bundle ZCO.", NULL);
}
}

if (threadRunning == 0)
{
break; /* Switch. */
Expand Down
46 changes: 7 additions & 39 deletions bpv6/dgr/dgrclo.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ static void *sendBundles(void *parm)
ZcoReader reader;
int bytesToSend;
DgrRC rc;
int result;

snooze(1); /* Let main thread become interruptable. */
buffer = MTAKE(DGRCLA_BUFSZ);
Expand Down Expand Up @@ -136,22 +135,18 @@ static void *sendBundles(void *parm)
if (rc == DgrFailed)
{
failedTransmissions++;
result = bpHandleXmitFailure(bundleZco);
if (result < 0)
if (bpHandleXmitFailure(bundleZco) < 0)
{
threadRunning = 0;
putErrmsg("Crashed handling \
failure.", NULL);
continue;
}

if (result == 0)
else
{
/* No such bundle. */

sm_TaskYield();
continue;
}

continue;
}
}
}
Expand Down Expand Up @@ -198,7 +193,6 @@ static void *receiveSegments(void *parm)
char *buffer;
int threadRunning = 1;
DgrRC rc;
int result;
unsigned short fromPortNbr;
unsigned int fromHostNbr;
int length;
Expand Down Expand Up @@ -267,27 +261,14 @@ temporary ZCO.", NULL);
continue;
}

result = bpHandleXmitSuccess(bundleZco,
0);
if (result < 0)
if (bpHandleXmitSuccess(bundleZco, 0)
< 0)
{
threadRunning = 0;
putErrmsg("Crashed handling \
success.", NULL);
}

if (result == 1)
{
CHKNULL(sdr_begin_xn(sdr));
zco_destroy(sdr, bundleZco);
if (sdr_end_xn(sdr) < 0)
{
threadRunning = 0;
putErrmsg("Failed \
destroying bundle ZCO.", NULL);
}
}

if (threadRunning == 0)
{
break; /* Switch. */
Expand Down Expand Up @@ -321,26 +302,13 @@ temporary ZCO.", NULL);
continue;
}

result = bpHandleXmitFailure(bundleZco);
if (result < 0)
if (bpHandleXmitFailure(bundleZco) < 0)
{
threadRunning = 0;
putErrmsg("Crashed handling \
failure.", NULL);
}

if (result == 1)
{
CHKNULL(sdr_begin_xn(sdr));
zco_destroy(sdr, bundleZco);
if (sdr_end_xn(sdr) < 0)
{
threadRunning = 0;
putErrmsg("Failed \
destroying bundle ZCO.", NULL);
}
}

if (threadRunning == 0)
{
break; /* Switch. */
Expand Down
2 changes: 2 additions & 0 deletions bpv6/library/acs/acsP.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ extern "C" {
#define ASSERT_BPSDR_XN assert(sdr_in_xn(bpSdr) != 0)
#define ASSERT_BPSDR_NOXN assert(sdr_in_xn(bpSdr) == 0)

#ifndef ACS_TTL
#define ACS_TTL (86400) /* Bundle lifetime of an ACS */
#endif
#define MAX_ACSLOG_LEN (512)
#define MAX_REPRACS_LEN (MAX_ACSLOG_LEN - 50) /* Max len of a printAcs */
#define DEFAULT_ACS_DELAY (15) /* Default s to wait before generating */
Expand Down
4 changes: 4 additions & 0 deletions bpv6/library/libbpP.c
Original file line number Diff line number Diff line change
Expand Up @@ -11928,6 +11928,7 @@ int bpHandleXmitSuccess(Object bundleZco, unsigned int timeoutInterval)

if (bundleAddr == 0) /* Bundle not found. */
{
zco_destroy(bpSdr, bundleZco);
if (sdr_end_xn(bpSdr) < 0)
{
putErrmsg("Failed handling xmit success.", NULL);
Expand Down Expand Up @@ -11989,6 +11990,7 @@ int bpHandleXmitSuccess(Object bundleZco, unsigned int timeoutInterval)
return -1;
}

zco_destroy(bpSdr, bundleZco);
if (sdr_end_xn(bpSdr) < 0)
{
putErrmsg("Can't handle transmission success.", NULL);
Expand All @@ -12015,6 +12017,7 @@ int bpHandleXmitFailure(Object bundleZco)

if (bundleAddr == 0) /* Bundle not found. */
{
zco_destroy(bpSdr, bundleZco);
if (sdr_end_xn(bpSdr) < 0)
{
putErrmsg("Failed handling xmit failure.", NULL);
Expand Down Expand Up @@ -12044,6 +12047,7 @@ int bpHandleXmitFailure(Object bundleZco)
return -1;
}

zco_destroy(bpSdr, bundleZco);
if (sdr_end_xn(bpSdr) < 0)
{
putErrmsg("Can't handle transmission failure.", NULL);
Expand Down
Loading

0 comments on commit 0a7f444

Please sign in to comment.