summaryrefslogtreecommitdiffstats
path: root/src/librbd/io/ObjectDispatchSpec.cc
blob: 3efff9774f087cf88427aa3bb477d316c47f1ef4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#include "librbd/io/ObjectDispatchSpec.h"
#include "include/Context.h"
#include "librbd/io/ObjectDispatcherInterface.h"
#include <boost/variant.hpp>

namespace librbd {
namespace io {

void ObjectDispatchSpec::C_Dispatcher::complete(int r) {
  if (r < 0) {
    finish(r);
    return;
  }

  switch (object_dispatch_spec->dispatch_result) {
  case DISPATCH_RESULT_CONTINUE:
    object_dispatch_spec->send();
    break;
  case DISPATCH_RESULT_COMPLETE:
    finish(r);
    break;
  case DISPATCH_RESULT_INVALID:
  case DISPATCH_RESULT_RESTART:
    ceph_abort();
    break;
  }
}

void ObjectDispatchSpec::C_Dispatcher::finish(int r) {
  on_finish->complete(r);
  delete object_dispatch_spec;
}

void ObjectDispatchSpec::send() {
  object_dispatcher->send(this);
}

void ObjectDispatchSpec::fail(int r) {
  ceph_assert(r < 0);
  dispatcher_ctx.complete(r);
}

} // namespace io
} // namespace librbd