Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

port_create race test and fix #215

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Commits on Dec 22, 2017

  1. app/tests/port_tests.c: add two_threads_race test

    This change adds a test to the port_tests suite
    to trigger the port_create() race.  When tested with
    an SMP (3) qemu instance, the race is discovered in
    less than twenty iterations and often much sooner.
    redpig committed Dec 22, 2017
    Configuration menu
    Copy the full SHA
    bc69ded View commit details
    Browse the repository at this point in the history
  2. kernel/port.c: protect against port_create() race

    In the current design, ports may be created with the same name
    because of time-of-check-time-of-use behavior.
    
    This change adds a new port magic, PORTHOLD_MAGIC, which cannot be
    accessed using the normal accessors. It is injected into the list
    upon a successful, locked search for a name.  It holds the name
    until the allocation happens. At which point the port-hold is
    deleted and the real port is added while, again, under the thread
    lock.
    
    This change assumes using a stack-allocated port is desirable over
    preallocating and freeing on each port_create().  If the overhead
    of allocation is low, then pre-allocating the new port would be
    the cleanest option: (1) allocate, (2) check for collisions,
    (3) add to list.
    
    This fix is confirmed by the two_threads_race test completing its
    256 iterations without a race. It also fixes the test to expect
    ERR_BUSY and to exit cleanly, as it had never completed before.
    redpig committed Dec 22, 2017
    Configuration menu
    Copy the full SHA
    e08ca47 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    0f939a5 View commit details
    Browse the repository at this point in the history
  4. app/tests/port_tests.c: static-ify consts

    This change makes the shared constants static
    as well as const-ifies shared packets.
    redpig committed Dec 22, 2017
    Configuration menu
    Copy the full SHA
    1c59a73 View commit details
    Browse the repository at this point in the history