@@ -292,14 +292,18 @@ bool EmergeManager::enqueueBlockEmergeEx(
292
292
void *callback_param)
293
293
{
294
294
EmergeThread *thread = NULL ;
295
+ bool entry_already_exists = false ;
295
296
296
297
{
297
298
MutexAutoLock queuelock (m_queue_mutex);
298
299
299
300
if (!pushBlockEmergeData (blockpos, peer_id, flags,
300
- callback, callback_param))
301
+ callback, callback_param, &entry_already_exists ))
301
302
return false ;
302
303
304
+ if (entry_already_exists)
305
+ return true ;
306
+
303
307
thread = getOptimalThread ();
304
308
thread->pushBlock (blockpos);
305
309
}
@@ -382,7 +386,8 @@ bool EmergeManager::pushBlockEmergeData(
382
386
u16 peer_requested,
383
387
u16 flags,
384
388
EmergeCompletionCallback callback,
385
- void *callback_param)
389
+ void *callback_param,
390
+ bool *entry_already_exists)
386
391
{
387
392
u16 &count_peer = m_peer_queue_count[peer_requested];
388
393
@@ -402,12 +407,12 @@ bool EmergeManager::pushBlockEmergeData(
402
407
findres = m_blocks_enqueued.insert (std::make_pair (pos, BlockEmergeData ()));
403
408
404
409
BlockEmergeData &bedata = findres.first ->second ;
405
- bool update_existing = !findres.second ;
410
+ *entry_already_exists = !findres.second ;
406
411
407
412
if (callback)
408
413
bedata.callbacks .push_back (std::make_pair (callback, callback_param));
409
414
410
- if (update_existing ) {
415
+ if (*entry_already_exists ) {
411
416
bedata.flags |= flags;
412
417
} else {
413
418
bedata.flags = flags;
0 commit comments