[QGIS-Developer] QGIS Server plugins and thread safety

Alessandro Pasotti apasotti at gmail.com
Sun Nov 19 07:58:38 PST 2017


Maybe I've found a simple and effective no-API-break solution: I'm working
on a QThreadStorage based implementation of the server iface request
handler that might be the simplest solution to this issue.

Btw this is only one of the most obvious issues in the server thread
safety, there are certainly more areas that need to be checked before we
can say that QgsServer class it thread-safe.

Happy sunday :)



On Sun, Nov 19, 2017 at 10:34 AM, Alessandro Pasotti <apasotti at gmail.com>
wrote:

> Hi,
>
> mi recent experiments with multi-threaded python wrappers for QGIS server
> showed a critical flaw in my original implementation of the server plugins.
>
> First, I want to stress that this is not a problem in FCGI server
> implementation but only if the server is used directly from python in a
> multi threaded server implementation.
>
> The problem is that the server interface that exposes the request handler
> is a static property of the interface, that is changed on every request.
> This means that there is a race condition in setting/accessing the handler
> from a plugin filter, and that a plugin filter might access to the handler
> for a wrong request.
>
> The solution is to pass the request handler (or the request and/or
> response objects depending on the filter) to the plugin filters and leave
> the interface for static properties only.
>
> This would be a big API change for the server interface and filters and
> I'm not sure we have time/resources to do that now.
>
> As an alternative we could simply document the issue and change the
> testing code to create a new server instance to server every request (to be
> verified, and with consitent performance degradation).
>
> What's your opinion about this issue?
>
> BTW,  tomorrow I'll file a ticket for this problem.
>
> --
> Alessandro Pasotti
> w3:   www.itopen.it
>



-- 
Alessandro Pasotti
w3:   www.itopen.it
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20171119/f8c28702/attachment.html>


More information about the QGIS-Developer mailing list