Skip to content

Commit

Permalink
Revert "Revert "handle start_http failure in rpc_service (solana-labs…
Browse files Browse the repository at this point in the history
…#25400)""

This reverts commit 7d54b1a45c8d91633fb1f4f365df8dab4fcd27c3.
  • Loading branch information
behzadnouri committed Jun 21, 2022
1 parent 7aca028 commit 90c9c70
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 27 deletions.
49 changes: 28 additions & 21 deletions core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,28 +780,35 @@ impl Validator {
} else {
None
};

let json_rpc_service = JsonRpcService::new(
rpc_addr,
config.rpc_config.clone(),
config.snapshot_config.clone(),
bank_forks.clone(),
block_commitment_cache.clone(),
blockstore.clone(),
cluster_info.clone(),
Some(poh_recorder.clone()),
genesis_config.hash(),
ledger_path,
config.validator_exit.clone(),
config.known_validators.clone(),
rpc_override_health_check.clone(),
optimistically_confirmed_bank.clone(),
config.send_transaction_service_config.clone(),
max_slots.clone(),
leader_schedule_cache.clone(),
connection_cache.clone(),
max_complete_transaction_status_slot,
)
.unwrap_or_else(|s| {
error!("Failed to create JSON RPC Service: {}", s);
abort();
});

(
Some(JsonRpcService::new(
rpc_addr,
config.rpc_config.clone(),
config.snapshot_config.clone(),
bank_forks.clone(),
block_commitment_cache.clone(),
blockstore.clone(),
cluster_info.clone(),
Some(poh_recorder.clone()),
genesis_config.hash(),
ledger_path,
config.validator_exit.clone(),
config.known_validators.clone(),
rpc_override_health_check.clone(),
optimistically_confirmed_bank.clone(),
config.send_transaction_service_config.clone(),
max_slots.clone(),
leader_schedule_cache.clone(),
connection_cache.clone(),
max_complete_transaction_status_slot,
)),
Some(json_rpc_service),
if !config.rpc_config.full_api {
None
} else {
Expand Down
14 changes: 8 additions & 6 deletions rpc/src/rpc_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ impl JsonRpcService {
leader_schedule_cache: Arc<LeaderScheduleCache>,
connection_cache: Arc<ConnectionCache>,
current_transaction_status_slot: Arc<AtomicU64>,
) -> Self {
) -> Result<Self, String> {
info!("rpc bound to {:?}", rpc_addr);
info!("rpc configuration: {:?}", config);
let rpc_threads = 1.max(config.rpc_threads);
Expand Down Expand Up @@ -523,28 +523,29 @@ impl JsonRpcService {
e,
rpc_addr.port()
);
close_handle_sender.send(Err(e.to_string())).unwrap();
return;
}

let server = server.unwrap();
close_handle_sender.send(server.close_handle()).unwrap();
close_handle_sender.send(Ok(server.close_handle())).unwrap();
server.wait();
exit_bigtable_ledger_upload_service.store(true, Ordering::Relaxed);
})
.unwrap();

let close_handle = close_handle_receiver.recv().unwrap();
let close_handle = close_handle_receiver.recv().unwrap()?;
let close_handle_ = close_handle.clone();
validator_exit
.write()
.unwrap()
.register_exit(Box::new(move || close_handle_.close()));
Self {
Ok(Self {
thread_hdl,
#[cfg(test)]
request_processor: test_request_processor,
close_handle: Some(close_handle),
}
})
}

pub fn exit(&mut self) {
Expand Down Expand Up @@ -638,7 +639,8 @@ mod tests {
Arc::new(LeaderScheduleCache::default()),
connection_cache,
Arc::new(AtomicU64::default()),
);
)
.unwrap();
let thread = rpc_service.thread_hdl.thread();
assert_eq!(thread.name().unwrap(), "solana-jsonrpc");

Expand Down

0 comments on commit 90c9c70

Please sign in to comment.