summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* doc: fixed grammar and a typoDerek Foreman2015-01-131-2/+2
| | | | Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
* doc: fixed a typoBill Spitzak2015-01-131-1/+1
| | | | Reviewed-by: Bryce Harrington <b.harrington@samsung.com>
* client: read_events should return -1 after an errorMarek Chalupa2015-01-131-0/+5
| | | | | | | | | | | | | | | | | When a thread is sleeping, waiting until another thread read from the display, it always returns 0. Even when an error occured. In documentation stands: "return 0 on success or -1 on error. In case of error errno will be set accordingly" So this is a fix for this. Along with the read_events, fix a test so that it now complies with this behaviour (and we have this tested) Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* connection: abort if a listener function is NULLRyo Munakata2015-01-131-0/+5
| | | | | Signed-off-by: Ryo Munakata <ryomnktml@gmail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* Remove useless semicolon.Carlos Olmedo Escobar2015-01-131-1/+1
| | | | | Signed-off-by: Carlos Olmedo Escobar <carlos.olmedo.e@gmail.com> Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
* doc: Added API documentation for wl_display_destroy and ↵Srivardhan Hebbar2015-01-131-0/+38
| | | | | | | | wl_display_add_socket functions. Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com> [Pekka Paalanen: minor re-wording.] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* scanner, client: Added more error checks when strtol function is usedImran Zaman2015-01-132-2/+7
| | | | | Signed-off-by: Imran Zaman <imran.zaman@gmail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* wayland-server: Abort if a read from a client gives 0 lengthPhilip Withnall2015-01-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | This happens on EOF if using a poll function such as select() or kqueue() which doesn’t distinguish EOF events. Currently execution should never reach the point where recvmsg() returns EOF (len == 0). Instead, epoll() will detect this and indicate EPOLLHUP, which is handled a few lines above, closing the connection. However, other event mechanisms may not be able to distinguish EOF from regular readability (in the case of select()) or inconsistently across platforms (in the case of POLLHUP). There is also the possibility of half-closed connections (shutdown(), POLLRDHUP), though this may not be an issue with Wayland. This will not cause problems if the FD polls as readable but actually is not — in that case, recvmsg() will return EAGAIN. Signed-off-by: Philip Withnall <philip at tecnocode.co.uk> Signed-off-by: Karsten Otto <ottoka at posteo.de> Reviewed-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* event-loop.c: Use correct OS abstraction function for dupfd()Philip Withnall2015-01-131-1/+1
| | | | | | | | Signed-off-by: Philip Withnall <philip at tecnocode.co.uk> Signed-off-by: Karsten Otto <ottoka at posteo.de> Reviewed-by: David Fort <contact at hardening-consulting.com> Reviewed-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* connection: Fix sendmsg() on FreeBSDPhilip Withnall2015-01-131-1/+1
| | | | | | | | | | | | It expects ((msg_controllen == 0) == (msg_control == NULL)), and returns EINVAL otherwise. It can't hurt to be tidy about things on other platforms either though. See: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=99356#c5 Signed-off-by: Philip Withnall <philip at tecnocode.co.uk> Signed-off-by: Karsten Otto <ottoka at posteo.de> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* scanner: Remove stray newlineJonas Ådahl2015-01-121-1/+0
| | | | Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
* scanner: Improve XML parse error reportingJonas Ådahl2015-01-121-2/+8
| | | | | | | Print the parse error and exit with a failure if expat can't parse the XML. Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
* shm: fix error in commentDerek Foreman2014-09-111-1/+1
|
* client: cancel read in wl_display_read_events() when last_error is setMarek Chalupa2014-09-111-3/+10
| | | | | | | | | | | Calling wl_display_read_events() after an error should be equivalent to wl_display_cancel_read(), so that display state is consistent. Thanks to Pekka Paalanen <pekka.paalanen@collabora.co.uk> for pointing that out. Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* client: wake-up threads on all return paths from read_eventsMarek Chalupa2014-09-111-1/+6
| | | | | | | | | | If wl_connection_read returned EAGAIN, we must wake up sleeping threads. If we don't do this and the thread calling wl_connection_read won't call wl_display_read_events again, the sleeping threads will sleep indefinitely. Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* client: add display_wakeup_threads functionMarek Chalupa2014-09-041-12/+25
| | | | | | | | | | | | This helper function wraps the always-repeated pattern: display->read_serial++; pthread_cond_broadcast(&display->reader_cond); [Pekka Paalanen: minor whitespace and comment fixes.] Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* wayland-client: Initialize newly created wl_proxys to zeroNils Chr. Brause2014-09-041-6/+4
| | | | | | | | | | | | Up until now, newly created wl_proxys (with proxy_create or wl_proxy_create_for_id) are not initialized properly after memory allocation. The wl_display object in contrast is. To prevent giving uninitialized data to the user (e.g. user_data) an appropriate memset has been added. Also, after a memset members don't have to be explicitly initialized with zero anymore. Signed-off-by: Nils Chr. Brause <nilschrbrause@googlemail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* 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