jcs
/subtext
/amendments
/367
dnr: Support a yielding callback in DNSResolveName
Instead of spinning, an application can pass something like
uthread_yield
jcs made amendment 367 about 1 year ago
--- dnr.c Wed Feb 22 16:27:08 2023
+++ dnr.c Wed Mar 8 10:07:56 2023
@@ -114,7 +114,7 @@ SearchFolderForDNRP(long targetType, long targetCreato
short refnum;
fi.fileParam.ioCompletion = nil;
- fi.fileParam.ioNamePtr = filename;
+ fi.fileParam.ioNamePtr = (StringPtr)&filename;
fi.fileParam.ioVRefNum = vRefNum;
fi.fileParam.ioDirID = dirID;
fi.fileParam.ioFDirIndex = 1;
@@ -309,7 +309,7 @@ MXInfo(char *hostName, struct returnRec *returnRecPtr,
#endif
OSErr
-TCPResolveName(char **name, unsigned long *ipAddress)
+DNSResolveName(char **name, unsigned long *ipAddress, void (*yielder)(void))
{
OSErr osErr;
struct hostInfo aHostInfo;
@@ -324,8 +324,10 @@ TCPResolveName(char **name, unsigned long *ipAddress)
if (osErr == cacheFault) {
/* StrToAddrMarkDone will set done when DNS resolution finishes */
- while (!done)
- ;
+ while (!done) {
+ if (yielder != NULL)
+ yielder();
+ }
}
if ((aHostInfo.rtnCode == noErr) || (aHostInfo.rtnCode == cacheFault)) {
--- tcp.h Wed Feb 22 16:27:08 2023
+++ tcp.h Wed Mar 8 10:07:09 2023
@@ -59,7 +59,8 @@ OSErr _UDPSend(UDPiopb *pb, StreamPtr stream, wdsEntry
OSErr _UDPRelease(UDPiopb *pb, StreamPtr stream, Ptr userData,
UDPIOCompletionProc ioCompletion, Boolean async);
-OSErr TCPResolveName(char **name, unsigned long *ipAddress);
+OSErr DNSResolveName(char **name, unsigned long *ipAddress,
+ void (*yielder)(void));
pascal void StrToAddrMarkDone(struct hostInfo *hi, char *data);
unsigned long ip2long(char *ip);