-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
thread safety #41
Comments
Do you create a different instance of the generated service object (or of KDSoapClientInterface, if using that directly), in each thread? Using the same instance isn't threadsafe indeed. |
Yes, we were instantiating one service object per thread. However, we might have found the issue: QString KDSoapNamespaceManager::xmlSchema1999() When multiple threads come in here the very first time simultaneously, there is a problem. This was actually happening pretty often (90% of the time). After moving all static variable initializations out of the function bodies, the problem seems to be gone. Do you want me to commit the changes? Best regards |
Ah, good find. But maybe we can do something simpler here: QStringLiteral() with Qt5 and QString::fromLatin1() with Qt4 (slower, but "fixed" in Qt5). |
Sure, something like this up front? namespace and then simple implementations like this: QString KDSoapNamespaceManager::xmlSchema1999() |
These are the "global static objects" that I know can give trouble, see my previous message. |
true, they can give trouble due to order problems. However I am not sure if - in this particular case - there is a danger of "out of sequence" initialization. These strings are independent from each other and just used within this cpp file. So, the order doesn't matter, as long as they are initialized at all. Your call. It is your library :) |
The problem is order of initialization not between these strings, but compared to the global statics in Qt itself. I'll create strings on the fly for Qt4 (thanks for the confirmation that you see no issue with that), and use QStringLiteral for Qt5 (which doesn't need any conversions, so it will be very fast). |
Further investigation reveals that gcc implements thread safety for function-local statics (as mandated by C++11, but it has done so for a much longer time), while MSVC doesn't (and still doesn't in MSVC2013). I committed the removal of "static" now in 5027b0c, sorry for the delay. |
Hello,
could it be, that the client code generated by kdwsdl2cpp is not thread safe?
When calling "executeCommand" simultaneously in concurrent threads I get weird crashes. With a single thread It is working like a charm though.
I couldn't find any documentation about the client side thread safety and therefore appreciate any comment on it.
Thank you in advance
Stefan
The text was updated successfully, but these errors were encountered: