"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "dataio/ChildProcessDataIO.cpp" between
muscle8.20.zip and muscle8.30.zip

About: MUSCLE (Multi User Server Client Linking Environment) is a messaging server and networking API. The included server program ("muscled") lets its clients message each other, and/or store information in its serverside hierarchical database.

ChildProcessDataIO.cpp  (muscle8.20):ChildProcessDataIO.cpp  (muscle8.30)
skipping to change at line 153 skipping to change at line 153
const char ** argv = (const char **) args; const char ** argv = (const char **) args;
Queue<String> tmpQ; (void) tmpQ.EnsureSize(argc); Queue<String> tmpQ; (void) tmpQ.EnsureSize(argc);
for (int i=0; i<argc; i++) (void) tmpQ.AddTail(argv[i]); for (int i=0; i<argc; i++) (void) tmpQ.AddTail(argv[i]);
cmd = UnparseArgs(tmpQ); cmd = UnparseArgs(tmpQ);
} }
// If environment-vars are specified, we need to create a new env ironment-variable-block // If environment-vars are specified, we need to create a new env ironment-variable-block
// for the child process to use. It will be the same as our own, but with the specified // for the child process to use. It will be the same as our own, but with the specified
// env-vars added/updated in it. // env-vars added/updated in it.
void * envVars = NULL; void * envVars = NULL;
char * newBlock = NULL; uint8 * newBlock = NULL;
if ((optEnvironmentVariables)&&(optEnvironmentVariables->HasItems ())) if ((optEnvironmentVariables)&&(optEnvironmentVariables->HasItems ()))
{ {
Hashtable<String, String> curEnvVars; Hashtable<String, String> curEnvVars;
char * oldEnvs = GetEnvironmentStrings(); char * oldEnvs = GetEnvironmentStrings();
if (oldEnvs) if (oldEnvs)
{ {
const char * s = oldEnvs; const char * s = oldEnvs;
while(s) while(s)
{ {
skipping to change at line 182 skipping to change at line 182
FreeEnvironmentStringsA(oldEnvs); FreeEnvironmentStringsA(oldEnvs);
} }
(void) curEnvVars.Put(*optEnvironmentVariables); // update ou r existing vars with the specified ones (void) curEnvVars.Put(*optEnvironmentVariables); // update ou r existing vars with the specified ones
// Now we can make a new environment-variables-block out of (c urEnvVars) // Now we can make a new environment-variables-block out of (c urEnvVars)
uint32 newBlockSize = 1; // this represents the final NUL ter minator (after the last string) uint32 newBlockSize = 1; // this represents the final NUL ter minator (after the last string)
for (HashtableIterator<String, String> iter(curEnvVars); iter. HasData(); iter++) newBlockSize += iter.GetKey().FlattenedSize()+iter.GetValue() .FlattenedSize(); // includes NUL terminators for (HashtableIterator<String, String> iter(curEnvVars); iter. HasData(); iter++) newBlockSize += iter.GetKey().FlattenedSize()+iter.GetValue() .FlattenedSize(); // includes NUL terminators
uint8 * newBlock = newnothrow uint8[newBlockSize]; newBlock = newnothrow uint8[newBlockSize];
if (newBlock) if (newBlock)
{ {
uint8 * s = newBlock; uint8 * s = newBlock;
for (HashtableIterator<String, String> iter(curEnvVars); it er.HasData(); iter++) for (HashtableIterator<String, String> iter(curEnvVars); it er.HasData(); iter++)
{ {
iter.GetKey().Flatten(s); s += iter.GetKey().Flattened Size(); iter.GetKey().Flatten(s); s += iter.GetKey().Flattened Size();
*(s-1) = '='; // replace key's trailing-NUL with an '=' sign *(s-1) = '='; // replace key's trailing-NUL with an '=' sign
iter.GetValue().Flatten(s); s += iter.GetValue().Flatten edSize(); iter.GetValue().Flatten(s); s += iter.GetValue().Flatten edSize();
} }
*s++ = '\0'; *s++ = '\0';
skipping to change at line 552 skipping to change at line 552
// block-and-read until either we read EOF from the _ioPipe or we reach th e timeout-time. // block-and-read until either we read EOF from the _ioPipe or we reach th e timeout-time.
bool sawEOF = false; bool sawEOF = false;
SocketMultiplexer sm; SocketMultiplexer sm;
const uint64 endTime = (maxWaitTimeMicros == MUSCLE_TIME_NEVER) ? MUSCLE_T IME_NEVER : (GetRunTime64()+maxWaitTimeMicros); const uint64 endTime = (maxWaitTimeMicros == MUSCLE_TIME_NEVER) ? MUSCLE_T IME_NEVER : (GetRunTime64()+maxWaitTimeMicros);
while(GetRunTime64() < endTime) while(GetRunTime64() < endTime)
{ {
if ((sm.RegisterSocketForReadReady(fd).IsError())||(sm.WaitForEvents(en dTime) < 0)) break; if ((sm.RegisterSocketForReadReady(fd).IsError())||(sm.WaitForEvents(en dTime) < 0)) break;
else else
{ {
char junk[1024] = ""; char junk[1024] = "";
if ((fread(junk, sizeof(junk), 1, _ioPipe.GetFile()) < 0)||(feof(_io Pipe.GetFile()))) if ((fread(junk, sizeof(junk), 1, _ioPipe.GetFile()) == 0)||(feof(_i oPipe.GetFile())))
{ {
sawEOF = true; sawEOF = true;
break; break;
} }
} }
} }
return sawEOF ? B_NO_ERROR : B_TIMED_OUT; // if we saw EOF on the _ioPipe , we'll take that to mean the child process exited -- best we can do return sawEOF ? B_NO_ERROR : B_TIMED_OUT; // if we saw EOF on the _ioPipe , we'll take that to mean the child process exited -- best we can do
} }
# endif # endif
skipping to change at line 770 skipping to change at line 770
if (childProcessExited) if (childProcessExited)
{ {
if (inBuf._index == inBuf._length) IOThreadAbort(); if (inBuf._index == inBuf._length) IOThreadAbort();
break; break;
} }
// block here until an event happens... gotta poll because // block here until an event happens... gotta poll because
// the Window anonymous pipes system doesn't allow me to // the Window anonymous pipes system doesn't allow me to
// to check for events on the pipe using WaitForMultipleObjects(). // to check for events on the pipe using WaitForMultipleObjects().
// It may be worth it to use named pipes some day to get around this... // It may be worth it to use named pipes some day to get around this...
const int evt = WaitForMultipleObjects(ARRAYITEMS(events)-(childProcess Exited?1:0), events, false, MicrosToMillis(pollTimeMicros))-WAIT_OBJECT_0; const int evt = WaitForMultipleObjects(ARRAYITEMS(events), events, fals e, MicrosToMillis(pollTimeMicros))-WAIT_OBJECT_0;
if (evt == 1) childProcessExited = true; if (evt == 1) childProcessExited = true;
int32 totalNumBytesRead = 0; int32 totalNumBytesRead = 0;
int32 numBytesToRead; int32 numBytesToRead;
while((numBytesToRead = sizeof(inBuf._buf)-inBuf._length) > 0) while((numBytesToRead = sizeof(inBuf._buf)-inBuf._length) > 0)
{ {
// See if there is actually any data available for reading first // See if there is actually any data available for reading first
DWORD pipeSize; DWORD pipeSize;
if (PeekNamedPipe(_readFromStdout, NULL, 0, NULL, &pipeSize, NULL)) if (PeekNamedPipe(_readFromStdout, NULL, 0, NULL, &pipeSize, NULL))
{ {
 End of changes. 4 change blocks. 
4 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)