Commit graph

2109 commits

Author SHA1 Message Date
Christian Persch (GNOME)
fe86222d10 Bug 21657 - Fix configure checks for va_list in maintainer mode
Include the right headers.
2009-07-10 19:40:00 -04:00
Tobias Mueller
5baf2f856a Bug 21161 - Update the FSF address
No comment.

Signed-off-by: Colin Walters <walters@verbum.org>
2009-07-10 19:32:38 -04:00
Colin Walters
1f6ac4deef Bug 21646 - Fix a signed char comparison
Original suggested patch from Marc-Andre Lureau <marcandre.lureau@gmail.com>

Explicitly cast to unsigned char before we do comparisons.
2009-07-10 19:26:52 -04:00
Colin Walters
e5310abd6c Add missing include for unistd.h in test-service.c
We use usleep here.
2009-07-10 19:22:54 -04:00
Kurt Miller
644fc38b24 Bug 21347 - Don't fail autolaunching if process has SIGCHLD handler
If other code in the process set a global SIGCHLD handler, it
will make autolaunching fail spuriously due to waitpid() failing.

This fix will temporarily block SIGCHLD delivery.

Signed-off-by: Colin Walters <walters@verbum.org>
2009-07-10 19:19:28 -04:00
Scott James Remnant
3f07008823 dbus_message_append_args_valist - abandon container
In case of OOM when constructing an array, we should abandon the
container to free the resources.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
2009-07-09 16:35:13 +01:00
Scott James Remnant
e57a368c44 bfo22316 - add dbus_message_iter_abandon_container()
It's not currently possible to abandon creation of a container without
either hitting asserts or leaking memory.  This new function allows
that.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
2009-07-09 16:34:54 +01:00
Scott James Remnant
4bea3ca2b0 Add test case for assert when unwinding a container.
* dbus/dbus-message-util.c: when constructing an array of structures,
it's not possible to unwind in case of an error part-way through.
This test will therefore assert.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
2009-07-09 16:28:29 +01:00
Scott James Remnant
0ee5d8e155 Bump configure.in for GIT
Signed-off-by: Scott James Remnant <scott@ubuntu.com>
2009-07-09 16:23:43 +01:00
Scott James Remnant
c1f165261a Add tests for pending call timeouts
* test/test-service.c (handle_delay_echo, path_message_func): Add a
  variant of the Echo method which sleeps for a short time.
* test/name-test/test-pending-call-timeout.c: Run tests with default,
  specified and infinite timeout to make sure we get the reply.
* test/name-test/run-test.sh: Run the new test
* test/name-test/Makefile.am: Build the new test

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
2009-05-28 11:47:38 +02:00
Scott James Remnant
bd2063e17e Unrestrict session bus timeout.
* bus/session.conf.in: Remove the reply_timeout stanza, previously
  intended to increase the reply timeout, this now reduces it.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
2009-05-28 11:47:37 +02:00
Scott James Remnant
8f1d2a2fa8 Change default reply timeout.
* bus/config-parser.c (bus_config_parser_new): change the default reply
  timeout to "never"

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
2009-05-28 11:47:36 +02:00
Scott James Remnant
d672d03206 Expire list timeout may be negative for no expiry.
* bus/expirelist.c (do_expiration_with_current_time): Don't check for
  expiry if expire_after is negative, will just disable the expiry timer
  after the call.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
2009-05-28 11:47:35 +02:00
Scott James Remnant
d33cfec625 Explicitly check for zero time fields.
* bus/expirelist.c (do_expiration_with_current_time): If the item added
  time fields are both zero, always expire.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
2009-05-28 11:47:35 +02:00
Scott James Remnant
7398ad7374 Remove 6 hour timeout restriction.
* dbus/dbus-pending-call.c (_dbus_pending_call_new_unlocked): Now that
  the timeout math won't overflow, don't clamp to six hours.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
2009-05-28 11:47:34 +02:00
Scott James Remnant
1faa92114f Fix issue where timeouts can overflow.
* dbus/dbus-connection.c (_dbus_connection_block_pending_call): Rework
  the timeout math so instead of calculating an end time, which may
  overflow, we instead calculate the elapsed time which is always
  smaller than the boundaries.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
2009-05-28 11:47:33 +02:00
Scott James Remnant
ce0d932d9b Update documentation now that INT_MAX means no timeout.
* dbus/dbus-connection.c (dbus_connection_send_with_reply): Fix
  documentation now that INT_MAX will not be clamped.
  (dbus_connection_send_with_reply_and_block): Update documentation too.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
2009-05-28 11:47:32 +02:00
Scott James Remnant
92dd55c903 Don't allocate DBusTimeout for pending call when passed INT_MAX
* dbus/dbus-pending-call.c (_dbus_pending_call_new_unlocked): When passed
  INT_MAX, do not clamp the value and do not allocate a timeout for the call
  (_dbus_pending_call_get_timeout_unlocked): Document that this may return
  NULL.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
