@@ -148,9 +148,9 @@ static const QString SETTINGS_CODE = QStringLiteral("settings");
148148static const QString KEYBOARD_CODE = QStringLiteral(" keyboard" );
149149
150150static const int HOTCACHE_COST_MAX = 5000 ;
151- static const int HOTCACHE_COST_STRONG = 1 ;
152- static const int HOTCACHE_COST_WEAK = 3 ;
153- static const int HOTCACHE_COST = 2 ;
151+ static const int HOTCACHE_COST_STRONG = 1 ;
152+ static const int HOTCACHE_COST_DEFAULT = 2 ;
153+ static const int HOTCACHE_COST_WEAK = 3 ;
154154
155155/* !
156156 \class PatchManagerObject
@@ -1868,33 +1868,44 @@ void PatchManagerObject::startReadingLocalServer()
18681868 return ;
18691869 }
18701870 const QByteArray request = clientConnection->readAll ();
1871- QByteArray payload;
18721871 const QString fakePath = QStringLiteral (" %1%2" ).arg (s_patchmanagerCacheRoot, QString::fromLatin1 (request));
1873- payload = request ;
1872+ bool passAsIs = true ;
18741873 if (
18751874 (!m_failed) // return unaltered for failed
18761875 && (!m_filter.active () || !m_filter.contains (request)) // filter inactive or not in the list of unpatched files
18771876 && (Q_UNLIKELY (QFileInfo::exists (fakePath))) // file is patched
18781877 )
18791878 {
1880- payload = fakePath. toLatin1 () ;
1879+ passAsIs = false ;
18811880 } else {
18821881 // failed state or file is unpatched
1882+ passAsIs = true ;
1883+ }
1884+ /* write the result back to the library as soon as possible */
1885+ if (passAsIs) {
1886+ clientConnection->write (request);
1887+ } else {
1888+ clientConnection->write (fakePath.toLatin1 ());
18831889 }
1884- clientConnection->write (payload);
18851890 clientConnection->flush ();
18861891// clientConnection->waitForBytesWritten();
18871892
1888- // print debug and manage the cache after writing the data:
1889- if (payload == request) { // file didn't exist
1893+ /* print debug and manage the cache after writing the data:
1894+ * if the file didn't exist, we add it to the cache.
1895+ * otherwise, we so nothing, but check that it wasn't wrongly in the
1896+ * cache, which shouldn't happen.
1897+ * Note that we don't actually store anything in the cache, we're only
1898+ * interested in the key and the cost management.
1899+ */
1900+ if (passAsIs) { // file didn't exist
18901901 if (qEnvironmentVariableIsSet (" PM_DEBUG_SOCKET" )) {
18911902 qDebug () << Q_FUNC_INFO << " Requested:" << request << " was sent unaltered." ;
18921903 }
18931904 QObject *dummy = new QObject (); // the cache will own it later
1894- m_filter.insert (request, dummy, HOTCACHE_COST ); // cost: see setupFilter, use middle ground here
1905+ m_filter.insert (request, dummy, HOTCACHE_COST_DEFAULT ); // cost: see setupFilter, use middle ground here
18951906 } else {
18961907 if (qEnvironmentVariableIsSet (" PM_DEBUG_SOCKET" )) {
1897- qDebug () << Q_FUNC_INFO << " Requested:" << request << " Sent:" << payload ;
1908+ qDebug () << Q_FUNC_INFO << " Requested:" << request << " Sent:" << fakePath ;
18981909 }
18991910 if (m_filter.remove (request)) {
19001911 qWarning () << Q_FUNC_INFO << " Hot cache: contained a patched file!" ;
0 commit comments