Actually I am now getting the error later on with the Gremlins. My problem seems to
be stemming from the function below. Can
anyone see if, in the function below, I am not releasing the record at the right time,
or checking the wrong condition. I
labeled the line for completeness' sake.
Thanks again,
Ed.
static Err ReadIntoNewRecord(DmOpenRef db, ExgSocketPtr socketPtr, UInt32 numBytes,
UInt16 *indexPtr) {
Char buffer[100];
Err err;
UInt16 index = 0;
UInt32 bytesReceived;
MemHandle recHandle = NULL;
Char *recPtr;
UInt32 recSize = 0;
Boolean allocatedRecord = false;
do {
UInt32 numBytesToRead = sizeof(buffer);
if (numBytesToRead > numBytes)
numBytesToRead = numBytes;
bytesReceived = ExgReceive(socketPtr, buffer, numBytesToRead, &err);
numBytes -= bytesReceived;
if (err == errNone) {
if (!recHandle) {
recHandle = DmNewRecord(db, &index, bytesReceived);
} else {
recHandle = DmResizeRecord(db, index, recSize + bytesReceived);
}
if (!recHandle) {
err = DmGetLastErr();
break;
}
allocatedRecord = true;
recPtr = (Char *) MemHandleLock(recHandle);
err = DmWrite(recPtr, recSize, buffer, bytesReceived);
MemHandleUnlock(recHandle);
recSize += bytesReceived;
}
} while (err == errNone && bytesReceived > 0 && numBytes > 0);
if (recHandle) { //
<---------------------------------------------------------------------- possible
problem?
DmReleaseRecord(db, index, true);
}
if (err != errNone && allocatedRecord)
DmRemoveRecord(db, index);
*indexPtr = index;
return err;
}
Danny Epstein wrote:
> > I get this error, "Records left locked in closed unprotected database.
> > " in POSE with my app.
>
> This indicates that you closed a database without unlocking all the record
> or resources that you locked. Note that it can be resources or records,
> despite the error message.
>
> > error = DmCloseDatabase(gSRCatDB);
> > if (gSRWorkDB != 0) // <--- This is the line that the error is generated
> on
>
> The debugger is probably pointing at the previous or next line. Look at the
> next stack frame; I'll bet it's DmCloseDatabase. Given the error message, it
> must be. :)
>
> Look for MemHandleLock calls without corresponding unlock calls. Remember to
> check for statements that can skip over the unlock call; e.g., break,
> continue, return, and goto.
> --
> Danny @ PalmSource
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe, please see
>http://www.palmos.com/dev/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/