Have Marinetti return a new handle in ReadFixup.

This should be faster, as in DoReadTCP, and it simplifies the code a little.

Also, check for returned data size of 0 in DoReadTCP. I don't think this should happen, but in case it did, the returned handle could be invalid.
This commit is contained in:
Stephen Heumann 2016-05-28 23:19:13 -05:00
parent e1288f7e1b
commit aa15c60672
1 changed files with 6 additions and 10 deletions

View File

@ -307,13 +307,6 @@ BOOLEAN DoWaitingReadTCP(unsigned long dataLength) {
/* Fix things when TCPIPReadTCP returns less data than it's supposed to */
static BOOLEAN ReadFixup (unsigned long requested, unsigned long returned) {
static rrBuff theRRBuff;
static void **fixupBufferHndl = NULL;
if (fixupBufferHndl == NULL) {
fixupBufferHndl = NewHandle(requested-returned, userid(), 0, NULL);
if (toolerror())
return FALSE;
}
SetHandleSize(requested, readBufferHndl);
if (toolerror())
@ -322,7 +315,7 @@ static BOOLEAN ReadFixup (unsigned long requested, unsigned long returned) {
do {
TCPIPPoll();
if ((tcperr = TCPIPReadTCP(hostIpid, buffTypeHandle, (Ref)fixupBufferHndl,
if ((tcperr = TCPIPReadTCP(hostIpid, buffTypeNewHandle, NULL,
requested-returned, &theRRBuff)) != tcperrOK)
return FALSE;
if (toolerror())
@ -331,11 +324,11 @@ static BOOLEAN ReadFixup (unsigned long requested, unsigned long returned) {
if (theRRBuff.rrBuffCount == 0) /* To avoid infinite loops */
return FALSE;
HandToPtr(fixupBufferHndl, (char *)*readBufferHndl + returned,
HandToPtr(theRRBuff.rrBuffHandle, (char *)*readBufferHndl + returned,
theRRBuff.rrBuffCount);
returned += theRRBuff.rrBuffCount;
DisposeHandle(theRRBuff.rrBuffHandle);
} while (returned < requested);
return TRUE;
@ -365,6 +358,9 @@ BOOLEAN DoReadTCP (unsigned long dataLength) {
return FALSE;
if (toolerror())
return FALSE;
if (theRRBuff.rrBuffCount == 0)
return FALSE;
readBufferHndl = theRRBuff.rrBuffHandle;
if (theRRBuff.rrBuffCount != dataLength)