• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Why would CFFileDescriptorCreate return NULL?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why would CFFileDescriptorCreate return NULL?


  • Subject: Why would CFFileDescriptorCreate return NULL?
  • From: Jeff Johnson <email@hidden>
  • Date: Wed, 04 Jan 2012 00:23:56 -0600

We've got reports from a Mac OS X 10.7.2 Server user that CFFileDescriptorCreate() is returning NULL occasionally. Below is essentially our code:

	struct sockaddr addr;
	socklen_t addrlen = sizeof( addr );
	int socket = accept( s, &addr, &addrlen );
	if ( socket == -1 )
		perror( "accept" );

	int flags = fcntl( socket, F_GETFL );
	if ( flags == -1 )
		perror( "fcntl" );

	flags |= O_NONBLOCK;
	int ret = fcntl( socket, F_SETFL, flags );
	if ( ret == -1 )
		perror( "fcntl" );

	CFFileDescriptorContext ctx = { 0, self, NULL, NULL, NULL };
	_fdRef = CFFileDescriptorCreate( NULL, socket, true, FDCallback, &ctx );
	if ( _fdRef == NULL )
		perror( "CFFileDescriptorCreate" );

The accept() and fcntl() calls succeed, but CFFileDescriptorCreate() fails. I'm baffled as to why it fails here, though. For what it's worth, the error is "CFFileDescriptorCreate: Bad file descriptor", although I'm not sure whether errno is valid after this function call.

We haven't received any reports of this problem from Mac OS X Client users, and I'm certain that we would have heard, because the consequences of the failure are quite bad. ;-)

-Jeff

 _______________________________________________
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

  • Next by Date: File Uploading to HTTP server using CFHTTPMessage API fails
  • Next by thread: File Uploading to HTTP server using CFHTTPMessage API fails
  • Index(es):
    • Date
    • Thread