• 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
Re: sleep in the NKE unload function
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sleep in the NKE unload function


  • Subject: Re: sleep in the NKE unload function
  • From: Jean Suisse <email@hidden>
  • Date: Sun, 09 Sep 2012 18:57:28 +0200

To add some more informations, I tried the "polling" approach in a tight while loop that only did tests if one of the two exit conditions were satisfied (1: sf_unregistered called or 2: a 3 ms timeout occurred).
In all test case, the normal exit condition (sf_unregistered called) was reached in less that 900 loop cycles.
Three ms is enough to do approx. 50000 cycles.

From these data, the polling solution to a one-call exit procedure seems OK. 
But I am still keen on getting a second opinion from someone experienced.

Jean

On 9 sept. 2012, at 18:33, Jean Suisse wrote:

Hello,

Unloading a network kernel extension that registers a socket filter 
can only be safely done once the sf_unregistered function has been called by the stack 
in response to a previous call to sflt_unregister from the kext.

Thus, when my kext is requested to unload, I first unregister the filter, then I do various cleanup (to gain some time). 
Eventually, I check wether or not sf_unregistered has been called. Unfortunately, most of the time it has not. 
But the timing is really close since sending two unload request in a row (from the terminal) is enough to get a 100% unload success rate on the second attempt.
Bottom line, I should have waited a little longer to give sf_unregistered a chance to be called.

Now, I have a few options:

- I could use msleep (the would originate from the sf_unregistered function).
- I could spin in a tight while loop (is it over yet ? is it over yet ? …) with a timeout exit condition (a few ms for instance).
- Other suggestions on how to deal with this kind of situation...

What do you think ?

Jean

Jean Suisse

Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302

U.F.R. Sciences et Techniques, Bâtiment Mirande
Aile B, bureau 411
9, avenue Alain Savary — B.P. 47870
21078 DIJON CEDEX


 _______________________________________________
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

References: 
 >sleep in the NKE unload function (From: Jean Suisse <email@hidden>)

  • Prev by Date: sleep in the NKE unload function
  • Next by Date: Directly creating NSNetService
  • Previous by thread: sleep in the NKE unload function
  • Next by thread: Directly creating NSNetService
  • Index(es):
    • Date
    • Thread