|
@@ -106,24 +106,22 @@ CalloutManager::calloutsPresent(int hook_index) const {
|
|
|
|
|
|
bool
|
|
|
CalloutManager::commandHandlersPresent(const std::string& command_name) const {
|
|
|
- try {
|
|
|
- // Check if the hook point for the specified command exists.
|
|
|
- // We don't want this to throw because this is not an error condition.
|
|
|
- // We may simply not support this command in any of the attached
|
|
|
- // hooks libraries. That's fine.
|
|
|
- int index = ServerHooks::getServerHooks().getIndex(
|
|
|
- ServerHooks::commandToHookName(command_name));
|
|
|
- // The hook point may exist but there are no callouts/command handlers.
|
|
|
- // This is possible if there was a hook library supporting this command
|
|
|
- // attached, but it was later unloaded. The hook points are not deregistered
|
|
|
- // in this case. Only callouts are deregistered.
|
|
|
+ // Check if the hook point for the specified command exists.
|
|
|
+ int index = ServerHooks::getServerHooks().findIndex(
|
|
|
+ ServerHooks::commandToHookName(command_name));
|
|
|
+ if (index >= 0) {
|
|
|
+ // The hook point exits but it is possible that there are no
|
|
|
+ // callouts/command handlers. This is possible if there was a
|
|
|
+ // hook library supporting this command attached, but it was
|
|
|
+ // later unloaded. The hook points are not deregistered in
|
|
|
+ // this case. Only callouts are deregistered.
|
|
|
+ // Let's check if callouts are present for this hook point.
|
|
|
return (calloutsPresent(index));
|
|
|
-
|
|
|
- } catch (...) {
|
|
|
- // Hook point not created, so we don't support this command in
|
|
|
- // any of the hooks libraries.
|
|
|
- return (false);
|
|
|
}
|
|
|
+
|
|
|
+ // Hook point not created, so we don't support this command in
|
|
|
+ // any of the hooks libraries.
|
|
|
+ return (false);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -218,7 +216,7 @@ void
|
|
|
CalloutManager::callCommandHandlers(const std::string& command_name,
|
|
|
CalloutHandle& callout_handle) {
|
|
|
// Get the index of the hook point for the specified command.
|
|
|
- // This may throw an exception if the hook point doesn't exist.
|
|
|
+ // This will throw an exception if the hook point doesn't exist.
|
|
|
// The caller should check if the hook point exists by calling
|
|
|
// commandHandlersPresent.
|
|
|
int index = ServerHooks::getServerHooks().getIndex(
|
|
@@ -312,15 +310,7 @@ CalloutManager::deregisterAllCallouts(const std::string& name) {
|
|
|
void
|
|
|
CalloutManager::registerCommandHook(const std::string& command_name) {
|
|
|
ServerHooks& hooks = ServerHooks::getServerHooks();
|
|
|
- int hook_index = -1;
|
|
|
- try {
|
|
|
- hook_index = hooks.getIndex(ServerHooks::commandToHookName(command_name));
|
|
|
-
|
|
|
- } catch (...) {
|
|
|
- // Ignore an error whereby the hook doesn't exist for this command.
|
|
|
- // In this case we're going to register a new hook.
|
|
|
- }
|
|
|
-
|
|
|
+ int hook_index = hooks.findIndex(ServerHooks::commandToHookName(command_name));
|
|
|
if (hook_index < 0) {
|
|
|
// Hook for this command doesn't exist. Let's create one.
|
|
|
hooks.registerHook(ServerHooks::commandToHookName(command_name));
|