Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3491907
D6625.id22122.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D6625.id22122.diff
View Options
diff --git a/services/tunnelbroker/src/cxx_bridge.rs b/services/tunnelbroker/src/cxx_bridge.rs
--- a/services/tunnelbroker/src/cxx_bridge.rs
+++ b/services/tunnelbroker/src/cxx_bridge.rs
@@ -84,5 +84,6 @@
deviceID: &str,
messagesIDs: &Vec<String>,
) -> Result<()>;
+ pub fn deleteDeliveryBrokerQueueIfEmpty(deviceID: &str) -> Result<()>;
}
}
diff --git a/services/tunnelbroker/src/libcpp/Tunnelbroker.h b/services/tunnelbroker/src/libcpp/Tunnelbroker.h
--- a/services/tunnelbroker/src/libcpp/Tunnelbroker.h
+++ b/services/tunnelbroker/src/libcpp/Tunnelbroker.h
@@ -27,3 +27,4 @@
void removeMessages(
rust::Str deviceID,
const rust::Vec<rust::String> &messagesIDs);
+void deleteDeliveryBrokerQueueIfEmpty(rust::Str deviceID);
diff --git a/services/tunnelbroker/src/libcpp/Tunnelbroker.cpp b/services/tunnelbroker/src/libcpp/Tunnelbroker.cpp
--- a/services/tunnelbroker/src/libcpp/Tunnelbroker.cpp
+++ b/services/tunnelbroker/src/libcpp/Tunnelbroker.cpp
@@ -226,20 +226,22 @@
rust::Str deviceID,
const rust::Vec<rust::String> &messagesIDs) {
std::vector<std::string> vectorOfmessagesIDs;
- std::string stringDeviceID = std::string{deviceID};
for (auto id : messagesIDs) {
vectorOfmessagesIDs.push_back(std::string{id});
};
comm::network::database::DatabaseManager::getInstance()
- .removeMessageItemsByIDsForDeviceID(vectorOfmessagesIDs, stringDeviceID);
+ .removeMessageItemsByIDsForDeviceID(
+ vectorOfmessagesIDs, std::string{deviceID});
+}
+void deleteDeliveryBrokerQueueIfEmpty(rust::Str deviceID) {
// If messages queue for `deviceID` is empty we don't need to store
// `folly::MPMCQueue` for it and need to free memory to fix possible
// 'ghost' queues in DeliveryBroker.
// We call `deleteQueueIfEmpty()` for this purpose here after removing
// messages.
comm::network::DeliveryBroker::DeliveryBroker::getInstance()
- .deleteQueueIfEmpty(stringDeviceID);
+ .deleteQueueIfEmpty(std::string{deviceID});
}
rust::Vec<rust::String> sendMessages(const rust::Vec<MessageItem> &messages) {
diff --git a/services/tunnelbroker/src/server/mod.rs b/services/tunnelbroker/src/server/mod.rs
--- a/services/tunnelbroker/src/server/mod.rs
+++ b/services/tunnelbroker/src/server/mod.rs
@@ -2,11 +2,11 @@
use super::constants;
use super::cxx_bridge::ffi::{
- ackMessageFromAMQP, eraseMessagesFromAMQP, getMessagesFromDatabase,
- getSavedNonceToSign, getSessionItem, isConfigParameterSet, newSessionHandler,
- removeMessages, sendMessages, sessionSignatureHandler,
- updateSessionItemDeviceToken, updateSessionItemIsOnline,
- waitMessageFromDeliveryBroker, GRPCStatusCodes,
+ ackMessageFromAMQP, deleteDeliveryBrokerQueueIfEmpty, eraseMessagesFromAMQP,
+ getMessagesFromDatabase, getSavedNonceToSign, getSessionItem,
+ isConfigParameterSet, newSessionHandler, removeMessages, sendMessages,
+ sessionSignatureHandler, updateSessionItemDeviceToken,
+ updateSessionItemIsOnline, waitMessageFromDeliveryBroker, GRPCStatusCodes,
};
use anyhow::Result;
use futures::Stream;
@@ -387,6 +387,14 @@
err.what()
);
};
+ if let Err(err) =
+ deleteDeliveryBrokerQueueIfEmpty(&session_item.deviceID)
+ {
+ error!(
+ "Error deleting delivery broker queue when empty: {}",
+ err.what()
+ );
+ }
}
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 9:12 PM (20 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2678876
Default Alt Text
D6625.id22122.diff (3 KB)
Attached To
Mode
D6625: [services] Tunnelbroker - Extracting `deleteQueueIfEmpty` logic to a separate function
Attached
Detach File
Event Timeline
Log In to Comment