summaryrefslogtreecommitdiff
path: root/trusty/coverage/coverage.cpp
diff options
context:
space:
mode:
authorSpencer Low <CompareAndSwap@gmail.com>2015-07-24 15:38:19 -0700
committerSpencer Low <CompareAndSwap@gmail.com>2015-07-31 15:13:52 -0700
commitc3211557b3a7f1021878399a1e2574e697e92c24 (patch)
treee093fd5f77f13f10ca4281ff56f52aea88993bf6 /trusty/coverage/coverage.cpp
parent0f91887868e51de67bdf9aedc97fbcb044dc1969 (diff)
adb: win32: file descriptor reliability improvements
When repeatedly opening and closing a file descriptor, the sequence of fds returned was: 100...227,100,100,100,100,100... Basically, the first wave was constantly increasing fds, but after the entire fd table was traversed once, the alloc algorithm would switch to returning the first free fd. This is sub-optimal for reliability because use-after-free bugs would be more likely to be hit because right after a close, the same fd would be given out next. This change makes the alloc algorithm use a persistent clock hand that walks forward through the fd table (wrapping around if necessary), searching for a free fd. This change adds locking for fd closing: - This prevents multiple concurrent closes of the same fd. - There was a race between alloc and close that wasn't guaranteed to be correct: close would set f->clazz to NULL last, but without any preceding memory barrier/fence, then the alloc thread would check for NULL. It probably worked out ok in practice, but it is probably best to fix this up with a lock (as in this change) or a memory barrier/fence (but this code isn't about performance, so why go with a complicated barrier/fence?) Also in this change: - Use errno = EMFILE for the out of fds case. - Clear FH->name Change-Id: Ic11d2a1a9d53996edfc1ca13566a2f46de4a4316 Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
Diffstat (limited to 'trusty/coverage/coverage.cpp')
0 files changed, 0 insertions, 0 deletions