crash in CFReadStreamOpen when called from secondary thread
crash in CFReadStreamOpen when called from secondary thread
- Subject: crash in CFReadStreamOpen when called from secondary thread
- From: "Shalini Kamala" <email@hidden>
- Date: Tue, 24 Oct 2006 11:24:22 -0700
- Organization: AOL
Hello!
I am trying to do an HTTP GET from a secondary thread, & when I
call CFReadStreamOpen, I get a crash in the
debugger.("Program Received Signal: EXC_ARITHMETIC")
The crash occurs in _CFNetConnectionRegisterClass. If I call
CFReadStreamOpen from the main thread, it works fine. What am I missing
? Do I need to do any initialization in the secondary thread ?
Thanks,
Shalini
PS:
Here is how I create the thread :
MPCriticalRegionID
criticalRegion;
OSStatus retStatus = MPCreateCriticalRegion(&criticalRegion);
retStatus = MPEnterCriticalRegion(criticalRegion, 5000*2);
MPTaskID taskID;
retStatus = MPCreateTask(&ThreadFunc, strArray, 0, 0, NULL,
NULL, 0, &taskID);
retStatus = MPExitCriticalRegion(criticalRegion);
retStatus = MPDeleteCriticalRegion(criticalRegion);
My HTTP GET calls look like this:
CFStringRef url
= "" href="http://10.169.150.209:8080/MetadataUploadServlet?Screenname=foo&Title=Testing&ThumbnailExtension=jpg">http://10.169.150.209:8080/MetadataUploadServlet?Screenname=foo&Title=Testing&ThumbnailExtension=jpg");
CFURLRef myURL = CFURLCreateWithString(kCFAllocatorDefault,
url, NULL);
CFStringRef requestMethod = CFSTR("GET");
CFHTTPMessageRef myRequest =
CFHTTPMessageCreateRequest(kCFAllocatorDefault, requestMethod, myURL,
kCFHTTPVersion1_1);
CFDataRef mySerializedRequest =
CFHTTPMessageCopySerializedMessage(myRequest);
CFReadStreamRef stream =
CFReadStreamCreateForHTTPRequest(kCFAllocatorDefault, myRequest);
CFStreamClientContext ctxt = { 0, (void*)NULL,
NULL, NULL, NULL };
CFReadStreamSetProperty(stream,
kCFStreamPropertyHTTPAttemptPersistentConnection, kCFBooleanTrue);
CFReadStreamSetClient(stream, kNetworkEvents,
ReadStreamClientCallBack, &ctxt);
CFReadStreamScheduleWithRunLoop(stream,
CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
CFReadStreamOpen(stream);
CFRelease(myRequest);
CFRelease(myURL);
CFRelease(url);
myRequest = NULL;
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden