init: Safely restart services to avoid race conditions.

Previously, service restarts (either an explicit "restart", or a "stop,
start" pair) exhibited a race condition whereby the new (restarting)
service process was often spawned before the old (stopping) process had
terminated.  This may have resulted in the new service process failing to
acquire a limited resource (file lock, socket bind, etc.) that the old
process had not yet released.

Now, a stopping service remains in the SVC_RUNNING state until its exiting
process has been reaped by waitpid.  This prevents a "stop, start" sequence
from spawning a second service process before resources held by the first
are released.  This enables safe service restarts by stopping the service,
waiting for the old service process to terminate, and (only then) starting
the new service process.  In the event of "restarting" an already stopped
service, the previous behavior is maintained whereby the service is simply
started.

This scenario could be special-cased by the restart command, however, we
have observed instances where services are, unintentionally, stopped and
started "too quickly," and so simultaneous processes for the same service
should never be allowed.

Note that this commit alters the behaviors for explicit restarts of
critical and oneshot services.  Previously these serivces would simply be
restarted, whereas now, an explicit restart of a critical service counts as
a crash (which may result in a recovery reboot) and oneshot services go
into the disabled state.
init: Retain traditional restart behavior for critical and oneshot services.

Adds an SVC_RESTART state that's used for an explicit "restart" of a
running service.  This retains the traditional restart behavior for
critical and oneshot services (previously altered by 7e36edd8), whereby
these services are "simply restarted" instead of counting as a crash (for a
critical serivce) or going into the disabled state (for a oneshot service).
Add Mips memset speedup

Change-Id: I157aa8b500e271c213bf615dd4ceb25b3aedd7c2
fs_mgr_priv: Extend fs wait timeout to 20 seconds

In practice 5 seconds is too short to wait for a disk device node to
show up if the disk is USB; 20 seconds is a much more comfortable
window.

Change-Id: Iaf2c1f46b41a44fc1240d52d8498ca9cb639ea80
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
cutils: bitops: Add Hamming weight to bitmask

Change-Id: I5c6b7adf711007edfffcb4fdf8e05b04bcffef54
Merge "cutils: bitops: Add Hamming weight to bitmask"
am 4c609e96: Remove CAP_NET_RAW from adb

* commit '4c609e9683959193dafd7a32bb8393410cbddc74':
  Remove CAP_NET_RAW from adb
am 277626e5: am 844306bd: am cc4499b6: Merge "adb: use correct header file."

* commit '277626e59dc0ccbf0337ec6615622f46e6f958fd':
  adb: use correct header file.
am d1439a7f: am b3be89df: am 3fb63338: Merge "android_filesystem_config.h: change ping and run-as"

* commit 'd1439a7f8eb228eb39dd74845a5e46d20c63b3b0':
  android_filesystem_config.h: change ping and run-as
Reconcile with jb-mr2-release - do not merge

Change-Id: I20987b51211410332c427eb876334b0c6a9bcc32
am 68fa5114: (-s ours) Reconcile with jb-mr2-release - do not merge

* commit '68fa5114fe56297763a50a9090793eaae300aaa2':
  Add directory for mediaserver
am 7c646cd3: am af4ececc: am 515bed0e: Merge "run-as:  set the SELinux security context."

* commit '7c646cd3594283bc4aaf53a0b10143a76281270f':
  run-as:  set the SELinux security context.
am 95b087fa: am 79d4381a: am 69f3ec84: Merge "Fix issues where the filename is referred to as \'sideload\'"

* commit '95b087fa90c89b21d18268c84167d1407f9e7905':
  Fix issues where the filename is referred to as 'sideload'
am bf6982ce: am 7c646cd3: am af4ececc: am 515bed0e: Merge "run-as:  set the SELinux security context."

* commit 'bf6982cec4b258f3e87d70d1767d69ab30e72ad2':
  run-as:  set the SELinux security context.
am ed64c3ff: am 95b087fa: am 79d4381a: am 69f3ec84: Merge "Fix issues where the filename is referred to as \'sideload\'"

* commit 'ed64c3ff536ea122a430b4cd42aa6e7a56454ba7':
  Fix issues where the filename is referred to as 'sideload'
am 81b5b5fb: sync: factor sw_sync functionality out of header

* commit '81b5b5fb02a59a443877363b1451328c7ad11fb2':
  sync: factor sw_sync functionality out of header
am 00977e58: am 81b5b5fb: sync: factor sw_sync functionality out of header

* commit '00977e5833a25bffd96d446ee39a25a6baf41a19':
  sync: factor sw_sync functionality out of header
am 4c8c35d0: Merge "move goldfish stuffs to device/generic/goldfish" into jb-mr2-dev

* commit '4c8c35d06ce6a673c6e015b809f94da0083cd4cc':
  move goldfish stuffs to device/generic/goldfish
am 6a955d72: am 4c8c35d0: Merge "move goldfish stuffs to device/generic/goldfish" into jb-mr2-dev

* commit '6a955d72ff8b5d4daafe9ce4df6d94d3effa99ea':
  move goldfish stuffs to device/generic/goldfish
ueventd: allow platform devices to have just a /devices/ prefix

When using device tree, platform devices may not have a
/devices/platform/ path prefix, but can be rooted in
/devices/.

Modify the platform device tracking code to store the device
path as well as the name. This way, when we create symlinks, we
can correctly skip the base platform device prefix and get to the
proper device node path.

Change-Id: I939ef8fbcb45c5c803cd9a054e40136a912efc72
Signed-off-by: Dima Zavin <dima@android.com>