]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commit
Use a separate pango fontmap per thread
authorSimon Arlott <sa.me.uk>
Fri, 11 Dec 2020 18:38:42 +0000 (18:38 +0000)
committerWolfgang Stöggl <c72578@yahoo.de>
Mon, 14 Dec 2020 06:50:14 +0000 (07:50 +0100)
commitb13bffbaf256fdf27bb0294ac647cdba5c802ffb
treeead2c71ce93bd5eb4f860940d112c80c4c208228
parent1bf874c74790109c4c32134bf0f58b6f6de7791a
Use a separate pango fontmap per thread

Reusing the same fontmap from multiple threads is not safe, despite
the attempts to use a mutex to protect it there are other instances
where it behaves unexpectedly if graphs are created from multiple
threads at the same time, e.g.:

(process:76234): Pango-WARNING **: 11:47:25.823: failed to create cairo scaled font, expect ugly output. the offending font is 'DejaVu Sans Mono 8'
(process:76234): Pango-WARNING **: 11:47:25.823: font_face status is: no error has occurred
(process:76234): Pango-WARNING **: 11:47:25.823: scaled_font status is: invalid matrix (not invertible)
(process:76234): Pango-WARNING **: 11:47:25.823: shaping failure, expect ugly output. shape-engine='PangoFcShapeEngine', font='DejaVu Sans Mono 8', text='Apparent temp (?C)'

This error results in boxes instead of characters on the graph. In the
worst case scenario there are memory management errors that cause GLib
to complain or the process to abort.

Calling pango_cairo_font_map_get_default() multiple times from the same
thread will return the same object, so this satisfies the performance
expectations of reusing it within a single thread. Trying to lock a
mutex for even more pango/cairo function calls is likely to decrease
performance when multiple threads are used concurrently.
src/rrd_graph.c
src/rrd_graph.h