projectbismark/bismark-active — pull request #1 by sburnett (2013-09-10 03:17:00+00:00)
Title: Migrate to new shared mlock

This will let other experiments reserve the uplink for active measurements.

This change only migrates the mlock to a new shared lock. It doesn't fix existing locking problems with DITG.

I've tested the functions on x86. I haven't tested my other modifications yet:

sburnett@univers:~/git/bismark$ source device/OpenWrt_common/lib/functions.inc.sh
sburnett@univers:~/git/bismark$ ACTIVE_MEASUREMENTS_LOCK_FILE=/tmp/active-lock
sburnett@univers:~/git/bismark$ ACTIVE_MEASUREMENTS_MAX_DURATION_SECONDS=3

sburnett@univers:~/git/bismark$ acquire_active_measurements_lock; echo $?
0 # Acquire succeeded.
sburnett@univers:~/git/bismark$ acquire_active_measurements_lock; echo $?
acquire_active_measurements_lock:2: file exists: /tmp/active-lock
1 # Acquire failed because lock already acquired.

sburnett@univers:~/git/bismark$ release_active_measurments_lock; echo $?
0 # Lock released.
sburnett@univers:~/git/bismark$ release_active_measurments_lock; echo $?
rm: can't remove '/tmp/active-lock': No such file or directory
1 # Lock cannot be released because it was already acquired.

sburnett@univers:~/git/bismark$ acquire_active_measurements_lock; echo $?
0
sburnett@univers:~/git/bismark$ sleep 15
sburnett@univers:~/git/bismark$ expire_active_measurements_lock; echo $?
0
sburnett@univers:~/git/bismark$ acquire_active_measurements_lock; echo $?
0 # Acquire succeeded because expire_active_measurements_lock released the lock after 10 seconds.

sburnett@univers:~/git/bismark$ sleep 3
sburnett@univers:~/git/bismark$ expire_active_measurements_lock; echo $?
0
sburnett@univers:~/git/bismark$ acquire_active_measurements_lock; echo $?
acquire_active_measurements_lock:2: file exists: /tmp/active-lock
1 # Acquire failed because expire_acitve_measurements_lock didn't release the lock after 3 seconds.