<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/foot.git/fdm.h, branch 1.26.0</title>
<subtitle>A fast, lightweight and minimalistic Wayland terminal emulator</subtitle>
<id>https://git.0x0f.dev/mirrors/foot.git/atom?h=1.26.0</id>
<link rel='self' href='https://git.0x0f.dev/mirrors/foot.git/atom?h=1.26.0'/>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/'/>
<updated>2021-02-11T17:55:21Z</updated>
<entry>
<title>fdm: add support for managing signals</title>
<updated>2021-02-11T17:55:21Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-02-10T15:17:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=863ae1143f9336f300c300c4d62165c3eac22834'/>
<id>urn:sha1:863ae1143f9336f300c300c4d62165c3eac22834</id>
<content type='text'>
Add fdm_signal_add() and fdm_signal_del(). Signals added to the fdm
will be monitored, and the provided callback called as “soon as
possible” from the main context (i.e not from the signal handler
context).

Monitored signals are *blocked* by default. We use epoll_pwait() to
unblock them while we’re polling. This allows us to do race-free
signal detection.

We use a single handler for all monitored signals; the handler simply
updates the signal’s slot in a global array (sized to fit SIGRTMAX
signals).

When epoll_pwait() returns EINTR, we loop the global array. The
callback associated with each signal that fired is called.
</content>
</entry>
<entry>
<title>fdm: add hook priorities</title>
<updated>2020-01-04T22:26:27Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-01-04T22:26:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=6534f64e6a1dfa21d8d99a195122035d741f7d65'/>
<id>urn:sha1:6534f64e6a1dfa21d8d99a195122035d741f7d65</id>
<content type='text'>
There are now three hook priorities: low, normal, high.

High priority hooks are executed *first*. Normal next, and last the
low priority hooks.

The renderer's terminal refresh hook now runs as a normal priority
hook.
</content>
</entry>
<entry>
<title>fdm: add support for hooks</title>
<updated>2020-01-04T18:48:15Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-01-04T18:48:15Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=a3c18e72f5804051c5111fea5f4fca488fa088ca'/>
<id>urn:sha1:a3c18e72f5804051c5111fea5f4fca488fa088ca</id>
<content type='text'>
Hooks are functions executed just before going into a poll(). Or just
after executing all FD handlers, if you like.
</content>
</entry>
<entry>
<title>fdm: add fdm_event_add() and fdm_event_del()</title>
<updated>2019-11-02T23:52:24Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2019-11-02T23:22:22Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=89997b97a0fb7f0fe0fa06de5409a03ed9ee91a8'/>
<id>urn:sha1:89997b97a0fb7f0fe0fa06de5409a03ed9ee91a8</id>
<content type='text'>
These functions allow users to modify already registered FDs, to add
or remove events they are interested in.
</content>
</entry>
<entry>
<title>fdm: don't free FD data that may be referenced by epoll return data</title>
<updated>2019-11-01T18:51:33Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2019-11-01T18:51:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=80c4721e578ae20f6c5a6b7959fde909582eeb85'/>
<id>urn:sha1:80c4721e578ae20f6c5a6b7959fde909582eeb85</id>
<content type='text'>
It is perfectly possible, and legal, for a FDM handler to delete
another handler. The problem however is when the epoll returned array
of FD events contain the removed FD handler *after* the handler that
removed it.

That is, if the epoll returned array is:

  [FD=13, FD=37]

and the handler for FD=13 removes FD=37, then given the current
implementation, the FD user data (our handler callback etc) will point
to a free:d address.

Add support for this situation by deferring FD handler removal *when
called from another handler*.

This is done by "locking" the FDM struct before looping the handlers
for FDs with events (and unlocking afterwards).

In fdm_del(), we check if the FDM has been locked, in which case the
FD is marked as deleted, and put on a deferred list. But
not *actually* deleted.

Meanwhile, in the FDM poll function, we skip calling handlers for
marked-for-deletion FDs.

Then, when all FDs have been processed, we loop the deferred list and
finally deletes the FDs for real.
</content>
</entry>
<entry>
<title>fdm: use the FDM's poll loop</title>
<updated>2019-10-27T10:46:18Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2019-10-27T10:46:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=5fefb950b3a1de2c8c8e2cbfecf4ed3790ecffef'/>
<id>urn:sha1:5fefb950b3a1de2c8c8e2cbfecf4ed3790ecffef</id>
<content type='text'>
</content>
</entry>
</feed>
