| Line | Source Code | Coverage |
|---|
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | | - |
| 10 | | - |
| 11 | static QHostInfoLookupManager *theHostInfoLookupManager() { static QGlobalStatic<QHostInfoLookupManager > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QHostInfoLookupManager *x = new QHostInfoLookupManager; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QHostInfoLookupManager > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); } never executed: delete x; executed: return thisGlobalStatic.pointer.load();Execution Count:2483 partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)| no Evaluation Count:0 | yes Evaluation Count:13 |
evaluated: !thisGlobalStatic.pointer.load()| yes Evaluation Count:13 | yes Evaluation Count:2470 |
partially evaluated: !thisGlobalStatic.destroyed| yes Evaluation Count:13 | no Evaluation Count:0 |
| 0-2483 |
| 12 | static QBasicAtomicInt theIdCounter = { (1) }; | - |
| 13 | int QHostInfo::lookupHost(const QString &name, QObject *receiver, | - |
| 14 | const char *member) | - |
| 15 | { | - |
| 16 | | - |
| 17 | | - |
| 18 | | - |
| 19 | | - |
| 20 | | - |
| 21 | if (!QAbstractEventDispatcher::instance(QThread::currentThread())) { partially evaluated: !QAbstractEventDispatcher::instance(QThread::currentThread())| no Evaluation Count:0 | yes Evaluation Count:132 |
| 0-132 |
| 22 | QMessageLogger("kernel/qhostinfo.cpp", 158, __PRETTY_FUNCTION__).warning("QHostInfo::lookupHost() called with no event dispatcher"); | - |
| 23 | return -1; never executed: return -1; | 0 |
| 24 | } | - |
| 25 | | - |
| 26 | qRegisterMetaType<QHostInfo>(); | - |
| 27 | | - |
| 28 | int id = theIdCounter.fetchAndAddRelaxed(1); | - |
| 29 | | - |
| 30 | if (name.isEmpty()) { partially evaluated: name.isEmpty()| no Evaluation Count:0 | yes Evaluation Count:132 |
| 0-132 |
| 31 | QHostInfo hostInfo(id); | - |
| 32 | hostInfo.setError(QHostInfo::HostNotFound); | - |
| 33 | hostInfo.setErrorString(QCoreApplication::translate("QHostInfo", "No host name given")); | - |
| 34 | QScopedPointer<QHostInfoResult> result(new QHostInfoResult); | - |
| 35 | QObject::connect(result.data(), "2""resultsReady(QHostInfo)", | - |
| 36 | receiver, member, Qt::QueuedConnection); | - |
| 37 | result.data()->emitResultsReady(hostInfo); | - |
| 38 | return id; never executed: return id; | 0 |
| 39 | } | - |
| 40 | | - |
| 41 | QHostInfoLookupManager *manager = theHostInfoLookupManager(); | - |
| 42 | | - |
| 43 | if (manager) { partially evaluated: manager| yes Evaluation Count:132 | no Evaluation Count:0 |
| 0-132 |
| 44 | | - |
| 45 | if (manager->cache.isEnabled()) { partially evaluated: manager->cache.isEnabled()| yes Evaluation Count:132 | no Evaluation Count:0 |
| 0-132 |
| 46 | | - |
| 47 | bool valid = false; | - |
| 48 | QHostInfo info = manager->cache.get(name, &valid); | - |
| 49 | if (valid) { evaluated: valid| yes Evaluation Count:1 | yes Evaluation Count:131 |
| 1-131 |
| 50 | info.setLookupId(id); | - |
| 51 | QHostInfoResult result; | - |
| 52 | QObject::connect(&result, "2""resultsReady(QHostInfo)", receiver, member, Qt::QueuedConnection); | - |
| 53 | result.emitResultsReady(info); | - |
| 54 | return id; executed: return id;Execution Count:1 | 1 |
| 55 | } | - |
| 56 | } executed: }Execution Count:131 | 131 |
| 57 | | - |
| 58 | | - |
| 59 | QHostInfoRunnable* runnable = new QHostInfoRunnable(name, id); | - |
| 60 | QObject::connect(&runnable->resultEmitter, "2""resultsReady(QHostInfo)", receiver, member, Qt::QueuedConnection); | - |
| 61 | manager->scheduleLookup(runnable); | - |
| 62 | } executed: }Execution Count:131 | 131 |
| 63 | return id; executed: return id;Execution Count:131 | 131 |
| 64 | } | - |
| 65 | | - |
| 66 | | - |
| 67 | | - |
| 68 | | - |
| 69 | | - |
| 70 | | - |
| 71 | void QHostInfo::abortHostLookup(int id) | - |
| 72 | { | - |
| 73 | theHostInfoLookupManager()->abortLookup(id); | - |
| 74 | } executed: }Execution Count:120 | 120 |
| 75 | QHostInfo QHostInfo::fromName(const QString &name) | - |
| 76 | { | - |
| 77 | | - |
| 78 | | - |
| 79 | | - |
| 80 | | - |
| 81 | QHostInfo hostInfo = QHostInfoAgent::fromName(name); | - |
| 82 | QAbstractHostInfoLookupManager* manager = theHostInfoLookupManager(); | - |
| 83 | manager->cache.put(name, hostInfo); | - |
| 84 | return hostInfo; executed: return hostInfo;Execution Count:23 | 23 |
| 85 | } | - |
| 86 | | - |
| 87 | | - |
| 88 | QHostInfo QHostInfoPrivate::fromName(const QString &name, QSharedPointer<QNetworkSession> session) | - |
| 89 | { | - |
| 90 | | - |
| 91 | | - |
| 92 | | - |
| 93 | | - |
| 94 | QHostInfo hostInfo = QHostInfoAgent::fromName(name, session); | - |
| 95 | QAbstractHostInfoLookupManager* manager = theHostInfoLookupManager(); | - |
| 96 | manager->cache.put(name, hostInfo); | - |
| 97 | return hostInfo; never executed: return hostInfo; | 0 |
| 98 | } | - |
| 99 | | - |
| 100 | | - |
| 101 | | - |
| 102 | QHostInfo QHostInfoAgent::fromName(const QString &hostName, QSharedPointer<QNetworkSession>) | - |
| 103 | { | - |
| 104 | return QHostInfoAgent::fromName(hostName); never executed: return QHostInfoAgent::fromName(hostName); | 0 |
| 105 | } | - |
| 106 | QHostInfo::QHostInfo(int id) | - |
| 107 | : d(new QHostInfoPrivate) | - |
| 108 | { | - |
| 109 | d->lookupId = id; | - |
| 110 | } executed: }Execution Count:990 | 990 |
| 111 | | - |
| 112 | | - |
| 113 | | - |
| 114 | | - |
| 115 | QHostInfo::QHostInfo(const QHostInfo &other) | - |
| 116 | : d(new QHostInfoPrivate(*other.d.data())) | - |
| 117 | { | - |
| 118 | } executed: }Execution Count:4389 | 4389 |
| 119 | | - |
| 120 | | - |
| 121 | | - |
| 122 | | - |
| 123 | | - |
| 124 | QHostInfo &QHostInfo::operator=(const QHostInfo &other) | - |
| 125 | { | - |
| 126 | *d.data() = *other.d.data(); | - |
| 127 | return *this; executed: return *this;Execution Count:57 | 57 |
| 128 | } | - |
| 129 | | - |
| 130 | | - |
| 131 | | - |
| 132 | | - |
| 133 | QHostInfo::~QHostInfo() | - |
| 134 | { | - |
| 135 | } | - |
| 136 | QList<QHostAddress> QHostInfo::addresses() const | - |
| 137 | { | - |
| 138 | return d->addrs; executed: return d->addrs;Execution Count:2526 | 2526 |
| 139 | } | - |
| 140 | | - |
| 141 | | - |
| 142 | | - |
| 143 | | - |
| 144 | | - |
| 145 | | - |
| 146 | void QHostInfo::setAddresses(const QList<QHostAddress> &addresses) | - |
| 147 | { | - |
| 148 | d->addrs = addresses; | - |
| 149 | } executed: }Execution Count:550 | 550 |
| 150 | | - |
| 151 | | - |
| 152 | | - |
| 153 | | - |
| 154 | | - |
| 155 | | - |
| 156 | QString QHostInfo::hostName() const | - |
| 157 | { | - |
| 158 | return d->hostName; never executed: return d->hostName; | 0 |
| 159 | } | - |
| 160 | | - |
| 161 | | - |
| 162 | | - |
| 163 | | - |
| 164 | | - |
| 165 | | - |
| 166 | void QHostInfo::setHostName(const QString &hostName) | - |
| 167 | { | - |
| 168 | d->hostName = hostName; | - |
| 169 | } executed: }Execution Count:36 | 36 |
| 170 | | - |
| 171 | | - |
| 172 | | - |
| 173 | | - |
| 174 | | - |
| 175 | | - |
| 176 | | - |
| 177 | QHostInfo::HostInfoError QHostInfo::error() const | - |
| 178 | { | - |
| 179 | return d->err; executed: return d->err;Execution Count:50 | 50 |
| 180 | } | - |
| 181 | | - |
| 182 | | - |
| 183 | | - |
| 184 | | - |
| 185 | | - |
| 186 | | - |
| 187 | void QHostInfo::setError(HostInfoError error) | - |
| 188 | { | - |
| 189 | d->err = error; | - |
| 190 | } executed: }Execution Count:5 | 5 |
| 191 | | - |
| 192 | | - |
| 193 | | - |
| 194 | | - |
| 195 | | - |
| 196 | | - |
| 197 | int QHostInfo::lookupId() const | - |
| 198 | { | - |
| 199 | return d->lookupId; executed: return d->lookupId;Execution Count:2 | 2 |
| 200 | } | - |
| 201 | | - |
| 202 | | - |
| 203 | | - |
| 204 | | - |
| 205 | | - |
| 206 | | - |
| 207 | void QHostInfo::setLookupId(int id) | - |
| 208 | { | - |
| 209 | d->lookupId = id; | - |
| 210 | } executed: }Execution Count:13 | 13 |
| 211 | | - |
| 212 | | - |
| 213 | | - |
| 214 | | - |
| 215 | | - |
| 216 | | - |
| 217 | | - |
| 218 | QString QHostInfo::errorString() const | - |
| 219 | { | - |
| 220 | return d->errorStr; executed: return d->errorStr;Execution Count:2 | 2 |
| 221 | } | - |
| 222 | | - |
| 223 | | - |
| 224 | | - |
| 225 | | - |
| 226 | | - |
| 227 | | - |
| 228 | | - |
| 229 | void QHostInfo::setErrorString(const QString &str) | - |
| 230 | { | - |
| 231 | d->errorStr = str; | - |
| 232 | } executed: }Execution Count:5 | 5 |
| 233 | QHostInfoRunnable::QHostInfoRunnable(QString hn, int i) : toBeLookedUp(hn), id(i) | - |
| 234 | { | - |
| 235 | setAutoDelete(true); | - |
| 236 | } executed: }Execution Count:131 | 131 |
| 237 | | - |
| 238 | | - |
| 239 | void QHostInfoRunnable::run() | - |
| 240 | { | - |
| 241 | QHostInfoLookupManager *manager = theHostInfoLookupManager(); | - |
| 242 | | - |
| 243 | if (manager->wasAborted(id)) { evaluated: manager->wasAborted(id)| yes Evaluation Count:88 | yes Evaluation Count:13 |
| 13-88 |
| 244 | manager->lookupFinished(this); | - |
| 245 | return; executed: return;Execution Count:88 | 88 |
| 246 | } | - |
| 247 | | - |
| 248 | QHostInfo hostInfo; | - |
| 249 | | - |
| 250 | | - |
| 251 | | - |
| 252 | | - |
| 253 | if (manager->cache.isEnabled()) { partially evaluated: manager->cache.isEnabled()| yes Evaluation Count:13 | no Evaluation Count:0 |
| 0-13 |
| 254 | | - |
| 255 | bool valid = false; | - |
| 256 | hostInfo = manager->cache.get(toBeLookedUp, &valid); | - |
| 257 | if (!valid) { partially evaluated: !valid| yes Evaluation Count:13 | no Evaluation Count:0 |
| 0-13 |
| 258 | | - |
| 259 | hostInfo = QHostInfoAgent::fromName(toBeLookedUp); | - |
| 260 | manager->cache.put(toBeLookedUp, hostInfo); | - |
| 261 | } executed: }Execution Count:13 | 13 |
| 262 | } else { executed: }Execution Count:13 | 13 |
| 263 | | - |
| 264 | hostInfo = QHostInfoAgent::fromName(toBeLookedUp); | - |
| 265 | } | 0 |
| 266 | | - |
| 267 | | - |
| 268 | if (manager->wasAborted(id)) { evaluated: manager->wasAborted(id)| yes Evaluation Count:1 | yes Evaluation Count:12 |
| 1-12 |
| 269 | manager->lookupFinished(this); | - |
| 270 | return; executed: return;Execution Count:1 | 1 |
| 271 | } | - |
| 272 | | - |
| 273 | | - |
| 274 | hostInfo.setLookupId(id); | - |
| 275 | resultEmitter.emitResultsReady(hostInfo); | - |
| 276 | | - |
| 277 | | - |
| 278 | { | - |
| 279 | QMutexLocker locker(&manager->mutex); | - |
| 280 | QMutableListIterator<QHostInfoRunnable*> iterator(manager->postponedLookups); | - |
| 281 | while (iterator.hasNext()) { partially evaluated: iterator.hasNext()| no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
| 282 | QHostInfoRunnable* postponed = iterator.next(); | - |
| 283 | if (toBeLookedUp == postponed->toBeLookedUp) { never evaluated: toBeLookedUp == postponed->toBeLookedUp | 0 |
| 284 | | - |
| 285 | iterator.remove(); | - |
| 286 | hostInfo.setLookupId(postponed->id); | - |
| 287 | postponed->resultEmitter.emitResultsReady(hostInfo); | - |
| 288 | delete postponed; | - |
| 289 | } | 0 |
| 290 | } | 0 |
| 291 | } | - |
| 292 | | - |
| 293 | manager->lookupFinished(this); | - |
| 294 | | - |
| 295 | | - |
| 296 | } executed: }Execution Count:12 | 12 |
| 297 | | - |
| 298 | QHostInfoLookupManager::QHostInfoLookupManager() : mutex(QMutex::Recursive), wasDeleted(false) | - |
| 299 | { | - |
| 300 | moveToThread(QCoreApplicationPrivate::mainThread()); | - |
| 301 | connect(QCoreApplication::instance(), "2""destroyed()", "1""waitForThreadPoolDone()", Qt::DirectConnection); | - |
| 302 | threadPool.setMaxThreadCount(5); | - |
| 303 | } executed: }Execution Count:13 | 13 |
| 304 | | - |
| 305 | QHostInfoLookupManager::~QHostInfoLookupManager() | - |
| 306 | { | - |
| 307 | wasDeleted = true; | - |
| 308 | | - |
| 309 | | - |
| 310 | clear(); | - |
| 311 | } executed: }Execution Count:13 | 13 |
| 312 | | - |
| 313 | void QHostInfoLookupManager::clear() | - |
| 314 | { | - |
| 315 | { | - |
| 316 | QMutexLocker locker(&mutex); | - |
| 317 | qDeleteAll(postponedLookups); | - |
| 318 | qDeleteAll(scheduledLookups); | - |
| 319 | qDeleteAll(finishedLookups); | - |
| 320 | postponedLookups.clear(); | - |
| 321 | scheduledLookups.clear(); | - |
| 322 | finishedLookups.clear(); | - |
| 323 | } | - |
| 324 | | - |
| 325 | threadPool.waitForDone(); | - |
| 326 | cache.clear(); | - |
| 327 | } executed: }Execution Count:13 | 13 |
| 328 | | - |
| 329 | void QHostInfoLookupManager::work() | - |
| 330 | { | - |
| 331 | if (wasDeleted) partially evaluated: wasDeleted| no Evaluation Count:0 | yes Evaluation Count:232 |
| 0-232 |
| 332 | return; | 0 |
| 333 | | - |
| 334 | | - |
| 335 | | - |
| 336 | | - |
| 337 | | - |
| 338 | QMutexLocker locker(&mutex); | - |
| 339 | | - |
| 340 | if (!finishedLookups.isEmpty()) { evaluated: !finishedLookups.isEmpty()| yes Evaluation Count:101 | yes Evaluation Count:131 |
| 101-131 |
| 341 | | - |
| 342 | for (int i = 0; i < finishedLookups.length(); i++) { evaluated: i < finishedLookups.length()| yes Evaluation Count:101 | yes Evaluation Count:101 |
| 101 |
| 343 | abortedLookups.removeAll(finishedLookups.at(i)->id); | - |
| 344 | } executed: }Execution Count:101 | 101 |
| 345 | | - |
| 346 | finishedLookups.clear(); | - |
| 347 | } executed: }Execution Count:101 | 101 |
| 348 | | - |
| 349 | if (!postponedLookups.isEmpty()) { partially evaluated: !postponedLookups.isEmpty()| no Evaluation Count:0 | yes Evaluation Count:232 |
| 0-232 |
| 350 | | - |
| 351 | | - |
| 352 | QMutableListIterator<QHostInfoRunnable*> iterator(postponedLookups); | - |
| 353 | while (iterator.hasNext()) { never evaluated: iterator.hasNext() | 0 |
| 354 | QHostInfoRunnable* postponed = iterator.next(); | - |
| 355 | | - |
| 356 | | - |
| 357 | bool alreadyRunning = false; | - |
| 358 | for (int i = 0; i < currentLookups.length(); i++) { never evaluated: i < currentLookups.length() | 0 |
| 359 | if (currentLookups.at(i)->toBeLookedUp == postponed->toBeLookedUp) { never evaluated: currentLookups.at(i)->toBeLookedUp == postponed->toBeLookedUp | 0 |
| 360 | alreadyRunning = true; | - |
| 361 | break; | 0 |
| 362 | } | - |
| 363 | } | 0 |
| 364 | if (!alreadyRunning) { never evaluated: !alreadyRunning | 0 |
| 365 | iterator.remove(); | - |
| 366 | scheduledLookups.prepend(postponed); | - |
| 367 | } | 0 |
| 368 | } | 0 |
| 369 | } | 0 |
| 370 | | - |
| 371 | if (!scheduledLookups.isEmpty()) { evaluated: !scheduledLookups.isEmpty()| yes Evaluation Count:131 | yes Evaluation Count:101 |
| 101-131 |
| 372 | | - |
| 373 | QMutableListIterator<QHostInfoRunnable*> iterator(scheduledLookups); | - |
| 374 | while (iterator.hasNext()) { evaluated: iterator.hasNext()| yes Evaluation Count:131 | yes Evaluation Count:131 |
| 131 |
| 375 | QHostInfoRunnable *scheduled = iterator.next(); | - |
| 376 | | - |
| 377 | | - |
| 378 | for (int i = 0; i < currentLookups.size(); i++) { evaluated: i < currentLookups.size()| yes Evaluation Count:30 | yes Evaluation Count:101 |
| 30-101 |
| 379 | if (currentLookups.at(i)->toBeLookedUp == scheduled->toBeLookedUp) { partially evaluated: currentLookups.at(i)->toBeLookedUp == scheduled->toBeLookedUp| yes Evaluation Count:30 | no Evaluation Count:0 |
| 0-30 |
| 380 | iterator.remove(); | - |
| 381 | postponedLookups.append(scheduled); | - |
| 382 | scheduled = 0; | - |
| 383 | break; executed: break;Execution Count:30 | 30 |
| 384 | } | - |
| 385 | } | 0 |
| 386 | | - |
| 387 | if (scheduled && currentLookups.size() < threadPool.maxThreadCount()) { evaluated: scheduled| yes Evaluation Count:101 | yes Evaluation Count:30 |
partially evaluated: currentLookups.size() < threadPool.maxThreadCount()| yes Evaluation Count:101 | no Evaluation Count:0 |
| 0-101 |
| 388 | | - |
| 389 | threadPool.start(scheduled); | - |
| 390 | iterator.remove(); | - |
| 391 | currentLookups.append(scheduled); | - |
| 392 | } else { executed: }Execution Count:101 | 101 |
| 393 | | - |
| 394 | continue; executed: continue;Execution Count:30 | 30 |
| 395 | } | - |
| 396 | }; | - |
| 397 | } executed: }Execution Count:131 | 131 |
| 398 | } executed: }Execution Count:232 | 232 |
| 399 | | - |
| 400 | | - |
| 401 | void QHostInfoLookupManager::scheduleLookup(QHostInfoRunnable *r) | - |
| 402 | { | - |
| 403 | if (wasDeleted) partially evaluated: wasDeleted| no Evaluation Count:0 | yes Evaluation Count:131 |
| 0-131 |
| 404 | return; | 0 |
| 405 | | - |
| 406 | QMutexLocker locker(&this->mutex); | - |
| 407 | scheduledLookups.enqueue(r); | - |
| 408 | work(); | - |
| 409 | } executed: }Execution Count:131 | 131 |
| 410 | | - |
| 411 | | - |
| 412 | void QHostInfoLookupManager::abortLookup(int id) | - |
| 413 | { | - |
| 414 | if (wasDeleted) partially evaluated: wasDeleted| no Evaluation Count:0 | yes Evaluation Count:120 |
| 0-120 |
| 415 | return; | 0 |
| 416 | | - |
| 417 | QMutexLocker locker(&this->mutex); | - |
| 418 | | - |
| 419 | | - |
| 420 | for (int i = 0; i < postponedLookups.length(); i++) { evaluated: i < postponedLookups.length()| yes Evaluation Count:30 | yes Evaluation Count:90 |
| 30-90 |
| 421 | if (postponedLookups.at(i)->id == id) { partially evaluated: postponedLookups.at(i)->id == id| yes Evaluation Count:30 | no Evaluation Count:0 |
| 0-30 |
| 422 | delete postponedLookups.takeAt(i); | - |
| 423 | return; executed: return;Execution Count:30 | 30 |
| 424 | } | - |
| 425 | } | 0 |
| 426 | | - |
| 427 | | - |
| 428 | for (int i = 0; i < scheduledLookups.length(); i++) { partially evaluated: i < scheduledLookups.length()| no Evaluation Count:0 | yes Evaluation Count:90 |
| 0-90 |
| 429 | if (scheduledLookups.at(i)->id == id) { never evaluated: scheduledLookups.at(i)->id == id | 0 |
| 430 | delete scheduledLookups.takeAt(i); | - |
| 431 | return; | 0 |
| 432 | } | - |
| 433 | } | 0 |
| 434 | | - |
| 435 | if (!abortedLookups.contains(id)) partially evaluated: !abortedLookups.contains(id)| yes Evaluation Count:90 | no Evaluation Count:0 |
| 0-90 |
| 436 | abortedLookups.append(id); executed: abortedLookups.append(id);Execution Count:90 | 90 |
| 437 | } executed: }Execution Count:90 | 90 |
| 438 | | - |
| 439 | | - |
| 440 | bool QHostInfoLookupManager::wasAborted(int id) | - |
| 441 | { | - |
| 442 | if (wasDeleted) partially evaluated: wasDeleted| no Evaluation Count:0 | yes Evaluation Count:114 |
| 0-114 |
| 443 | return true; never executed: return true; | 0 |
| 444 | | - |
| 445 | QMutexLocker locker(&this->mutex); | - |
| 446 | return abortedLookups.contains(id); executed: return abortedLookups.contains(id);Execution Count:114 | 114 |
| 447 | } | - |
| 448 | | - |
| 449 | | - |
| 450 | void QHostInfoLookupManager::lookupFinished(QHostInfoRunnable *r) | - |
| 451 | { | - |
| 452 | if (wasDeleted) partially evaluated: wasDeleted| no Evaluation Count:0 | yes Evaluation Count:101 |
| 0-101 |
| 453 | return; | 0 |
| 454 | | - |
| 455 | QMutexLocker locker(&this->mutex); | - |
| 456 | currentLookups.removeOne(r); | - |
| 457 | finishedLookups.append(r); | - |
| 458 | work(); | - |
| 459 | } executed: }Execution Count:101 | 101 |
| 460 | | - |
| 461 | | - |
| 462 | QHostInfo qt_qhostinfo_lookup(const QString &name, QObject *receiver, const char *member, bool *valid, int *id) | - |
| 463 | { | - |
| 464 | *valid = false; | - |
| 465 | *id = -1; | - |
| 466 | | - |
| 467 | | - |
| 468 | QAbstractHostInfoLookupManager* manager = theHostInfoLookupManager(); | - |
| 469 | if (manager && manager->cache.isEnabled()) { partially evaluated: manager| yes Evaluation Count:2107 | no Evaluation Count:0 |
partially evaluated: manager->cache.isEnabled()| yes Evaluation Count:2107 | no Evaluation Count:0 |
| 0-2107 |
| 470 | QHostInfo info = manager->cache.get(name, valid); | - |
| 471 | if (*valid) { evaluated: *valid| yes Evaluation Count:1976 | yes Evaluation Count:131 |
| 131-1976 |
| 472 | return info; executed: return info;Execution Count:1976 | 1976 |
| 473 | } | - |
| 474 | } executed: }Execution Count:131 | 131 |
| 475 | | - |
| 476 | | - |
| 477 | *id = QHostInfo::lookupHost(name, receiver, member); | - |
| 478 | | - |
| 479 | | - |
| 480 | return QHostInfo(); executed: return QHostInfo();Execution Count:131 | 131 |
| 481 | } | - |
| 482 | | - |
| 483 | void qt_qhostinfo_clear_cache() | - |
| 484 | { | - |
| 485 | QAbstractHostInfoLookupManager* manager = theHostInfoLookupManager(); | - |
| 486 | if (manager) { | 0 |
| 487 | manager->clear(); | - |
| 488 | } | 0 |
| 489 | } | 0 |
| 490 | | - |
| 491 | void qt_qhostinfo_enable_cache(bool e) | - |
| 492 | { | - |
| 493 | QAbstractHostInfoLookupManager* manager = theHostInfoLookupManager(); | - |
| 494 | if (manager) { | 0 |
| 495 | manager->cache.setEnabled(e); | - |
| 496 | } | 0 |
| 497 | } | 0 |
| 498 | | - |
| 499 | | - |
| 500 | | - |
| 501 | QHostInfoCache::QHostInfoCache() : max_age(60), enabled(true), cache(64) | - |
| 502 | { | - |
| 503 | | - |
| 504 | | - |
| 505 | | - |
| 506 | } executed: }Execution Count:13 | 13 |
| 507 | | - |
| 508 | bool QHostInfoCache::isEnabled() | - |
| 509 | { | - |
| 510 | return enabled; executed: return enabled;Execution Count:2252 | 2252 |
| 511 | } | - |
| 512 | | - |
| 513 | | - |
| 514 | | - |
| 515 | void QHostInfoCache::setEnabled(bool e) | - |
| 516 | { | - |
| 517 | enabled = e; | - |
| 518 | } | 0 |
| 519 | | - |
| 520 | | - |
| 521 | QHostInfo QHostInfoCache::get(const QString &name, bool *valid) | - |
| 522 | { | - |
| 523 | QMutexLocker locker(&this->mutex); | - |
| 524 | | - |
| 525 | *valid = false; | - |
| 526 | if (cache.contains(name)) { evaluated: cache.contains(name)| yes Evaluation Count:1992 | yes Evaluation Count:260 |
| 260-1992 |
| 527 | QHostInfoCacheElement *element = cache.object(name); | - |
| 528 | if (element->age.elapsed() < max_age*1000) evaluated: element->age.elapsed() < max_age*1000| yes Evaluation Count:1977 | yes Evaluation Count:15 |
| 15-1977 |
| 529 | *valid = true; executed: *valid = true;Execution Count:1977 | 1977 |
| 530 | return element->info; executed: return element->info;Execution Count:1992 | 1992 |
| 531 | | - |
| 532 | | - |
| 533 | | - |
| 534 | | - |
| 535 | } | - |
| 536 | | - |
| 537 | return QHostInfo(); executed: return QHostInfo();Execution Count:260 | 260 |
| 538 | } | - |
| 539 | | - |
| 540 | void QHostInfoCache::put(const QString &name, const QHostInfo &info) | - |
| 541 | { | - |
| 542 | | - |
| 543 | if (info.error() != QHostInfo::NoError) evaluated: info.error() != QHostInfo::NoError| yes Evaluation Count:5 | yes Evaluation Count:31 |
| 5-31 |
| 544 | return; executed: return;Execution Count:5 | 5 |
| 545 | | - |
| 546 | QHostInfoCacheElement* element = new QHostInfoCacheElement(); | - |
| 547 | element->info = info; | - |
| 548 | element->age = QElapsedTimer(); | - |
| 549 | element->age.start(); | - |
| 550 | | - |
| 551 | QMutexLocker locker(&this->mutex); | - |
| 552 | cache.insert(name, element); | - |
| 553 | } executed: }Execution Count:31 | 31 |
| 554 | | - |
| 555 | void QHostInfoCache::clear() | - |
| 556 | { | - |
| 557 | QMutexLocker locker(&this->mutex); | - |
| 558 | cache.clear(); | - |
| 559 | } executed: }Execution Count:13 | 13 |
| 560 | | - |
| 561 | QAbstractHostInfoLookupManager* QAbstractHostInfoLookupManager::globalInstance() | - |
| 562 | { | - |
| 563 | return theHostInfoLookupManager(); never executed: return theHostInfoLookupManager(); | 0 |
| 564 | } | - |
| 565 | | - |
| 566 | | - |
| 567 | | - |
| | |