Commit graph

63 commits

Author SHA1 Message Date
Havoc Pennington
f05f87a825 2003-03-15 Havoc Pennington <hp@pobox.com>
* bus/dispatch.c (bus_dispatch_test): OK, now finally actually
	write useful test code, after all that futzing around ;-)

	Test does not yet pass because we can't handle OOM in
	_dbus_transport_messages_pending (basically,
	dbus_connection_preallocate_send() does not prealloc the write
	watch). To fix this, I think we need to add new stuff to
	set_watch_functions, namely a SetEnabled function so we can alloc
	the watch earlier, then enable it later.

	* dbus/Makefile.am (libdbus_convenience_la_SOURCES): move
	dbus-memory.c to the convenience lib

	* bus/test.c: rename some static functions to keep them clearly
	distinct from stuff in connection.c. Handle client disconnection.
2003-03-15 06:00:01 +00:00
Havoc Pennington
4c95a9782c 2003-03-14 Havoc Pennington <hp@redhat.com>
* dbus/dbus-memory.c: add a "detect buffer overwrites on free"
	cheesy hack

	* dbus/dbus-transport-debug.c: rework this a good bit to be
	less complicated. hopefully still works.

	* dbus/dbus-server-debug.c (handle_new_client): remove timeout
	manually

	* glib/dbus-gmain.c (timeout_handler): don't remove timeout
	after running it

	* dbus/dbus-message.c (dbus_message_copy): rename from
	dbus_message_new_from_message, fix it up to copy
	all the message fields, add test case

	* bus/dispatch.c (bus_dispatch_test): add some more test code,
	not quite passing yet
2003-03-15 02:19:02 +00:00
Havoc Pennington
3bea935316 2003-03-13 Havoc Pennington <hp@redhat.com>
* dbus/dbus-timeout.c (_dbus_timeout_list_set_functions): handle
	out of memory

	* dbus/dbus-watch.c (_dbus_watch_list_set_functions): handle out
	of memory

	* dbus/dbus-connection.h: Make AddWatchFunction and
	AddTimeoutFunction return a bool so they can fail on out-of-memory

	* bus/bus.c (bus_context_new): set up timeout handlers

	* bus/connection.c (bus_connections_setup_connection): set up
	timeout handlers

	* glib/dbus-gmain.c: adapt to the fact that set_functions stuff
	can fail

	* bus/bus.c (bus_context_new): adapt to changes

	* bus/connection.c: adapt to changes

	* test/watch.c: adapt to DBusWatch changes

	* bus/dispatch.c (bus_dispatch_test): started adding this but
	didn't finish
2003-03-14 01:27:58 +00:00
Havoc Pennington
6ecc14ffab 2003-03-12 Havoc Pennington <hp@pobox.com>
Throughout: purge global variables, introduce BusActivation,
	BusConnections, BusRegistry, etc. objects instead.

	* bus/bus.h, bus/bus.c: introduce BusContext as a global
	message bus object

	* test/Makefile.am (TEST_BINARIES): disable bus-test for now,
	going to redo this a bit differently I think
2003-03-13 03:52:58 +00:00
Havoc Pennington
29560adcc7 2003-03-12 Havoc Pennington <hp@redhat.com>
Mega-patch that gets the message bus daemon initially handling
	out-of-memory. Work still needed. Also lots of random
	moving stuff to DBusError instead of ResultCode.

	* dbus/dbus-list.c (_dbus_list_length_is_one): new function

	* dbus/dbus-connection.c
	(dbus_connection_send_with_reply_and_block): use DBusError

	* dbus/dbus-bus.c: adapt to API changes, make it use DBusError not
	DBusResultCode

	* dbus/dbus-connection.c (dbus_connection_send): drop the result
	code here, as the only failure possible is OOM.

	* bus/connection.c (bus_connection_disconnect):
	rename bus_connection_disconnected as it's a notification only

	* bus/driver.c (bus_driver_handle_acquire_service): don't free
	"name" on get_args failure, should be done by get_args;
	don't disconnect client for bad args, just return an error.
	(bus_driver_handle_service_exists): ditto

	* bus/services.c (bus_services_list): NULL-terminate returned array

	* bus/driver.c (bus_driver_send_service_lost)
	(bus_driver_send_service_acquired): send messages from driver to a
	specific client to the client's unique name, not to the broadcast
	service.

	* dbus/dbus-message.c (decode_header_data): reject messages that
	contain no name field
	(_dbus_message_get_client_serial): rename to
	dbus_message_get_serial and make public
	(_dbus_message_set_serial): rename from set_client_serial
	(_dbus_message_set_reply_serial): make public
	(_dbus_message_get_reply_serial): make public

	* bus/connection.c (bus_connection_foreach): allow stopping
	iteration by returning FALSE from foreach function.

	* dbus/dbus-connection.c (dbus_connection_send_preallocated)
	(dbus_connection_free_preallocated_send)
	(dbus_connection_preallocate_send): new API for sending a message
	without possibility of malloc failure.
	(dbus_connection_send_message): rename to just
	dbus_connection_send (and same for whole function family)

	* dbus/dbus-errors.c (dbus_error_free): make this reinit the error

	* dbus/dbus-sysdeps.c (_dbus_exit): new function

	* bus/activation.c: handle/return errors

	* dbus/dbus-errors.h: add more DBUS_ERROR #define

	* dbus/dbus-sysdeps.c (_dbus_directory_open) (_dbus_file_get_contents)
	(_dbus_directory_get_next_file): use DBusError instead of DBusResultCode
	(_dbus_result_from_errno): move to this file
