Age | Commit message (Collapse) | Author | Files | Lines |
|
The inputthread is kept locked all the time while X server's VT is not active.
If the X server is terminated while not active, it will be stuck forever in
InputThreadFini waiting for the thread to join, but it wouldn't because it is
locked.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=103782
Signed-off-by: Michal Srb <msrb@suse.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
(cherry picked from commit 71348e99a8e6a95542e483b93839168ca8f51f81)
|
|
Building with strict-aliasing rightly chirps here:
../os/xdmcp.c: In function ‘XdmcpRegisterConnection’:
../os/xdmcp.c:489:31: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
&((struct sockaddr_in6 *) &address)->sin6_addr.s6_addr[12];
^~~~~~~~~~~~
We have "const char *address", so &address here is a char ** (i.e., it
points to the slot on the stack containing the pointer to the character
array passed in as an argument). Casting that to a struct sockaddr_in6 *
is wrong, because it means that area of the stack will be reinterpreted
as a struct sockaddr_in6.
Instead, cast address, not &address.
Signed-off-by: Adam Jackson <ajax@redhat.com>
(cherry picked from commit 652913cd9474946bcb29271602bacfd98f46ad0b)
|
|
Don't reuse cmd for strtok output to ensure the proper pointer is
freed afterwards.
The code incorrectly assumed the pointer returned by strtok(cmd, ":")
would always point to cmd. However, strtok(str, sep) != str if str
begins with sep. This caused an invalid-free crash when running
a program under X with a name beginning with a colon.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=104123
Signed-off-by: Tomasz Śniatowski <kailoran@gmail.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
(cherry picked from commit 6883ae43eb72fe4e2651c1dca209563323fad2db)
|
|
Terminate a dead session when -once was passed. Don't restart it.
Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Walter Harms <wharms@bfs.de>
(cherry picked from commit 918afeecbc63d70413e222efdb2ac4cfb16eae9e)
|
|
A client can send a big request where the 32B "length" field has value
0. When the big request header is removed and the length corrected,
the value will underflow to 0xFFFFFFFF. Functions processing the
request later will think that the client sent much more data and may
touch memory beyond the receive buffer.
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 9c23685009aa96f4b861dcc5d2e01dbee00c4dd9)
|
|
The meson build gives me:
../os/utils.c: In function ‘LockServer’:
../os/utils.c:310:40: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=]
snprintf(pid_str, sizeof(pid_str), "%10ld\n", (long) getpid());
^~~~~~~~~
../os/utils.c:310:5: note: ‘snprintf’ output between 12 and 13 bytes into a destination of size 12
snprintf(pid_str, sizeof(pid_str), "%10ld\n", (long) getpid());
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Which seems to be due to the %d part meaning that a negative number's -
sign would be one wider than we're expecting. Fine, just coerce it to
unsigned.
Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit aabf65d2a0206bd1a9c6e9a9f3153ded873dfd43)
|
|
This makes sure the server will go look at the client again, notice
that the FD is no longer valid and close the client down.
Bugzilla: https://bugs.freedesktop.org/100863
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
(cherry picked from commit e2f68296ffb8e40035c0ebd949b67d1e2e424e11)
|
|
There are three copies of the same short sequence of operations to
close down a client when a write error occurs. Create a new function,
AbortClient, which performs these operations and then call it from the
three places.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
(cherry picked from commit a82971b07035ee9a4e3ed01326e7c1eab34b5a19)
|
|
Without this, assertion failures can make life hard for users and those
trying to help them.
v2:
* Change commit log wording slightly to "can make life hard", since
apparently e.g. logind can alleviate that somewhat.
* Set default handler for SIGABRT in
hw/xfree86/common/xf86Init.c:InstallSignalHandlers() and
hw/xquartz/quartz.c:QuartzInitOutput() (Eric Anholt)
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
(cherry picked from commit 27a6b9f7c84c914d0f5909ec1069d72f5035bc04)
|
|
Fixes a regression from
commit 41da295eb50fa08eaacd0ecde99f43a716fcb41a
Author: Keith Packard <keithp@keithp.com>
Date: Sun Nov 3 13:12:40 2013 -0800
Trap SIGBUS to handle truncated shared memory segments
that causes the SIGBUS handler to fail to chain up correctly and
corrupts nearby memory instead.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit acdb5bf2de57c0080d2a6e730c788a0a428e13dc)
|
|
timingsafe_memcmp.c:21:1: warning: no previous prototype for ‘timingsafe_memcmp’ [-Wmissing-prototypes]
timingsafe_memcmp(const void *b1, const void *b2, size_t len)
Signed-off-by: Adam Jackson <ajax@redhat.com>
(cherry picked from commit 5c44169caed811e59a65ba346de1cadb46d266ec)
|
|
- typo in #ifdef check
- also need to add AC_CHECK_FUNCS([arc4random_buf])
Reported-by Eric Engestrom. Thanks
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
(cherry picked from commit 386fbbe410a1168b724136e54cf3bd37fb64ad4e)
|
|
And the current code for MitToId has a use-after-free() issue.
[Also remove the actual implementations - ajax]
Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit 2855f759b1e7bf7f5e57cac36c1f0d0e5ac1a683)
|
|
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
(cherry picked from commit 957e8db38f27932d353e86e9aa69cf16778b18f1)
|
|
Provide the function definition for systems that don't have it.
Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit d7ac755f0b618eb1259d93c8a16ec6e39a18627c)
|
|
The input thread should generate events, not send them. Make it easier to
find the instances where it's doing so.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
(cherry picked from commit 1b12249fd6d4d3b566043d556503f3f625b9b4ba)
|
|
A client which is attended while a grab is blocking execution of its
requests needs to be placed in the saved_ready_clients list so that it
will get scheduled once the grab terminates. Otherwise, if the client
never sends another request, there is no way for it to be placed in
the ready_clients list.
v2: Wrap comment above mark_client_saved_ready.
Remove test for OS_COMM_IGNORED which will always be true.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99333
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
(cherry picked from commit 785053d033e73d2deb0ded4b97eabfd881991978)
|
|
Fixes a regression introduced in 0b2f30834b1a9f. If a driver posts input
events during a timer function (wacom and synaptics do this during tap
timeouts), ProcessInputEvents() is not called for these events. There are no
new events on any fds, so the events just sit in the queue waiting for
something else to happen.
Fix this by simply returning 0 from check_timers if we ran at least one of
them or reset them all. This way the callers ospoll_wait will exit and
continue with normal processing.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
|
|
The custom os/os.O library reuses *.o files of os/libos.la.
The current rule assumes automake puts all the objects into per-target
am__*_la_OBJECTS variable. At least with AC_REPLACE_FUNCS, this no
longer holds (as wanted objects are put into LTLIBOBJS instead).
Depend on automake's result, the *.la library instead, to express demand
of any its dependencies being built.
Should be fixing randomly occuring "undefined reference to `strlcpy'"
errors when linking Xvfb and other DDX-es that could use os.O.
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Mihail Konev <k.mvc@ya.ru>
(cherry picked from commit 5b74e260e009d8bdf26433724495802b85cce7c3)
|
|
If a work proc wakes up a sleeping client and it is ready to execute,
we need to re-compute the local 'are_ready' value before deciding
what timeout value to use in WaitForSomething.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98030
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
|
|
On Linux, setting the main thread's name changes the program name
(/proc/self/comm). Setting it to MainThread breaks scripts that rely on
the command name, e.g. ps -C Xorg.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
When putting a device node into a poll-request list, do not overwrite a
"please-remove" element with the same fd, so that a closed device file
is ospoll_remove'd prior to being ospoll_add'ed.
Before, the opposite order was possible, resulting in ospoll_add
considering the newly opened file being already polled, should it have a
fd for which the "please-remove" has not been procesed yet. In this
case, no further events would be seen from the device.
Signed-off-by: Mihail Konev <k.mvc@ya.ru>
Regressed-in: 52d6a1e832a5e62289dd4f32824ae16a78dfd7e8
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97880
Patchwork: https://patchwork.freedesktop.org/patch/113763/
Hit-and-Reduced-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-and-Reduced-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
|
|
V2: Moves InputCheckPending() into dix.h
Bumps required version of xproto to 7.0.30
==================
WARNING: ThreadSanitizer: data race (pid=4943)
Read of size 4 at 0x00010c4e3854 by thread T8:
#0 WaitForSomething WaitFor.c:237 (X11.bin+0x00010049216c)
#1 Dispatch dispatch.c:413 (X11.bin+0x000100352ed9)
#2 dix_main main.c:287 (X11.bin+0x00010036e894)
#3 server_thread quartzStartup.c:66 (X11.bin+0x000100039e63)
Previous write of size 4 at 0x00010c4e3854 by thread T12 (mutexes: write M856, write M1976):
#0 mieqEnqueue mieq.c:263 (X11.bin+0x000100448d14)
#1 DarwinSendDDXEvent darwinEvents.c:641 (X11.bin+0x000100033613)
#2 DarwinProcessFDAdditionQueue_thread darwinEvents.c:338 (X11.bin+0x000100032039)
Location is global 'miEventQueue' at 0x00010c4e3850 (X11.bin+0x0001005ab854)
Mutex M856 (0x00010c4c8c80) created at:
#0 pthread_mutex_lock <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x0000000321fe)
#1 DarwinListenOnOpenFD darwinEvents.c:300 (X11.bin+0x000100031607)
#2 socket_handoff bundle-main.c:288 (X11.bin+0x000100002b40)
#3 __do_request_fd_handoff_socket_block_invoke bundle-main.c:379 (X11.bin+0x0001000029ba)
#4 __tsan::invoke_and_release_block(void*) <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x00000005d97b)
#5 _dispatch_client_callout <null>:33 (libdispatch.dylib+0x0000000020ef)
Mutex M1976 (0x00010c4e3d68) created at:
#0 pthread_mutex_init <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x0000000253c3)
#1 input_lock inputthread.c:103 (X11.bin+0x00010049fd10)
#2 TimerSet WaitFor.c:343 (X11.bin+0x0001004926c2)
#3 RootlessQueueRedisplay rootlessScreen.c:594 (X11.bin+0x000100065d7f)
#4 RootlessInstallColormap rootlessScreen.c:514 (X11.bin+0x000100069f1a)
#5 miSpriteInstallColormap misprite.c:562 (X11.bin+0x000100467095)
#6 miCreateDefColormap micmap.c:270 (X11.bin+0x000100440399)
#7 DarwinScreenInit darwin.c:285 (X11.bin+0x0001000303bb)
#8 AddScreen dispatch.c:3908 (X11.bin+0x00010036c417)
#9 InitOutput darwin.c:671 (X11.bin+0x00010002fdeb)
#10 dix_main main.c:197 (X11.bin+0x00010036e228)
#11 server_thread quartzStartup.c:66 (X11.bin+0x000100039e63)
Thread T8 (tid=4198779, running) created by main thread at:
#0 pthread_create <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x000000024490)
#1 create_thread quartzStartup.c:78 (X11.bin+0x000100039dad)
#2 QuartzInitServer quartzStartup.c:95 (X11.bin+0x000100039c16)
#3 X11ApplicationMain X11Application.m:1238 (X11.bin+0x00010001cde4)
#4 X11ControllerMain X11Controller.m:984 (X11.bin+0x00010002a642)
#5 server_main quartzStartup.c:136 (X11.bin+0x00010003a03b)
#6 do_start_x11_server bundle-main.c:436 (X11.bin+0x000100002eb5)
#7 _Xstart_x11_server mach_startupServer.c:189 (X11.bin+0x000100004e99)
#8 mach_startup_server mach_startupServer.c:399 (X11.bin+0x000100005734)
#9 mach_msg_server mach_msg.c:563 (libsystem_kernel.dylib+0x000000012186)
#10 start <null>:29 (libdyld.dylib+0x000000005254)
Thread T12 (tid=4198797, running) created by thread T8 at:
#0 pthread_create <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x000000024490)
#1 create_thread darwinEvents.c:121 (X11.bin+0x000100031ecf)
#2 DarwinEQInit darwinEvents.c:365 (X11.bin+0x000100031860)
#3 InitInput darwin.c:571 (X11.bin+0x00010002ea09)
#4 dix_main main.c:261 (X11.bin+0x00010036e7ce)
#5 server_thread quartzStartup.c:66 (X11.bin+0x000100039e63)
SUMMARY: ThreadSanitizer: data race WaitFor.c:237 in WaitForSomething
==================
==================
WARNING: ThreadSanitizer: data race (pid=22841)
Write of size 4 at 0x000105bbd864 by main thread (mutexes: write M1945):
#0 mieqEnqueue mieq.c:263 (X11.bin+0x000100448cf4)
#1 DarwinSendDDXEvent darwinEvents.c:642 (X11.bin+0x000100033693)
#2 -[X11Controller set_window_menu:] X11Controller.m:275 (X11.bin+0x0001000222fd)
#3 -[X11Application set_window_menu:] X11Application.m:486 (X11.bin+0x000100018b44)
#4 -[X11Application handleMachMessage:] X11Application.m:177 (X11.bin+0x000100016678)
#5 __NSFireMachPort <null>:69 (Foundation+0x00000009b62b)
#6 X11ControllerMain X11Controller.m:984 (X11.bin+0x00010002a5f2)
#7 server_main quartzStartup.c:136 (X11.bin+0x000100039ffb)
#8 do_start_x11_server bundle-main.c:436 (X11.bin+0x000100002e65)
#9 _Xstart_x11_server mach_startupServer.c:189 (X11.bin+0x000100004e49)
#10 mach_startup_server mach_startupServer.c:399 (X11.bin+0x0001000056e4)
#11 mach_msg_server mach_msg.c:563 (libsystem_kernel.dylib+0x000000012186)
#12 start <null>:29 (libdyld.dylib+0x000000005254)
Previous read of size 4 at 0x000105bbd864 by thread T7:
#0 Dispatch dispatch.c:434 (X11.bin+0x000100352fc8)
#1 dix_main main.c:287 (X11.bin+0x00010036e874)
#2 server_thread quartzStartup.c:66 (X11.bin+0x000100039e23)
Location is global 'miEventQueue' at 0x000105bbd860 (X11.bin+0x0001005ab864)
Mutex M1945 (0x000105bbdd78) created at:
#0 pthread_mutex_init <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x0000000253c3)
#1 input_lock inputthread.c:103 (X11.bin+0x00010049fd10)
#2 TimerSet WaitFor.c:348 (X11.bin+0x0001004926c2)
#3 RootlessQueueRedisplay rootlessScreen.c:594 (X11.bin+0x000100065d3f)
#4 RootlessInstallColormap rootlessScreen.c:514 (X11.bin+0x000100069eda)
#5 miSpriteInstallColormap misprite.c:562 (X11.bin+0x000100467075)
#6 miCreateDefColormap micmap.c:270 (X11.bin+0x000100440379)
#7 DarwinScreenInit darwin.c:285 (X11.bin+0x00010003036b)
#8 AddScreen dispatch.c:3914 (X11.bin+0x00010036c3f7)
#9 InitOutput darwin.c:671 (X11.bin+0x00010002fd9b)
#10 dix_main main.c:197 (X11.bin+0x00010036e208)
#11 server_thread quartzStartup.c:66 (X11.bin+0x000100039e23)
Thread T7 (tid=4257217, running) created by main thread at:
#0 pthread_create <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x000000024490)
#1 create_thread quartzStartup.c:78 (X11.bin+0x000100039d6d)
#2 QuartzInitServer quartzStartup.c:95 (X11.bin+0x000100039bd6)
#3 X11ApplicationMain X11Application.m:1238 (X11.bin+0x00010001cd94)
#4 X11ControllerMain X11Controller.m:984 (X11.bin+0x00010002a5f2)
#5 server_main quartzStartup.c:136 (X11.bin+0x000100039ffb)
#6 do_start_x11_server bundle-main.c:436 (X11.bin+0x000100002e65)
#7 _Xstart_x11_server mach_startupServer.c:189 (X11.bin+0x000100004e49)
#8 mach_startup_server mach_startupServer.c:399 (X11.bin+0x0001000056e4)
#9 mach_msg_server mach_msg.c:563 (libsystem_kernel.dylib+0x000000012186)
#10 start <null>:29 (libdyld.dylib+0x000000005254)
SUMMARY: ThreadSanitizer: data race mieq.c:263 in mieqEnqueue
==================
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
|
|
When a client is marked as write blocked, clear any old 'write ready'
bit in the osfds structure so that a new indication of write ready
(which is marked as edge trigggered) will trigger the callback.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Tested-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Tested-by: Matthieu Herrb <matthieu@herrb.eu>
|
|
When a client with pending output is ready (has request data pending),
FlushAllOutput will skip it to get all of the requests processed
before sending any queued output. That means FlushAllOutput is going
to return with some output pending to a client which isn't known to be
write blocked. And that means NewOutputPending needs to be set so that
FlushAllOutput will get called again to actually go flush this client.
It might be interesting to try just flushing the client to send any
queued data along the way. This patch just restores the server
behavior to what it was before the ospoll changes.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Tested-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Tested-by: Matthieu Herrb <matthieu@herrb.eu>
|
|
Distribute this source file.
Signed-off-by: Keith Packard <keithp@keithp.com>
|
|
Autoconf logic borrowed from glib
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Tested-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
|
|
If RTLD_DI_SETSIGNAL is set to let us turn runtime linker/loader errors
into catchable signals, then we should only show the errors when catching
that signal, instead of tossing out red herrings to distract people with
unrelated crashes long after their last failed symbol lookup (especially
when using drivers built to support multiple API's by checking which
symbols are available before calling them).
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Aaron Plattner <aplattner@nvidia.com>
|
|
O_CLOEXEC is not a file bit. It is not setable with F_SETFL. One must
use it when calling open(2). To set it cloexec on an existing fd,
F_SETFD and FD_CLOEXEC must be used.
This also fixes a build failure regression on configurations that don't
have O_CLOEXEC defined.
cf: http://pubs.opengroup.org/onlinepubs/9699919799/functions/fcntl.html
Regressed-in: 30ac7567980a1eb79d084a63e0e74e1d9a3af673
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Reviewed-by: Julien Cristau <jcristau@debian.org>
|
|
This change has two effects:
1. Only calls FlushCallbacks when we're actually flushing data to a
client. The unnecessary FlushCallback calls could cause significant
performance degradation with compositing, which is significantly
reduced even without any driver changes.
2. By passing the ClientPtr to FlushCallbacks, drivers can completely
eliminate unnecessary flushing of GPU commands by keeping track of
whether we're flushing any XDamageNotify events to the client for
which the corresponding rendering commands haven't been flushed to
the GPU yet.
Reviewed-by: Adam Jackson <ajax@redha.com>
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
|
|
If a file descriptor is added or removed from an ospoll callback, then
the arrays containing file descriptor information will have all of
their indices changed, so the loop state is no longer consistent. Just
bail out and let the caller come back around to try again.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
|
|
Instead of freeing the struct ospollfd elements when the fd is
removed by the user, delay that until epoll is idle so that we are
sure no epoll_event structures could contain the stale pointer. This
handles cases where an fd is removed from the ospoll callback
interface, and also in case the OS keeps stale pointers around after
the call to epoll_ctl with EPOLL_CTL_DEL.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
|
|
Calling InputThreadRegisterDev twice with the same fd should replace
the existing function and args instead of creating a new entry with
the same fd.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
|
|
xf86AddEnabledDevice() prepends the new fd to the list,
xf86RemoveEnabledDevice() then searches for a matching fd and removes that
entry. If this is done for the same fd (and since we lose all information but
the actual fd) we usually unregister virtual devices in reverse order, causing
a dereference of already released memory.
Case in point:
- the wacom driver calls xf86AddEnabledDevice() once for the physical device,
then multiple times for the virtual subdevices
- when the physical device is unplugged, the driver calls
xf86RemoveEnabledDevice() for the physical device
- all we have is the fd, so we end up removing the last virtual device from
the fd set
- xf86DeleteInput() frees the physical device's pInfo
- the fd goes crazy with ENODEV, but a read_input() now passes the already
freed pInfo for the physical device
- boom
Fix this by appending to the fd list to provide bug-for-bug compatibility with
the old SIGIO code. This needs to be fixed in the driver, but meanwhile not
crashing the server provides for better user experience.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
|
|
Do all timer stuff before blocking, avoiding a bunch of duplicate code
and merge common code in WaitForSomething.
The WaitForSomething changes need a bit of explanation to show that
the new code is effectively equivalent to the old. Eliding error
checking and trivial bits we've got:
Before:
if (ready clients)
timeout = 0
else
compute timeout
i = poll
if (i <= 0) {
if (ready clients)
return TRUE;
if (input)
return FALSE;
if (any ready timers) {
run timers
return FALSE;
}
} else {
if (input)
return FALSE;
if (any ready timers) {
run timers
return FALSE;
}
if (ready clients)
return TRUE;
}
After:
if (ready clients)
timeout = 0;
else
compute timeout
run_timers
poll
if (input)
return FALSE;
if (ready clients)
return TRUE;
The old code would return TRUE if there were ready clients and input
pending. Dispatch would then schedule that ready client, but before
processing any requests, it would notice that there was input pending
and go process it. The new code just checks for input first, which is
effectively the same.
If the poll timed out and there weren't clients ready, then timers
would get run.
If the poll didn't time out, then timers would get run, even if there
were clients now ready. Now, if the timeout interval was zero, that
means that the timers must have been ready *before* poll was
invoked. In this case, we should simply run the timers before calling
poll -- no sense calling poll just to discard any data that it
generates.
If the timeout interval was non-zero, and poll didn't timeout, then
either there aren't any timers to run, or we got a surprise and hit a
timer exactly as a client became ready to run. This is the one case
where the new code is different from the old; the new code delays the
timer call until the next time WaitForSomething is called.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
|
|
No sense having an open-coded linked list here, plus the doubly linked
list is more efficient
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
|
|
poll provides per-fd notification of failure, so we don't need
CheckConnections anymore.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
|
|
There's no reason to close these now that we don't care what file
descriptors we use.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
|
|
There's no reason not to offer ridiculous numbers of clients; only a
few static data structures are arrays of this length.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
|
|
With no code depending on the range of file descriptors, checking
for that can be eliminated.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
|
|
Replace use of select(2) to avoid fd limits. Note that
InputThreadFillPipe used select as well, but none of the files passed
were non-blocking, so there was no need for that code at all.
v2: Keep ospoll API usage single threaded to avoid re-entrancy issues
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
|
|
Eliminates all of the fd_set mangling in the server main thread
v2: Listen for POLLOUT while writes are blocked.
v3: Only mark client not ready on EAGAIN return from read
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
|
|
This converts the dispatch loop into using a list of ready clients
instead of an array. This changes the WaitForSomething API so that it
notifies DIX when a client becomes ready to read, instead of returning
the set of ready clients.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
|
|
This provides a wrapper around poll or epoll providing a
callback-based interface for monitoring activity on a large set of
file descriptors.
v2: use xserver_poll API instead of poll. Don't use WSAPoll as
that is broken.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
|
|
v2: rename as 'xserver_poll' to avoid potential library name
collisions. Provide 'xserver_poll.h' which uses the system
poll where available and falls back to this emulation otherwise.
Autodetects when this is required, building the emulation only
then
Source: https://github.com/bmc/poll
Signed-off-by: Adam Jackson <ajax@redhat.com>
|
|
The file descriptors passed to InputThreadFillPipe are always
blocking, so there's no need to use Select (or poll).
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
|
|
This lets other code share this functionality
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
|
|
The timeout resolution offered in the AdjustWaitForDelay call is
only milliseconds, so passing around the timeout as a pointer to a
struct timeval is not helpful. Doing everything in milliseconds up to
the point of the select call simplifies the code without affecting
functionality at all.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
|
|
Instead of having scheduling done in two places (one in
WaitForSomething, and the other in SmartScheduleClient), just stick
all of the scheduling in SmartScheduleClient.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
|
|
All uses of these interfaces should instead be using the NotifyFd API
instead.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
|