• 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
Apple's Sample Code: GetPrimaryMACAddress.c
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Apple's Sample Code: GetPrimaryMACAddress.c


  • Subject: Apple's Sample Code: GetPrimaryMACAddress.c
  • From: Mark de Jong <email@hidden>
  • Date: Sat, 26 Oct 2002 10:48:59 -0700

Hi!

I'm using Apple's sample code "GetPrimaryMACAddress.c" to obtain the
machine's MAC address. I'm not doing any networking, just want to get
the MAC address. (And, I don't know anything about IOKit at this point;
I just need to use this code. :-) )

When I call this code, the machine appears "hang on" to something
causing delays in other programs, most notably internet applications.

While digging through the code, I noticed "masterPort" was not being
released when it was done being used. At the bottom of "static
kern_return_t FindEthernetInterfaces(io_iterator_t *matchingServices)",
there is the following code:

kernResult = IOServiceGetMatchingServices(masterPort,
classesToMatch, matchingServices);
if (KERN_SUCCESS != kernResult)
printf("IOServiceGetMatchingServices returned %d\n",
kernResult);

return kernResult;

where "masterPort" had been previously created with:

kernResult = IOMasterPort(MACH_PORT_NULL, &masterPort);
if (KERN_SUCCESS != kernResult)
printf("IOMasterPort returned %d\n", kernResult);

So, I changed the end of the routine to look like this:

kernResult = IOServiceGetMatchingServices(masterPort,
classesToMatch, matchingServices);
if (KERN_SUCCESS != kernResult)
printf("IOServiceGetMatchingServices returned %d\n",
kernResult);

IOObjectRelease( masterPort );
return kernResult;

Adding the "IOObjectRelease()" call to release the masterPort.

Here's my question: Could not releasing the "masterPort" cause the
delays I had been seeing? And, is this an ok way to fix it?

Thanks,

-- Mark
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Follow-up: Cocoa thread-safety
  • Next by Date: Follow-up: Cocoa-Java Threads
  • Previous by thread: Help system stopped working
  • Next by thread: Follow-up: Cocoa-Java Threads
  • Index(es):
    • Date
    • Thread