summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* client: check for error in wl_display_read_eventsMarek Chalupa2014-08-221-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | This prevents from blocking shown in one display test. Also, it makes sense to not proceed further in the code of the function when an error ocurred. v2. set errno put note about the errno into wl_display_prepare_read doc check for error with mutex locked v3. set errno to display->last_error check for the error only in wl_display_read_events. It's sufficient as prevention for the hanging and programmer doesn't need to check if wl_display_prepare_read (that was previously covered by this patch too) returned an error or the queue just was not empty. Without the check, it could result in indefinite looping. Thanks to Pekka Paalanen <pekka.paalanen@collabora.co.uk> for constant reviewing and discussing this patch. Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* client: broadcast the right pthread_cond variableMarek Chalupa2014-08-221-0/+16
| | | | | | | | | | In previous commit we removed unused variables. One of them was pthread_cond_t that was formerly used when reading from display, but later was (erroneously) made unused. This patch fixes this error and is a fix for the failing test introduced few patches ago (tests: test if thread can block on error) Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* client: drop unused event queue cond and list variablesOlivier Blin2014-08-221-22/+0
| | | | | | | | | | | | | | | | | | | | | | | The wl_event_queue cond variable has been replaced by the wl_display reader_cond variable (commit 3c7e8bfbb4745315b7bcbf69fa746c3d6718c305). This cond variable is never waited for anymore, just signaled/broadcasted, and thus can be safely removed. The wl_display event_queue_list and link from wl_event_queue can be removed as well, since it was only used to iterate over the event queue list in order to broadcast the now unused cond. No regression on queue unit tests. Signed-off-by: Olivier Blin <olivier.blin@softathome.com> v2: fixed and rebased after 886b09c9a3a9d8672039f09fe7eaf3f2b2b012ca added signed-off-by v3: removed link from wl_event_queue Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* client: remove unused variableMarek Chalupa2014-08-211-1/+0
| | | | | | | | display_thread variable is unused since 3c7e8bfbb4745315b7bcbf69fa746c3d6718c305 Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* server: Don't expose wl_display as a globalJasper St. Pierre2014-08-211-20/+8
| | | | | | | | | | | | | | | | | | | | The idea here was that once upon a time, clients could rebind wl_display to a higher version, so we offered the ability to rebind it here. However, this is particularly broken. The existing bind implementation actually still hardcodes version numbers, and it leaks previous resources, overwriting the existing one. The newly bound resource *also* won't have any listeners attached by the client, meaning that the error and delete_id events won't get delivered correctly. Unless the client poked into libwayland internals, it also can't possibly set up these handlers correctly either, so the client will sustain errors and leak all deleted globals. Since this never worked correctly in the first place, we can feel safe removing it. Acked-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* client: add a public function to make a roundtrip on a custom queueGiulio Camuffo2014-08-212-3/+23
| | | | | | | wl_display_roundtrip() works on the default queue. Add a parallel wl_display_roundtrip_queue(). Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* event-loop: make signalfd non-blockingMarek Chalupa2014-08-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | When we add more that one source to a signal, then wayland will block in wl_event_loop_dispatch. This is due to the attampt to read from signal's fd each time the source is dispatched. wl_event_loop_add_signal(loop, SIGINT, ...); wl_event_loop_add_signal(loop, SIGINT, ...); /* raise signal .. */ /* we got two fd's ready, both for the one SIGINT */ epoll_wait(...) = 2 [ for (i == 0) ] source1->dispatch() --> read(fd1); [ for (i == 1) ] source2->dispatch() --> read(fd2); /* blocking! */ Reading from fd2 will block, because we got only one signal, and it was read from fd1. Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* scanner: Make emit_structs more explicitJasper St. Pierre2014-08-181-13/+12
| | | | | | | | | "is_interface" is a really terrible name for the client or server variants, and instead of checking whether we were passed the requests or the events, just pass an argument through. Reviewed-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* scanner: Use an enum to determine the type of thing we're writing outJasper St. Pierre2014-08-181-6/+11
| | | | | Reviewed-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* server: fix conditions for fds in wl_socket_destroyPekka Paalanen2014-08-071-7/+20
| | | | | | | | | | | | | | | 0 is also a valid fd, and needs to be closed. On error we set fd to -1. We need to also initialize fds to -1, so we do not accidentally close stdout on error. While fixing this, also remove one use-before-NULL-check. Based on the patch by Marek. Cc: Marek Chalupa <mchqwerty@gmail.com> Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
* server: fix error handling when adding socketMarek Chalupa2014-08-071-7/+16
| | | | | | | | | | | When some function during adding socket fails, it must clean everything it set or we can get funky errors. This patch fixes: http://lists.freedesktop.org/archives/wayland-devel/2014-August/016331.html Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* server: move memset after checkMarek Chalupa2014-08-071-1/+2
| | | | | | If the malloc fails, memset would touch invalid memory. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* server: Add a simple API to find a good default displayJasper St. Pierre2014-08-052-25/+74
| | | | This allows compositors to easily select a good display to listen on.
* server: Save the display name in the wl_socketJasper St. Pierre2014-08-051-0/+3
| | | | This allows us to return the display name to the client in a new API.
* server: Make get_socket_lock operate directly on the socket's lock_fdJasper St. Pierre2014-08-051-11/+11
|
* server: Split out code to initialize the socket address for a display nameJasper St. Pierre2014-08-051-16/+27
| | | | We'll use this to autodetect a good socket to open on.
* server: Create the socket FD after taking the lockJasper St. Pierre2014-08-051-6/+6
| | | | | We're going to split out the lock-taking to another function so we can repetitively try locks.
* server: Clean up socket destructionJasper St. Pierre2014-08-051-26/+25
| | | | | | | | The code here is wrong, leaky, and inconsistent. We don't free, unlink or clean up things when we should in every error path. Centralize the data destruction so it's easier to keep track of and easier to bug fix.
* wayland-client: Fix indentationJasper St. Pierre2014-08-051-3/+3
|
* doc: Fix link to wl_list_remove()Bryce W. Harrington2014-07-241-2/+2
| | | | | | | | | | Use function linking syntax instead of variable linking, to resolve two warnings: wayland-server.h:167: warning: explicit link request to 'wl_list_remove' could not be resolved wayland-server.h:188: warning: explicit link request to 'wl_list_remove' could not be resolved Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
* client: extend error handlingMarek Chalupa2014-07-072-18/+122
| | | | | | | | | | | | | | | | | | | | | | | When an error occurs, wl_display_get_error() does not provide any way of getting know if it was a local error or if it was an error event, respectively what object caused the error and what the error was. This patch introduces a new function wl_display_get_protocol_error() which will return error code, interface and id of the object that generated the error. wl_display_get_error() will work the same way as before. wl_display_get_protocol_error() DOES NOT indicate that a non-protocol error happened. It returns valid information only in that case that (protocol) error occurred, so it should be used after calling wl_display_get_error() with positive result. [Pekka Paalanen] Applied another hunk of Bryce's comments to docs, added libtool version bump. Reviewed-by: Pekka Paalanen <ppaalanen@gmail.com> Reviewed-by: Bryce Harrington <b.harrington@samsung.com>
* connection: remove unreached codeBoyan Ding2014-06-181-2/+0
|
* scanner: Downgrade non-increasing version error to warning1.4.93Kristian Høgsberg2014-05-121-1/+1
| | | | | | | | | | | Commit 99a72777f96f63e4e25dc528bb37115424adac59 introduced a new error for when the 'since' version decreases. It also reset the version for messages without a version to 1. Versioning semantics in the spec files was a little under-specified and we don't want to break projects caught in this grey zone. This commits replaces previous configure.ac as the 1.4.93 tag and the final 1.5 RC.
* scanner: Generate macros for getting the 'since' version of an eventJonas Ådahl2014-05-091-0/+13
| | | | | | | | | | | This could be useful for compositors who need to be able to not send events if the client bound a version lower than the newest provided. Event version numbers are exposed as [INTERFACE_NAME]_[EVENT_NAME]_SINCE_VERSION for example wl_output.scale will have the version macro WL_OUTPUT_SCALE_SINCE_VERSION. Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
* scanner: Also fail when an implicitly versioned message is out of orderJonas Ådahl2014-05-091-4/+6
| | | | | | | Fail if a message with version implicitly set to 1 (i.e. not specified) comes after a message with since-version > 1. Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
* doc: Added API documentation for wl_display_create function.Srivardhan Hebbar2014-05-091-0/+9
| | | | Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com>
* server: fix potential memleak and NULL derefU. Artie Eoff2014-05-061-1/+2
| | | | | | | | | | | | | | | | | | If for some reason that errno is neither value (ENOMEM or EINVAL), then prior to this patch, there would be a NULL deref in wl_closure_lookup(...) at the "else if" conditional when closure == NULL. Also, closure might not be NULL but still fall into the block due to the wl_closure_lookup < 0 condition... in that case, we need to destroy the closure to avoid a memory leak. Currently, wl_connection_demarshal only sets errno to ENOMEM or EINVAL... we've already checked for ENOMEM so remove check for EINVAL (just assume it). Also, call wl_closure_destroy(...) unconditionally in the "else if" block (assume it can handle NULL closure, too, which it does right now). Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
* scanner: check wl_array_add resultU. Artie Eoff2014-05-061-1/+1
| | | | Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
* Avoid printing to stderrKristian Høgsberg2014-04-302-15/+9
| | | | | | | Use wl_log in the last few places where we print to stderr. Remove logging in a couple of places where we properly return an error code. https://bugs.freedesktop.org/show_bug.cgi?id=73339
* Use non-blocking timerfd to prevent blocking when updating timer event sourcesAndrew Wedgbury2014-04-251-2/+3
| | | | | | | | | | | | | | | | | This implements a simple fix for the blocking problem that occurs when updating a timer event source after the timer expires, but before its callback is dispatched. This can happen when another event happens during the same epoll wakeup as the timer event, and causes the read() call in wl_event_source_timer_dispatch() to block for the updated duration of the timer. We never want this read() call to block, so I believe it makes sense for the timerfd to be non-blocking, and we simply ignore the case where the read fails with EAGAIN. We still report all other errors as before, and still ignore the actual value read from the socket. With this change, the event_loop_timer_updates unit test case I submitted previously now passes, and weston appears to work as before.
* connection: fix a format string typo in error messageGiulio Camuffo2014-04-251-1/+1
|
* connection: Don't write past the end of the connection bufferAnder Conselvan de Oliveira2014-04-211-8/+17
| | | | | | | | | | | If a message was too big to fit in the connection buffer, the code in wl_buffer_put would just write past the end of it. I haven't seen any real world use case that would trigger this bug, but it was possible to trigger it by sending a long enough string to the wl_data_source.offer request. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=69267
* shm: Disallow shrinking shm poolsKristian Høgsberg2014-04-071-2/+8
| | | | | | | Unused shm space will be automatically reclaimed if unused or can be explicitly returned by using fallocate FALLOC_FL_PUNCH_HOLE. https://bugs.freedesktop.org/show_bug.cgi?id=74632
* scanner: Only output each forward declaration onceKristian Høgsberg2014-04-031-8/+28
| | | | | Just sort the types and only print unique type names. We avoid using the GCC pragma.
* Add WL_PRINTF attribute and annotate wl_log_func_tKristian Høgsberg2014-04-031-1/+8
|
* client: Delay EPIPE handling so we get a chance to handle error eventsKristian Høgsberg2014-03-261-2/+5
|
* server: Kill some unnecessary logsJasper St. Pierre2014-03-251-4/+0
| | | | | | In order to set a logging function all the time, the output we get needs to be useful. Logging about trivial things like the socket we're using and when clients disconnect doesn't realy help anyone.
* build: Move src/Makefile.am into toplevel Makefile.amKristian Høgsberg2014-03-071-72/+0
|
* connection: Use wl_log to report errorsJasper St. Pierre2014-02-181-18/+18
| | | | | | | In some cases, like Xwayland, stdout and stderr are redirected to /dev/null, losing us valuable information, while wl_log can be overridden, allowing us to send it to a log file instead. This can help debugging immensely.
* scanner: Add GCC pragmas to disable -Wredundant-declsJasper St. Pierre2014-02-181-1/+3
| | | | | | | | | The code very intentionally emits a lot of redundant declarations to simplify the scanner code. Somebody building with -Wredundant-decls would have compile errors, so emit special pragmas to turn those warnings off. These pragmas should be ignored outside of gcc/clang.
* wayland-client: Set a proper errnoJasper St. Pierre2014-02-181-3/+3
| | | | | | errno is supposed to be positive, not negative. It seems that everything else that calls display_fatal_error() calls it with a positive error code, so do it here as well.
* client: Queue display events on private queue and always dispatchKristian Høgsberg2014-02-071-4/+21
| | | | | | | | | | | | | | The wl_display events (error and delete_id) need to be handled even if the default queue doesn't get dispatched for a while. For example, a busy EGL rendering loop hits wl_display.sync every eglSwapBuffers() and we need to process the delete_id events to maintain the object ID data structure. As it is, that doesn't happen, but with this change we special case wl_display events. We put them on a custom, private queue and when dispatching events, we always dispatch display_queue events first. The wl_display proxy should still be the default_queue, so that objects created from wl_display requests get assigned to that.
* client: Rename display->queue to default_queueKristian Høgsberg2014-02-071-8/+9
| | | | We'll add a new queue next, so rename the default queue first.
* Make default log handler print to stderrKristian Høgsberg2014-02-071-2/+4
| | | | | On the client side we log fatal errors before we exit. If a client doesn't set a log handler, it's hard to figure out what goes wrong.
* Rename wl_debug to debug_server/clientJason Ekstrand2014-02-052-10/+10
| | | | Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
* Don't deref the sample pointer in the wl_container_of macroNeil Roberts2014-02-053-19/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous implementation of the wl_container_of macro was dereferencing the sample pointer in order to get an address of the member to calculate the offset. Ideally this shouldn't cause any problems because the dereference doesn't actually cause the address to be read from so it shouldn't matter if the pointer is uninitialised. However this is probably technically invalid and could cause undefined behavior. Clang appears to take advantage of this undefined behavior and doesn't bother doing the subtraction. It also gives a warning when it does this. The documentation for wl_container_of implies that it should only be given an initialised pointer and if that is done then there is no problem with clang. However this is quite easy to forget and doesn't cause any problems or warnings with gcc so it's quite easy to accidentally break clang. To fix the problem this changes the macro to use pointer - offsetof(__typeof__(sample), member) so that it doesn't need to deref the sample pointer. This does however require that the __typeof__ operator is supported by the compiler. In practice we probably only care about gcc and clang and both of these happily support the operator. The previous implementation was also using __typeof__ but it had a fallback path avoiding it when the operator isn't available. The fallback effectively has undefined behaviour and it is targetting unknown compilers so it is probably not a good idea to leave it in. Instead, this patch just removes it. If someone finds a compiler that doesn't have __typeof__ but does work with the old implementation then maybe they could add it back in as a special case. This patch removes the initialisation anywhere where the sample pointer was being unitialised before using wl_container_of. The documentation for the macro has also been updated to specify that this is OK.
* client: Include poll.h instead of sys/poll.hJonas 'Sortie' Termansen2014-01-171-1/+1
| | | | POSIX mandates the poll.h header as the standard location of poll(2).
* add_shm_format: check wl_array_add return value before derefU. Artie Eoff2014-01-152-5/+11
| | | | | | | | In wl_display_add_shm_format(), check the return value from wl_array_add() before dereferencing it and assigning it a value. Return the resulting pointer back to the caller. Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
* shm: assert sigbus_data is not NULL before member accessU. Artie Eoff2014-01-151-1/+1
| | | | Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
* Fix buffer overflow when serializing a closure object1.3.92chi ding2014-01-091-8/+83
| | | | | | | | | Here is the JIRA page of this issue https://bugs.tizen.org/jira/browse/TIVI-1889 Change-Id: I773a6d2d8f6fd02ff10c92450db1fa8a69544219 Signed-off-by: Chi Ding <chi.ding@mobica.com> Closes: https://bugs.freedesktop.org/show_bug.cgi?id=65186