Currently DBusWatcher registers read and write watchers on
the I/O thread unconditionally. Thus for read-only DBusWatch
structures, the write watcher on the I/O thread generates a
significant amount of CPU overhead by constantly reporting
success via calls to OnFileCanWriteWithoutBlocking.
This patch changes DBusWatcher to respect the status flags
of supplied DBusWatch structures. It will only poll for
read or write status if the DBus watch has the corresponding
flag set.
DBus keeps track of these flags and calls the toggle callback
when it needs to wait on a certain DBusWatch.
The use of htons on the network address truncates its value. Using
htonl instead fixes this problem. The change also makes Ril.cpp
build without warnings.
The use of htons on the network address truncates its value. Using
htonl instead fixes this problem. The change also makes Nfc.cpp
build without warnings.
Making a call to mListener with a mMonitor lock is bad. Most of the code
path for ReportConnectionError() are doing this because they are just
after the Connected() method which needs the lock. We ensure to unlock
mMonitor in the scope of the ReportConnectionError() call.
This patch converts DBusWatcher to run on the I/O thread. When a
caller starts DBus, StartDBus creates a new connection and adds
it to the I/O thread's poll loop. DBusWatchers are created and
removed automatically by the DBus libary.
The I/O thread provides all features of the DBus thread. So most
of the existing code has been removed or rewritten. The former
includes the control socket and the DBus thread, the latter is in
the DBusWatcher code.
Using a private DBus connection gives each of its users, such as
Bluetooth, its own connection to the DBus server. This simplifies
the use of DBusWatch structures and ensures that all resources of
a connection are free'd when the connection gets closed.
Bluetooth maintains two connections to the DBus server and the DBus
system itself maintains a third one. This implies some overhead and
makes the code more difficult to understand.
This patch changes the Bluetooth code to use the connection that is
established by the DBus system.
- HAVE_RANDOM is not checked at all.
- HAVE_STRERROR is not checked in code built using the defines from the main
configure.
- HAVE_LCHOWN is only checked in nsinstall.c, which means the test is also wrong
since it's checking for the target instead of the host. Also, lchown is only
used of the -o and -g options of nsinstall, which, as far as I know, we don't
use (and if we were, that would fail with nsinstall.py, which explicitly rejects
them).
- HAVE_FCHMOD is only checked in nsinstall.c, so same as above about the
correctness of the check. If it's not available, nsinstall.c falls back to
chmod, which is fine enough for our use.
- HAVE_SNPRINTF is not checked.
- HAVE_MEMMOVE is checked in parser/expat/lib/xmlparse.c, but it's also
unconditionally defined in expat_config.h which is included from that file.
- HAVE_SETBUF is checked in a couple files, but setbuf is C89 and C99, I think
it's safe to assume all compilers we support are C89 and C99. Interestingly,
windows does have it, but since we skip this check on windows, we don't use it.
- HAVE_ISATTY, same as HAVE_SETBUF, except it's POSIX instead of C89/C99.
- HAVE_FLOCKFILE is not checked at all.
- HAVE_STRTOK_R is not checked.
- HAVE_FT_SELECT_SIZE is not checked.
- HAVE_DLADDR is not checked under js/src.
- HAVE_GETPAGESIZE is not checked under js/src (it is in libffi, but ffi uses
its own configure)
- HAVE_LSTAT64, HAVE_STAT64, HAVE_STATVFS, HAVE_STATVFS64, HAVE_TRUNCATE64 are
not checked under js/src.
- HAVE_SBRK is not checked under js/src. Moreover,
js/src/assembler/wtf/Platform.h defines it depending on the platform.
- HAVE_SNPRINTF is not checked under js/src.
- HAVE_HYPOT is not checked under js/src.
- HAVE__UNWIND_BACKTRACE is not checked under js/src.
UnixSocketImpl, which mostly runs on the I/O thread, doesn't control
its reference to UnixSocketConsumer. If the connection status is
stored in UnixSocketConsumer, the I/O thread can't read it safely.
This patch duplicates the connection status in UnixSocketImpl, where
reading from the I/O thread is safe. Methods of UnixSocketImpl don't
need to access mConsumer any longer to obtain the connection status.