<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/foot.git/fdm.c, branch 1.6.4</title>
<subtitle>A fast, lightweight and minimalistic Wayland terminal emulator</subtitle>
<id>https://git.0x0f.dev/mirrors/foot.git/atom?h=1.6.4</id>
<link rel='self' href='https://git.0x0f.dev/mirrors/foot.git/atom?h=1.6.4'/>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/'/>
<updated>2021-02-12T09:53:10Z</updated>
<entry>
<title>fdm: add support for managing signals</title>
<updated>2021-02-12T09:53:10Z</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=cf1335f2580ae303ace3bac6fa0d1a25c7d5b60d'/>
<id>urn:sha1:cf1335f2580ae303ace3bac6fa0d1a25c7d5b60d</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: do *not* keep polling on EINTR</title>
<updated>2020-12-04T17:36:53Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-12-04T17:36:53Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=384ba4d30d4a77751a8068d9aebaaee2c02cf10c'/>
<id>urn:sha1:384ba4d30d4a77751a8068d9aebaaee2c02cf10c</id>
<content type='text'>
This fixes an issue where foot --server did not exit on SIGINT. This
happened because we never returned out from fdm_poll(), and thus we
never saw ‘aborted’ being set.
</content>
</entry>
<entry>
<title>fdm: keep polling on EINTR</title>
<updated>2020-11-26T17:23:01Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-11-26T17:23:01Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=15b35b7641955949acaa209986ff3fa8b7f1a98e'/>
<id>urn:sha1:15b35b7641955949acaa209986ff3fa8b7f1a98e</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Cast printf formatter %p arguments to void*</title>
<updated>2020-08-23T08:07:08Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-08-23T05:50:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=e32c0d9bf698782353bbe9e4348617523af473bd'/>
<id>urn:sha1:e32c0d9bf698782353bbe9e4348617523af473bd</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Convert most dynamic allocations to use functions from xmalloc.h</title>
<updated>2020-08-08T19:37:57Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2020-08-08T19:34:30Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=7a77958ba20c2b344be5e66e69e2f212a4bbf6b3'/>
<id>urn:sha1:7a77958ba20c2b344be5e66e69e2f212a4bbf6b3</id>
<content type='text'>
</content>
</entry>
<entry>
<title>fdm: fix log message</title>
<updated>2020-01-10T18:22:41Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-01-10T18:22:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=a07de9ef3c402371b5a484b6eb2271ec31a774b9'/>
<id>urn:sha1:a07de9ef3c402371b5a484b6eb2271ec31a774b9</id>
<content type='text'>
</content>
</entry>
<entry>
<title>fdm: verify FDs are non-blocking (debug builds only)</title>
<updated>2020-01-10T18:22:10Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-01-10T18:22:10Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=698d5fdf06b79b66633629c7a387fa26ff352eca'/>
<id>urn:sha1:698d5fdf06b79b66633629c7a387fa26ff352eca</id>
<content type='text'>
</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: close fd even if we didn't find it in our list</title>
<updated>2019-12-15T14:06:09Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2019-12-15T14:06:09Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=5106937c7b24933bb1f906f672606147c4bac1cb'/>
<id>urn:sha1:5106937c7b24933bb1f906f672606147c4bac1cb</id>
<content type='text'>
This behavior is debatable, but helps in error handling where we're
removing a bunch of descriptors where not all of them have been added
to the FDM yet.
</content>
</entry>
<entry>
<title>tllist: is now an external "library", so use &lt;&gt; includes</title>
<updated>2019-11-17T18:19:55Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2019-11-17T18:19:55Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=29cccadd1d9c372b3861bb0c285628bb374da2ba'/>
<id>urn:sha1:29cccadd1d9c372b3861bb0c285628bb374da2ba</id>
<content type='text'>
</content>
</entry>
<entry>
<title>fdm: invert check to get rid of one level of indentation</title>
<updated>2019-11-02T23:52:24Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2019-11-02T23:42:34Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=777d851282a59fcfacc19b9232b9ad80c412efdf'/>
<id>urn:sha1:777d851282a59fcfacc19b9232b9ad80c412efdf</id>
<content type='text'>
</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: bug: 'ret' was renamed to 'r', and replaced with another 'ret'</title>
<updated>2019-11-02T23:51:47Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2019-11-02T23:51:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=e09bda322a2d39e6692b3dbd3ccf72bc86951737'/>
<id>urn:sha1:e09bda322a2d39e6692b3dbd3ccf72bc86951737</id>
<content type='text'>
</content>
</entry>
<entry>
<title>fdm: rename struct fd -&gt; struct handler</title>
<updated>2019-11-02T22:37:19Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2019-11-02T22:37:19Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=8ffa021de86b08b28be33b769f129c3c951ad1a7'/>
<id>urn:sha1:8ffa021de86b08b28be33b769f129c3c951ad1a7</id>
<content type='text'>
</content>
</entry>
<entry>
<title>fdm: fdm_destroy(): assert deferred delete list is empty</title>
<updated>2019-11-02T22:36:02Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2019-11-02T22:36:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=9b67a6627ad42557dd71e9bd09a21bd75f0d3b45'/>
<id>urn:sha1:9b67a6627ad42557dd71e9bd09a21bd75f0d3b45</id>
<content type='text'>
</content>
</entry>
<entry>
<title>fdm: purge deferred delete list also when handler fails</title>
<updated>2019-11-02T22:35:42Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2019-11-02T22:35:42Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=ba7f79af18ef3713eefc71a52012e255adfbc30e'/>
<id>urn:sha1:ba7f79af18ef3713eefc71a52012e255adfbc30e</id>
<content type='text'>
</content>
</entry>
<entry>
<title>fdm: fdm_poll(): disallow nested calls</title>
<updated>2019-11-02T12:46:54Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2019-11-02T12:46:54Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=c99c0285dc5d5fc38fa4dbee1cba70a660578fca'/>
<id>urn:sha1:c99c0285dc5d5fc38fa4dbee1cba70a660578fca</id>
<content type='text'>
</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>
