| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
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: http://lists.apple.com/mailman/options/macnetworkprog/email@hidden This email sent to email@hidden
| References: | |
| >crash in CFReadStreamOpen when called from secondary thread (From: "Shalini Kamala" <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.