2003-03-13 00:56:43 +00:00
Alexander Larsson
fe40189411 2003-02-15 Alexander Larsson <alexl@redhat.com>
* dbus/dbus-threads.c:
	* dbus/dbus-threads.h:
	Add condvars. Remove static mutext from API.
	Implement static mutexes by initializing them from threads_init.

	* glib/dbus-gthread.c:
	* qt/dbus-qthread.cpp:
	Update with the thread api changes.


	* dbus/dbus-list.c:
	* dbus/dbus-list.h:
	Turn StaticMutex into normal mutex + init function.
	Export new functions _dbus_list_alloc_link, _dbus_list_free_link,
	_dbus_list_append_link, _dbus_list_prepend_link


	* dbus/dbus-sysdeps.c:
	* dbus/dbus-sysdeps.h:
	New type dbus_atomic_t, and new functions _dbus_atomic_inc,
	_dbus_atomic_dec. Only slow fallback implementation at the moment.

	* dbus/dbus-protocol.h:
	Add DBUS_MESSAGE_LOCAL_DISCONNECT define

	* dbus/dbus-message.c:
	Make ref/unref atomic.
	Fix some docs.

	* dbus/dbus-connection-internal.h:
	* dbus/dbus-connection.c:
	* dbus/dbus-connection.h:
	Make threadsafe.
	Change _peek to _borrow,_return & _steal_borrowed.
	Change disconnect callback to event.
	Make dbus_connection_dispatch_messages reentrant.

	* dbus/dbus-transport.c:
	Don't ref the connection on calls to the transport
	implementation.

	* dbus/dbus-message-handler.c:
	Make threadsafe.

	* glib/dbus-gmain.c:
	Don't use peek_message anymore

	* test/Makefile.am:
	* test/debug-thread.c:
	* test/debug-thread.h:
	Simple thread implementation that asserts() on deadlocks in
	single-threaded code.

	* test/bus-test.c:
	(main) Call debug_threads_init.

	* test/watch.c:
	Use disconnect message instead of disconnect callback.

	* bus/connection.c:
	* bus/connection.h:
	Don't call dbus_connection_set_disconnect_function. Instead export
	bus_connection_disconnect.

	* bus/dispatch.c:
	Call bus_connection_disconnect when we get a disconnected message.
2003-02-15 16:25:08 +00:00
Anders Carlsson
02dfd4fb34 2003-02-13 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
	Add utils.[ch]

	* bus/connection.c: (bus_connection_foreach):
	Fix a warning.

	* bus/desktop-file.c: (grow_lines_in_section), (grow_sections),
	(unescape_string), (new_section), (parse_section_start),
	(parse_key_value), (report_error), (bus_desktop_file_load),
	(bus_desktop_file_get_string):
	* bus/desktop-file.h:
	Use DBusError for error reporting.

	* bus/dispatch.c: (send_one_message),
	(bus_dispatch_message_handler):
	* bus/driver.c: (bus_driver_send_service_deleted),
	(bus_driver_send_service_created), (bus_driver_send_service_lost),
	(bus_driver_send_service_acquired), (bus_driver_handle_hello),
	(bus_driver_send_welcome_message),
	(bus_driver_handle_list_services),
	(bus_driver_handle_acquire_service),
	(bus_driver_handle_service_exists):
	* bus/loop.c: (bus_loop_run):
	* bus/main.c:
	Use BUS_HANDLE_OOM instead of _DBUS_HANDLE_OOM.

	* bus/utils.c: (bus_wait_for_memory):
	* bus/utils.h:
	New files with general utility functions.

	* dbus/dbus-internals.h:
	Remove _DBUS_HANDLE_OOM.
