summaryrefslogtreecommitdiff
path: root/src/mongo/executor/network_interface.h
diff options
context:
space:
mode:
authorWaley Chen <waleycz@gmail.com>2016-03-30 17:36:37 -0400
committerWaley Chen <waleycz@gmail.com>2016-03-30 21:13:50 -0400
commitdfabadb09387a4236ee7675cd02d39b17affaf39 (patch)
treefca4ba78cd6bb9b96810f712b2b1abf64c55cfe2 /src/mongo/executor/network_interface.h
parente45aba42f783cf2e2974b7ea6944a6c81b0a6be4 (diff)
downloadmongo-dfabadb09387a4236ee7675cd02d39b17affaf39.tar.gz
SERVER-21170 NetworkInterface::startCommand should be able to reject requests due to shutdown
Diffstat (limited to 'src/mongo/executor/network_interface.h')
-rw-r--r--src/mongo/executor/network_interface.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/mongo/executor/network_interface.h b/src/mongo/executor/network_interface.h
index e35f8ed9c52..d230e2eb8a6 100644
--- a/src/mongo/executor/network_interface.h
+++ b/src/mongo/executor/network_interface.h
@@ -86,6 +86,11 @@ public:
virtual void shutdown() = 0;
/**
+ * Returns true if shutdown has been called, false otherwise.
+ */
+ virtual bool inShutdown() const = 0;
+
+ /**
* Blocks the current thread (presumably the executor thread) until the network interface
* knows of work for the executor to perform.
*/
@@ -114,10 +119,14 @@ public:
/**
* Starts asynchronous execution of the command described by "request".
+ *
+ * Returns ErrorCodes::ShutdownInProgress if NetworkInterface::shutdown has already started
+ * and Status::OK() otherwise. If it returns Status::OK(), then the onFinish argument will be
+ * executed by NetworkInterface eventually; otherwise, it will not.
*/
- virtual void startCommand(const TaskExecutor::CallbackHandle& cbHandle,
- const RemoteCommandRequest& request,
- const RemoteCommandCompletionFn& onFinish) = 0;
+ virtual Status startCommand(const TaskExecutor::CallbackHandle& cbHandle,
+ const RemoteCommandRequest& request,
+ const RemoteCommandCompletionFn& onFinish) = 0;
/**
* Requests cancelation of the network activity associated with "cbHandle" if it has not yet
@@ -133,13 +142,17 @@ public:
/**
* Sets an alarm, which schedules "action" to run no sooner than "when".
*
+ * Returns ErrorCodes::ShutdownInProgress if NetworkInterface::shutdown has already started
+ * and true otherwise. If it returns Status::OK(), then the action will be executed by
+ * NetworkInterface eventually; otherwise, it will not.
+ *
* "action" should not do anything that requires a lot of computation, or that might block for a
* long time, as it may execute in a network thread.
*
* Any callbacks invoked from setAlarm must observe onNetworkThread to
* return true. See that method for why.
*/
- virtual void setAlarm(Date_t when, const stdx::function<void()>& action) = 0;
+ virtual Status setAlarm(Date_t when, const stdx::function<void()>& action) = 0;
/**
* Returns true if called from a thread dedicated to networking. I.e. not a