Fix session drop

This commit is contained in:
Tyera Eulberg 2018-10-15 13:58:46 -06:00 committed by Tyera Eulberg
parent 537436bd5e
commit 7424388924
3 changed files with 9 additions and 33 deletions

View File

@ -80,11 +80,11 @@ env_logger = "0.5.12"
generic-array = { version = "0.12.0", default-features = false, features = ["serde"] }
getopts = "0.2"
influx_db_client = "0.3.4"
solana-jsonrpc-core = "0.2.0"
solana-jsonrpc-http-server = "0.2.0"
solana-jsonrpc-macros = "0.2.0"
solana-jsonrpc-pubsub = "0.2.0"
solana-jsonrpc-ws-server = "0.2.0"
solana-jsonrpc-core = "0.3.0"
solana-jsonrpc-http-server = "0.3.0"
solana-jsonrpc-macros = "0.3.0"
solana-jsonrpc-pubsub = "0.3.0"
solana-jsonrpc-ws-server = "0.3.0"
ipnetwork = "0.12.7"
itertools = "0.7.8"
libc = "0.2.43"

View File

@ -536,20 +536,6 @@ mod tests {
assert_eq!(expected, result);
}
#[test]
fn test_rpc_start_sub_channel() {
let bob_pubkey = Keypair::new().pubkey();
let (io, meta, _last_id, _alice_keypair) = start_rpc_handler_with_tx(bob_pubkey);
let req = format!(r#"{{"jsonrpc":"2.0","id":1,"method":"startSubscriptionChannel"}}"#);
let res = io.handle_request_sync(&req, meta);
let json: Value = serde_json::from_str(&res.expect("actual response"))
.expect("actual response deserialization");
let port = json["result"]["port"].as_u64().unwrap();
assert!(8000 <= port && port < 10000);
assert!(json["result"]["path"].is_string());
}
#[test]
fn test_rpc_send_tx() {
let leader_keypair = Keypair::new();

View File

@ -51,16 +51,6 @@ impl PubSubService {
let session = Arc::new(Session::new(context.sender().clone()));
session.on_drop(Box::new(|| {
info!("Pubsub connection dropped");
// Following should not be required as jsonrpc_pubsub will
// unsubscribe automatically once the websocket is dropped ...
/*
for (_, (bank_sub_id, pubkey)) in self.account_subscriptions.read().unwrap().iter() {
server_bank.remove_account_subscription(bank_sub_id, pubkey);
}
for (_, (bank_sub_id, signature)) in self.signature_subscriptions.read().unwrap().iter() {
server_bank.remove_signature_subscription(bank_sub_id, signature);
}
*/
}));
session
})
@ -93,7 +83,7 @@ build_rpc_trait! {
// Unsubscribe from account notification subscription.
#[rpc(name = "accountUnsubscribe")]
fn account_unsubscribe(&self, Self::Metadata, SubscriptionId) -> Result<bool>;
fn account_unsubscribe(&self, SubscriptionId) -> Result<bool>;
}
#[pubsub(name = "signatureNotification")] {
// Get notification when signature is verified
@ -103,7 +93,7 @@ build_rpc_trait! {
// Unsubscribe from signature notification subscription.
#[rpc(name = "signatureUnsubscribe")]
fn signature_unsubscribe(&self, Self::Metadata, SubscriptionId) -> Result<bool>;
fn signature_unsubscribe(&self, SubscriptionId) -> Result<bool>;
}
}
}
@ -163,7 +153,7 @@ impl RpcSolPubSub for RpcSolPubSubImpl {
.add_account_subscription(bank_sub_id, pubkey, sink);
}
fn account_unsubscribe(&self, _meta: Self::Metadata, id: SubscriptionId) -> Result<bool> {
fn account_unsubscribe(&self, id: SubscriptionId) -> Result<bool> {
info!("account_unsubscribe");
if let Some((bank_sub_id, pubkey)) = self.account_subscriptions.write().unwrap().remove(&id)
{
@ -223,7 +213,7 @@ impl RpcSolPubSub for RpcSolPubSubImpl {
}
}
fn signature_unsubscribe(&self, _meta: Self::Metadata, id: SubscriptionId) -> Result<bool> {
fn signature_unsubscribe(&self, id: SubscriptionId) -> Result<bool> {
info!("signature_unsubscribe");
if let Some((bank_sub_id, signature)) =
self.signature_subscriptions.write().unwrap().remove(&id)