2003-02-13 19:06:42 +00:00
Anders Carlsson
39dd1fcee6 2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
	* bus/connection.c: (connection_disconnect_handler),
	(connection_watch_callback), (bus_connection_setup):
	* bus/dispatch.c: (send_one_message),
	(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
	(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
	* bus/dispatch.h:
	* bus/driver.c: (bus_driver_send_service_deleted),
	(bus_driver_send_service_created), (bus_driver_handle_hello),
	(bus_driver_send_welcome_message),
	(bus_driver_handle_list_services), (bus_driver_remove_connection),
	(bus_driver_handle_message):
	* bus/driver.h:
	Refactor code, put the message dispatching in its own file. Use
	_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
	is disconnected.
2003-01-25 20:53:53 +00:00
Anders Carlsson
a16e83f45d 2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/connection.c: (bus_connection_foreach):
	* bus/connection.h:
	Add new bus_connection_foreach function.

	* bus/driver.c: (send_one_message), (bus_driver_broadcast_message):
	Add function that broadcasts a message to all clients.

	(bus_driver_send_service_created), (bus_driver_handle_hello),
	(bus_driver_send_welcome_message),
	(bus_driver_handle_list_services), (bus_driver_message_handler):
	Implement functions that take care of listing services, and notifying
	clients when new services are created.

	* bus/services.c: (bus_services_list):
	* bus/services.h:
	Add new function that returns an array of strings with the currently
	registered services.

	* glib/dbus-glib.h:
	* glib/dbus-gmain.c:
	Update copyright year.
2003-01-24 23:51:59 +00:00
Anders Carlsson
aff24a72c1 2003-01-21 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
	Add driver.[ch]

	* bus/connection.c: (connection_disconnect_handler):
	Remove the connection from the bus driver's list.

	(connection_watch_callback): Dispatch messages.

	(free_connection_data): Free connection name.

	(bus_connection_setup): Add connection to the bus driver's list.
	(bus_connection_remove_owned_service):
	(bus_connection_set_name), (bus_connection_get_name):
	Add functions for setting and getting the connection's name.

	* bus/connection.h:
	Add function headers.

	* bus/driver.c: (create_unique_client_name),
	(bus_driver_handle_hello_message),
	(bus_driver_send_welcome_message), (bus_driver_message_handler),
	(bus_driver_add_connection), (bus_driver_remove_connection):
	* bus/driver.h:
	* bus/main.c:
	* bus/services.c: (bus_service_free):
	* bus/services.h:
	New file that handles communication and registreation with the bus
	itself.
2003-01-21 12:42:33 +00:00
Havoc Pennington
0363701c34 2003-01-18 Havoc Pennington <hp@pobox.com>
* dbus/dbus-connection.c (dbus_connection_unref): disconnect the
	connection if it hasn't been already.

	* dbus/dbus-connection.h: kill off the idea of an ErrorFunction,
	replace with DisconnectFunction.
2003-01-18 17:40:42 +00:00
Anders Carlsson
1b9a4589f6 2003-01-14 Anders Carlsson <andersca@codefactory.se>
* bus/connection.c: (connection_error_handler),
	(bus_connection_setup):
	* bus/main.c: (main):
	Make sure that the DBusConnectionData struct is NULLed
	out to prevent a segfault.

	* dbus/dbus-errors.c: (dbus_result_to_string):
	* dbus/dbus-errors.h:
	* dbus/dbus-message.c: (dbus_message_get_fields),
	(dbus_message_get_fields_valist), (_dbus_message_test):
	* dbus/dbus-message.h:
	Make dbus_message_get_fields return a result code so we can
	track invalid fields as well as oom.
2003-01-14 11:19:06 +00:00
Havoc Pennington
96a9f80300 2003-01-05 Havoc Pennington <hp@pobox.com>
* bus/connection.c: implement routines for handling connections,
	first thing is keeping a list of owned services on each connection
	and setting up watches etc.

	* bus/services.c: implement a mapping from service names to lists
	of connections

	* dbus/dbus-hash.c: add DBUS_HASH_POINTER

	* dbus/dbus-threads.c (dbus_static_mutex_lock): add functions
	to use static mutexes for global data

	* dbus/dbus-connection.c (dbus_connection_set_data): add new
	collection of functions to set/get application-specific data
	on the DBusConnection.
2003-01-06 01:08:14 +00:00