2009-05-28 11:47:31 +02:00
Scott James Remnant
e5eb472d11 Allow a pending call to block forever
* dbus/dbus-connection.c (_dbus_connection_block_pending_call): Allow the
  pending call to have no timeout, in which case we simply block until we
  complete, have data or get disconnected.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
2009-05-28 11:47:30 +02:00
Scott James Remnant
ba22606c3b Make sure a pending call timeout isn't assumed.
* dbus/dbus-connection.c (_dbus_connection_attach_pending_call_unlocked):
  Don't assume that the pending call has a timeout.
  (connection_timeout_and_complete_all_pending_call_unlocked): check that
  the timeout was actually added before removing it; this safeguards us
  if the pending call doesn't have a timeout.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
2009-05-28 11:47:21 +02:00
Lennart Poettering
89f70b1949 bus: don't forward messages with unix fds on connections that don't support it
This simply verifies that we forward unix fds only on connection that
support it. We willr eturn an error if a client attempts to send a
message with unix fds to another client that cannot do it.
2009-05-21 01:21:35 +02:00
Lennart Poettering
724adb2f61 doxygen: document that we don't support reading/writing arrays of unix fds in once piece right now 2009-05-20 23:48:46 +02:00
Lennart Poettering
869291ea5a doc: document Unix FD passing in the specification 2009-05-20 03:01:37 +02:00
Lennart Poettering
64ad844967 bus: make use of new unix fd limits
Create configuration settings and enforce message unix fd limits the
same way we do for allocated message memory.
2009-05-20 02:10:17 +02:00
Lennart Poettering
bfad32422f unix-fd: add logic to count unix fds the same way as allocated memory
This make all counters count both bytes of memory and unix fds.
2009-05-20 02:09:32 +02:00
Lennart Poettering
ec901d786f byteswap: make use of glibc specific bytswap primitives
glibc knows three bswap_{16|32|64}() calls that internally make use of a
gcc extension to implement faster byteswapping. We should make use of it
if we can.
2009-05-20 02:09:32 +02:00
Lennart Poettering
9293e82376 atomic: implement atomic operations based on gcc's __sync extension
Newer gccs and intel ccs support a __sync extension for making use of
atomic operations. This patch replaces the handcrafted x86 atomic
operation support with usage of __sync.

__sync is supported by more processors and by more compilers than the
old assembler code. Also, this extension has been available on gcc for
quite a while now for x86, so replacing the old assembler code should
only be a loss when very old compiilers are used.
2009-05-20 02:09:32 +02:00
Lennart Poettering
74bff5af80 git: enable whitespace checking commit hook during in autogen.sh
Trailing whitespace sucks. This change modifies autogen.sh to activate
the example pre-commit that ships with git. It will make sure that from
then on no further commits with trailing whitespace can be made
2009-05-20 02:09:32 +02:00
Lennart Poettering
cbf0874f01 memset: replace memset() by _DBUS_ZERO where applicable 2009-05-20 02:09:31 +02:00
Lennart Poettering
c200e0304d auth: add fd passing negotiation support
This adds two new directives to the auth protocol:

NEGOTIATE_UNIX_FD is sent by the client after the authentication was
sucessful, i.e. OK was received.

AGREE_UNIX_FD is then sent by the server if it can do unix fd passing as
well.

ERROR is returned when the server cannot or is unwilling to do unix fd
passing.

This should be compatible with existing D-Bus implementations which will
naturally return ERROR on NEGOTIATE_UNIX_FD.
2009-05-20 02:09:31 +02:00
Lennart Poettering
89318bbeb4 cloexec: set all sockets that are created with SOCK_CLOEXEC
Since all socket users enable FD_CLOEXEC anyway we can just do that in
_dbus_open_socket() and be done with it for all cases. By side effect
this allows us to use SOCK_CLOEXEC and hence close the CLOEXEC race.
2009-05-20 02:09:31 +02:00
Lennart Poettering
3c319c7193 cloexec: make use of pipe2(O_CLOEXEC) when available
This should fix another CLOEXEC race.
2009-05-20 02:09:31 +02:00
Lennart Poettering
18b08180aa build-system: define _GNU_SOURCE centrally
Instead of having everyone define _GNU_SOURCE and similar macros
seperately, simply do so centrally by using AC_USE_SYSTEM_EXTENSIONS
2009-05-20 02:09:31 +02:00
Lennart Poettering
44f3a1465a cloexec: set FD_CLOEXEC for all full duplex pipes
All users of full duplex pipes enable FD_CLOEXEC later anyway so let's
just do it as part of _dbus_full_duplex_pipe. By side effect this allows
to make use of SOCK_CLOEXEC which fixes a race when forking/execing from
a different thread at the same time as we ar in this function.
2009-05-20 02:09:31 +02:00
Lennart Poettering
004f01fa45 unix-fd: add test for passing unix fds
This adds a full test for passing multiple fds across a D-Bus
connection.
2009-05-20 02:09:30 +02:00
Lennart Poettering
2eb14dbcac unix-fd: when sending a message with unix fds verify that the connection can do it
Not all of the send function flavours allow returning proper error
codes. For the cases where this is not easily possible the client should
call dbus_connection_can_send_type() first.
2009-05-20 02:09:30 +02:00
Lennart Poettering
08e49d9b53 unix-fd: introduce dbus_connection_can_send_type()
This is just a wrapper around _dbus_transport_can_pass_unix_fd() however
it is more generic.

