Bug 820438 - Immediately apply changes in maximum script runtime to make them visible in content processes. r=jst
Bug 836523 - Protect mCurrentTaskIsCanceled by lock. r=qdot, r=echou

The main thread and the I/O thread concurrently access the field
mCurrentTaskIsCanceled in UnixSocketImpl. Protect it by a lock.
Bug 836523 - Wait for incoming connections in UnixSocketImpl. r=qdot, r=echou

The UnixSocketImpl currently polls the socket file descriptor while
listening for incoming connections and schedules itself to run again
if no connection requests have been received.

This behavior interferes with closing the socket and deleting the
socket structure in the main thread. It can happen that the I/O thread
dispatches a SocketAcceptTask to poll the listening socket and the
main thread dispatches a DeleteInstanceRunnable for the UnixSocketImpl,
such that the delete operation gets dispatched before the poll
operation. The latter then operates on the just deleted UnixSocketImpl.

With this patch, the I/O thread watches the listing socket for incoming
connection requests and only attempts to run accept when connection
requests are pending. This allows to serialize polling and close
operations within the I/O thread in a sound order.

A side effect of this patch is that we don't constantly run code for
polling the listing socket, which should result in less CPU overhead
and save battery power.
Bug 836523  - Cleanup UnixSocketImpl from within I/O thread. r=qdot, r=echou

When closing a socket from within the main thread, we need to make
sure that the I/O thread does not operate on the related instance of
UnixSocketImpl.

With this patch, the main thread posts a SocketCloseTask to the I/O
thread. The SocketCloseTask removes the socket from the I/O thread's
list of watched file descriptors and dispatches an instance of
DeleteInstanceRunnable for the socket's UnixSocketImpl, which cleans
up the data structures. These steps serialize the close operation
within the I/O thread, and ensure that the main thread processed all
other dispatched runnables that may use the UnixSocketImpl.