Repository navigation
add LOCK() for proxy related data-structures - #1859
Conversation
There was a problem hiding this comment.
Using one "proxy info" lock would be enough, no need for a separate one for the nameproxy.
|
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/bd5f5de6b8ab13ec34c96fa7376da329a07c1105 for binaries and test log. |
|
ACK |
There was a problem hiding this comment.
Holding the cs_proxyInfos lock all through ConnectSocket and it's subroutines is bad practice.
How about something like:
proxyType proxy; { LOCK(cs_proxyInfos); proxy = proxyInfo[addrDest.GetNetwork()]; }
... proceed, with local copy of proxy...
There was a problem hiding this comment.
Or... We already have a GetProxy function to encapsulate getting values from proxyInfo, why not use it here?
There was a problem hiding this comment.
Just to understand, a lock is persistent in a function scope, right? So when I have a lock in a sub-function used in ConnectSocket it is released, when returning back to ConnectSocket.
There was a problem hiding this comment.
A scoped lock is acquired where you define it with LOCK(), and it is released immediately at the end of the block (}) in which you define it. So, yes.
|
I'm going to update this until early next week :). |
|
Updated to include 2 new functions to use local copies of the proxyInfo and nameproxyInfo objects in the time-critical functions, which removes the bad practise of holding the lock all through ConnectSocket and it's subroutines, as Gavin suggested. I chose to add these 2 function (currently not exposed to netbase.h), because I think I need those when updating the GUI with extended proxy settings. |
There was a problem hiding this comment.
What "is" a name proxy? I agree GetNameProxy() currently doesn't make sense either, but I'd go for HaveNameProxy().
|
@sipa I updated GetProxy() to fill a proxyType object and make that usable outsite of netbase.cpp (moved the typedef to netbase.h). |
There was a problem hiding this comment.
@laanwj I was asking myself, if this should be changed into, as data() returns active state for IP, port and SOCKS version, too.
case ProxyUse: {
proxyType proxy;
return QVariant(GetProxy(NET_IPV4, proxy));
}
There was a problem hiding this comment.
Could be better because that better represents the current configuration, but leave that for a later pull. Aim to keep functionality precisely the same in these commits.
There was a problem hiding this comment.
Understood :), thanks for your valuable input master!
|
ACK on changes to core. |
|
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/fd31870d2820d7e1d0f8f3253f081aa71c0b2dca for binaries and test log. |
|
@laanwj Anything left for the Qt changes? I trie to not include feature-changes and will do that after this got merged. |
|
ACK |
|
No code changes, only updated some code-layout in optionsmodel.cpp. |
There was a problem hiding this comment.
I'd suggest using the return value of GetProxy here, instead of querying proxy.second later on. It's a little bit more readable.
There was a problem hiding this comment.
Yes, good idea ... and updated :).
- fix #1560 by properly locking proxy related data-structures - update GetProxy() and introduce GetNameProxy() to be able to use a thread-safe local copy from proxyInfo and nameproxyInfo - update usage of GetProxy() all over the source to match the new behaviour, as it now fills a full proxyType object - rename GetNameProxy() into HaveNameProxy() to be more clear
|
Can we get this fix into 0.7.1? |
|
Yes as I said on the mailing list, that's the goal. Avoiding corner-case random crashes is always good. |
add LOCK() for proxy related data-structures
thread-safe local copy from proxyInfo and nameproxyInfo