The reason for keeping this generic is to ease later addition of more
types without having to add a new API for that.
2009-05-20 02:09:30 +02:00
Lennart Poettering
a0cc21f8bb unix-fd: add message encoding/decoding for unix fds
When appending unix fds to the message a new entry in the fd array will
be allocated and the index to it will be written to the message payload.

When parsing unix fds from the message the index will be read from the
payload and then looked up in the fd array.

When we read fds we put them in a queue first. Since each message knows
how many fds are attached to it we will then pop enough fds from this
queue each time we decode a message from the stream.

This should make sending and receiving more portable since we don't make
any strong requirements on the exact semantics of the SCM_RIGHTS
implementation: as long as fds are recieved in order, none or lost and
the arrive at the same time as at least one byte from the actual message
dat we should be able to handle them correctly.
2009-05-20 02:09:03 +02:00
Lennart Poettering
ba7daa606c unix-fd: add basic marshalling code for unix fds
This is actually pretty boring since we store our fds as indexes that
are stored as uint32_t's.
2009-05-20 01:36:44 +02:00
Lennart Poettering
faac66e3ea unix-fd: introduce basic protocol definitions
We introduce a new type code for the unix fds. The data stored in unix
fd fields will be an integer index into the array of fds that are
attached to a specific message. We also introduce a new header field
that stores how many fds belong to the message. And finally we introduce
a new error for messages where the payload and the meta data (i.e. unix
fds read for it) don't match up.
2009-05-20 01:36:37 +02:00
Lennart Poettering
4c4db7f9da sysdeps-unix: add basic IO primitives for unix fd passing
This introduces three new functions:

_dbus_read_socket_with_unix_fds
_dbus_write_socket_with_unix_fds
_dbus_read_socket_with_unix_fds_two

These work exactly like their counterpart sans 'with_unix_fds' except
that they also send/recieve file descriptors along with the actual
payload data.
2009-05-20 01:36:27 +02:00
Lennart Poettering
64c63db21e sysdeps-unix: introduce _dbus_socket_can_pass_unix_fd()
This function can be used to check if a socket can be used to pass file
descriptors. On platforms that don't support this at all this is
hardcoded to return FALSE.
2009-05-20 01:36:26 +02:00
Lennart Poettering
18f7259a43 sysdeps-unix: introduce _dbus_dup()
This is a simple wrapper around dup()-like functionality.

Also handles CLOEXEC and makes sure we don't interfere with the standard
I/O file descriptors 0, 1 and 2.
2009-05-20 01:36:19 +02:00
Lennart Poettering
03d50fbd77 sysdeps-unix: if MSG_NOSIGNAL is available don't touch SIGPIPE by default
If we can use MSG_NOSIGNAL we don't have to play games with SIGPIPE
2009-05-15 20:30:15 +02:00
Lennart Poettering
ff0a8993d4 sysdeps-unix: Use MSG_NOSIGNAL when available
On Linux send()/sendmsg() know the special flag MSG_NOSIGNAL which if
set makes sure that no SIGPIPE signal is raised when we write to a
socket that has been disconnected.

By using this flag we don't have to play games with SIGPIPE which is
pretty ugly stuff since it touches the global process context.
2009-05-15 20:30:15 +02:00
Lennart Poettering
6d2eacba89 memory: remove semicolons from macros
Due to some unknown reasons the dbus_new() macros had a semicolon at the
end which makes it impossible to use them in some situations.
2009-05-15 20:30:15 +02:00
Lennart Poettering
3801b6de78 build-system: get rid of config.h inclusion checks
These header files include config.h explicitly anyway. These checks are
hence pointless.

Of course one could argue that including config.h from header files
sucks, but D-Bus generally seems not to have a problem with that, so
let's unify this.
2009-05-15 20:30:15 +02:00
Thiago Macieira
f322112b84 Merge branch 'dbus-1.2' 2009-05-13 15:52:26 +02:00
Thiago Macieira
e21d06cba4 Merge branch 'dbus-1.2'
Conflicts:
	dbus/dbus-sysdeps-util-unix.c
2009-05-13 15:52:18 +02:00
Marc Mutz
6eddb6e122 configure.in: fail abstract socket test gracefully when cross-compiling
* configure.in: only run AC_CACHE_CHECK if enable_abstract_sockets=auto
 * configure.in: warn that, when cross-compiling, we're unable to detect
                 abstract sockets availability automatically

Signed-off-by: Thiago Macieira <thiago@kde.org>
2009-05-13 15:50:52 +02:00