Skip to content

Commit

Permalink
fix(rxcontrib): Fixes in file loading & process management
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregungory committed Oct 30, 2024
1 parent 55eaa4e commit 433f08a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
9 changes: 5 additions & 4 deletions src/rt/RcontribSimulManager.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef lint
static const char RCSid[] = "$Id: RcontribSimulManager.cpp,v 2.2 2024/10/29 19:47:19 greg Exp $";
static const char RCSid[] = "$Id: RcontribSimulManager.cpp,v 2.3 2024/10/30 01:38:21 greg Exp $";
#endif
/*
* RcontribSimulManager.cpp
Expand Down Expand Up @@ -443,7 +443,8 @@ RcontribOutput::CheckHeader(const RcontribSimulManager *rcp)
return -1;
}
// check format
if (!(cp = findArgs(hdr, FMTSTR, begData)) || strcmp(cp, formstr(etyp))) {
if (!(cp = findArgs(hdr, FMTSTR, begData)) ||
strncmp(cp, formstr(etyp), strlen(formstr(etyp)))) {
sprintf(errmsg, "expected %s%s in '%s'", FMTSTR, formstr(etyp), GetName());
error(USER, errmsg);
return -1;
Expand Down Expand Up @@ -632,7 +633,8 @@ RcontribSimulManager::GetChild(bool forceWait)
FD_ISSET(kid[n].w, &writeset) |
FD_ISSET(kid[n].w, &errset)) {
// update output row counts
UpdateRowsDone(kidRow[n]);
if (!FD_ISSET(kid[n].w, &errset))
UpdateRowsDone(kidRow[n]);
kidRow[n] = -1; // flag it available
pn = n;
}
Expand Down Expand Up @@ -716,7 +718,6 @@ RcontribSimulManager::StartKids(int n2go)
close(kid[nkids].w);
free(kid); free(kidRow);
kid = NULL; kidRow = NULL;
rowsDone.NewBitMap(0);
RunChild(); // should never return
_exit(1);
}
Expand Down
4 changes: 2 additions & 2 deletions src/rt/RcontribSimulManager.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* RCSid $Id: RcontribSimulManager.h,v 2.2 2024/10/29 19:47:19 greg Exp $ */
/* RCSid $Id: RcontribSimulManager.h,v 2.3 2024/10/30 01:38:21 greg Exp $ */
/*
* RcontribSimulManager.h
*
Expand Down Expand Up @@ -154,7 +154,7 @@ extern lut_free_t FreeRcMod;
*/

/// Output channel opening options: new/exclusive, overwrite if exists, or recover data
enum RCOutputOp {RCOnew, RCOforce, RCOrecover};
enum RCOutputOp {RCOnew=0, RCOforce, RCOrecover};

/// Converts above to RdataShare open flags (may be adjusted by calling program)
extern int RSDOflags[];
Expand Down
12 changes: 6 additions & 6 deletions src/rt/RdataShareFile.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef lint
static const char RCSid[] = "$Id: RdataShareFile.cpp,v 2.1 2024/10/29 00:36:54 greg Exp $";
static const char RCSid[] = "$Id: RdataShareFile.cpp,v 2.2 2024/10/30 01:38:21 greg Exp $";
#endif
/*
* RdataShareFile.cpp
Expand Down Expand Up @@ -84,16 +84,16 @@ RdataShareFile::RdataShareFile(const char *name, int flags, size_t siz)
int oflags = O_CLOEXEC;
switch (flags & (RDSread|RDSwrite)) {
case RDSread|RDSwrite:
oflags |= O_RDWR;
oflags |= O_RDWR|O_CREAT;
break;
case RDSwrite:
oflags |= O_WRONLY|O_CREAT;
break;
case RDSread:
oflags |= O_RDONLY;
break;
case RDSwrite:
oflags |= O_WRONLY;
break;
}
if (flags & RDSexcl) oflags |= O_CREAT|O_EXCL;
if (flags & RDSexcl) oflags |= O_EXCL;
else if (flags & RDSextend && !siz) oflags |= O_TRUNC;
fd = open(name, oflags, 0666);
if (fd < 0) {
Expand Down
23 changes: 11 additions & 12 deletions src/rt/RdataShareMap.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef lint
static const char RCSid[] = "$Id: RdataShareMap.cpp,v 2.1 2024/10/29 00:36:54 greg Exp $";
static const char RCSid[] = "$Id: RdataShareMap.cpp,v 2.2 2024/10/30 01:38:21 greg Exp $";
#endif
/*
* RdataShareMap.cpp
Expand Down Expand Up @@ -36,25 +36,24 @@ RdataShareMap::RdataShareMap(const char *name, int flags, size_t siz)
error(CONSISTENCY, "bad RDSextend in RdataShareMap()");
return;
}
int mmprot = PROT_NONE;
int oflags = 0;
int oflags, mmprot;
switch (flags & (RDSread|RDSwrite)) {
case RDSread|RDSwrite:
mmprot |= PROT_READ|PROT_WRITE;
oflags |= O_RDWR;
break;
case RDSread:
mmprot |= PROT_READ;
oflags |= O_RDONLY;
mmprot = PROT_READ|PROT_WRITE;
oflags = O_RDWR|O_CREAT;
break;
case RDSwrite:
mmprot |= PROT_WRITE;
oflags |= O_WRONLY;
mmprot = PROT_WRITE;
oflags = O_RDWR|O_CREAT; // XXX system limitation
break;
case RDSread:
mmprot = PROT_READ;
oflags = O_RDONLY;
break;
}
int fd = -1;
if (name) { // opening a shared file
if (flags & RDSexcl) oflags |= O_CREAT|O_EXCL;
if (flags & RDSexcl) oflags |= O_EXCL;
else if (flags & RDSextend && !siz) oflags |= O_TRUNC;
fd = open(name, oflags, 0666);
if (fd < 0) {
Expand Down

0 comments on commit 433f08a

Please sign in to comment.