summaryrefslogtreecommitdiffstats
path: root/src/test/messenger/simple_dispatcher.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/test/messenger/simple_dispatcher.cc
parentInitial commit. (diff)
downloadceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz
ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/messenger/simple_dispatcher.cc')
-rw-r--r--src/test/messenger/simple_dispatcher.cc85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/test/messenger/simple_dispatcher.cc b/src/test/messenger/simple_dispatcher.cc
new file mode 100644
index 00000000..b13958d3
--- /dev/null
+++ b/src/test/messenger/simple_dispatcher.cc
@@ -0,0 +1,85 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2013 CohortFS, LLC
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation. See file COPYING.
+ *
+ */
+
+#include "include/compat.h"
+
+#include "simple_dispatcher.h"
+#include "messages/MPing.h"
+#include "messages/MDataPing.h"
+
+SimpleDispatcher::SimpleDispatcher(Messenger *msgr) :
+ Dispatcher(msgr->cct),
+ active(false),
+ messenger(msgr),
+ dcount(0)
+{
+ // nothing
+}
+
+SimpleDispatcher::~SimpleDispatcher() {
+ // nothing
+}
+
+bool SimpleDispatcher::ms_dispatch(Message *m)
+{
+ uint64_t dc = 0;
+
+ dc = dcount++;
+
+ ConnectionRef con = m->get_connection();
+ Messenger* msgr = con->get_messenger();
+
+ switch (m->get_type()) {
+ case CEPH_MSG_PING:
+ break;
+ case MSG_DATA_PING:
+ {
+ MDataPing* mdp __attribute__((unused)) = static_cast<MDataPing*>(m);
+ //cout << "MDataPing " << mdp->tag << " " << mdp->counter << std::endl;
+ //mdp->get_data().hexdump(cout);
+ ConnectionRef con = m->get_connection();
+ con->send_message(m);
+ }
+ break;
+ default:
+ ceph_abort();
+ }
+
+ if (unlikely(msgr->get_magic() & MSG_MAGIC_TRACE_CTR)) {
+ if (unlikely(dc % 65536) == 0) {
+ struct timespec ts;
+ clock_gettime(CLOCK_REALTIME_COARSE, &ts);
+ std::cout << "ping " << dc << " nanos: " <<
+ ts.tv_nsec + (ts.tv_sec * 1000000000) << std::endl;
+ }
+ } /* trace ctr */
+
+
+ con->send_message(m);
+
+ //m->put();
+
+ return true;
+}
+
+bool SimpleDispatcher::ms_handle_reset(Connection *con)
+{
+ return true;
+}
+
+void SimpleDispatcher::ms_handle_remote_reset(Connection *con)
+{
+ // nothing
+}
+