mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 955888. Part 4: In chaos mode, put new sockets at a random position in the poll list. r=jduell
This means sockets are processed in a semi-random (but consistent) order during a poll. --HG-- extra : rebase_source : 46d1e0bcdde73fc2e0886294f90df4b8eb93af62
This commit is contained in:
parent
dfca86f550
commit
03b64d9405
@ -21,6 +21,8 @@
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/PublicSSL.h"
|
||||
#include "mozilla/ChaosMode.h"
|
||||
#include "mozilla/PodOperations.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIFile.h"
|
||||
|
||||
@ -227,12 +229,20 @@ nsSocketTransportService::AddToPollList(SocketContext *sock)
|
||||
}
|
||||
}
|
||||
|
||||
mActiveList[mActiveCount] = *sock;
|
||||
uint32_t newSocketIndex = mActiveCount;
|
||||
if (ChaosMode::isActive()) {
|
||||
newSocketIndex = ChaosMode::randomUint32LessThan(mActiveCount + 1);
|
||||
PodMove(mActiveList + newSocketIndex + 1, mActiveList + newSocketIndex,
|
||||
mActiveCount - newSocketIndex);
|
||||
PodMove(mPollList + newSocketIndex + 2, mPollList + newSocketIndex + 1,
|
||||
mActiveCount - newSocketIndex);
|
||||
}
|
||||
mActiveList[newSocketIndex] = *sock;
|
||||
mActiveCount++;
|
||||
|
||||
mPollList[mActiveCount].fd = sock->mFD;
|
||||
mPollList[mActiveCount].in_flags = sock->mHandler->mPollFlags;
|
||||
mPollList[mActiveCount].out_flags = 0;
|
||||
mPollList[newSocketIndex + 1].fd = sock->mFD;
|
||||
mPollList[newSocketIndex + 1].in_flags = sock->mHandler->mPollFlags;
|
||||
mPollList[newSocketIndex + 1].out_flags = 0;
|
||||
|
||||
SOCKET_LOG((" active=%u idle=%u\n", mActiveCount, mIdleCount));
|
||||
return NS_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user