diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-11-23 18:26:00 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-11-23 18:26:00 +0000 |
| commit | 90edc096971aa013dbacf1315271c2f2da62bd59 (patch) | |
| tree | 75d592ca2c4797188d5d6f34790e535085c964a6 | |
| parent | sixel: fix crash when an explicit sixel size had a height less than 6 pixels (diff) | |
render: don’t call term_arm_blink_timer() from multiple threads
We call term_arm_blink_timer() from render_cell(), which runs in
multiple threads.
This caused multiple blink timer FDs to be created and registered with
the FDM, later causing read failures after one of those FDs had been
closed again.
This rarely happened under normal circumstances, but was easy to
trigger when the whole screen was full of blinking text.
As a small optimization, we don’t bother taking the lock if the timer
FD already is valid.
This is safe, because:
1) If the timer FD isn’t valid, we take the lock and then call
term_arm_blink_timer(), which again checks if the FD is already
valid.
2) The blink timer FD cannot be closed while we’re rendering cells. It
is only disabled in the FDM callback, which cannot execute while
we’re rendering.
| -rw-r--r-- | render.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -487,8 +487,12 @@ render_cell(struct terminal *term, pixman_image_t *pix, PIXMAN_OP_SRC, pix, &bg, 1, &(pixman_rectangle16_t){x, y, cell_cols * width, height}); - if (cell->attrs.blink) + if (cell->attrs.blink && term->blink.fd < 0) { + /* TODO: use a custom lock for this? */ + mtx_lock(&term->render.workers.lock); term_arm_blink_timer(term); + mtx_unlock(&term->render.workers.lock); + } if (has_cursor && term->cursor_style == CURSOR_BLOCK && term->kbd_focus) draw_cursor(term, cell, font, pix, &fg, &bg, x, y, cell_cols); @@ -499,7 +503,6 @@ render_cell(struct terminal *term, pixman_image_t *pix, pixman_image_t *clr_pix = pixman_image_create_solid_fill(&fg); if (glyph != NULL) { - /* Clip to cell */ if (unlikely(pixman_image_get_format(glyph->pix) == PIXMAN_a8r8g8b8)) { /* Glyph surface is a pre-rendered image (typically a color emoji...) */ if (!(cell->attrs.blink && term->blink.state == BLINK_OFF)) { |
