Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential timing issue on bid responses #109

Merged
merged 1 commit into from
Dec 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/adaptermanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ exports.callBids = function(bidderArr) {
//emit 'bidRequested' event
events.emit(CONSTANTS.EVENTS.BID_REQUESTED, bidder);
currentBidder.callBids(bidder);

// if the bidder didn't explicitly set the number of bids
// expected, default to the number of bids passed into the bidder
if (bidmanager.getExpectedBidsCount(bidder.bidderCode) === undefined) {
bidmanager.setExpectedBidsCount(bidder.bidderCode, bidder.bids.length);
}

var currentTime = new Date().getTime();
bidmanager.registerBidRequestTime(bidder.bidderCode, currentTime);

Expand Down
15 changes: 6 additions & 9 deletions src/bidmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ exports.setExpectedBidsCount = function(bidderCode,count){
function getExpectedBidsCount(bidderCode){
return expectedBidsCount[bidderCode];
}
exports.getExpectedBidsCount = getExpectedBidsCount;


/*
Expand Down Expand Up @@ -395,17 +396,13 @@ exports.checkIfAllBidsAreIn = function(adUnitCode) {
// check all bids response received by bidder
function checkAllBidsResponseReceived(){
var available = true;

utils._each(bidResponseReceivedCount,function(count,bidderCode){

//expected bids count check for appnexus
if(bidderCode === 'appnexus'){
var expectedCount = getExpectedBidsCount(bidderCode);
utils._each(bidResponseReceivedCount, function(count, bidderCode){
var expectedCount = getExpectedBidsCount(bidderCode);

if(typeof expectedCount === objectType_undefined || count < expectedCount){
available = false;
}
}else if(count<1){
// expectedCount should be set in the adapter, or it will be set
// after we call adapter.callBids()
if ((typeof expectedCount === objectType_undefined) || (count < expectedCount)) {
available = false;
}
});
Expand Down