Skip to content

Commit

Permalink
Merge pull request #3944 from dachary/wip-9193-firefly
Browse files Browse the repository at this point in the history
messages/MWatchNotify: include an error code in the message

Reviewed-by: Samuel Just <sjust@redhat.com>
  • Loading branch information
ldachary committed Mar 16, 2015
2 parents c0abc4d + 0f31388 commit 3050262
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions src/messages/MWatchNotify.h
Expand Up @@ -20,16 +20,27 @@


class MWatchNotify : public Message {
static const int HEAD_VERSION = 2;
static const int COMPAT_VERSION = 1;

public:
uint64_t cookie;
uint64_t ver;
uint64_t notify_id;
uint8_t opcode;
bufferlist bl;
uint64_t cookie; ///< client unique id for this watch or notify
uint64_t ver; ///< unused
uint64_t notify_id; ///< osd unique id for a notify notification
uint8_t opcode; ///< always WATCH_NOTIFY
bufferlist bl; ///< notify payload (osd->client)
int32_t return_code; ///< notify result (osd->client)

MWatchNotify() : Message(CEPH_MSG_WATCH_NOTIFY) { }
MWatchNotify(uint64_t c, uint64_t v, uint64_t i, uint8_t o, bufferlist b) : Message(CEPH_MSG_WATCH_NOTIFY),
cookie(c), ver(v), notify_id(i), opcode(o), bl(b) { }
MWatchNotify()
: Message(CEPH_MSG_WATCH_NOTIFY, HEAD_VERSION, COMPAT_VERSION) { }
MWatchNotify(uint64_t c, uint64_t v, uint64_t i, uint8_t o, bufferlist b)
: Message(CEPH_MSG_WATCH_NOTIFY, HEAD_VERSION, COMPAT_VERSION),
cookie(c),
ver(v),
notify_id(i),
opcode(o),
bl(b),
return_code(0) { }
private:
~MWatchNotify() {}

Expand All @@ -44,6 +55,10 @@ class MWatchNotify : public Message {
::decode(notify_id, p);
if (msg_ver >= 1)
::decode(bl, p);
if (header.version >= 2)
::decode(return_code, p);
else
return_code = 0;
}
void encode_payload(uint64_t features) {
uint8_t msg_ver = 1;
Expand All @@ -53,11 +68,12 @@ class MWatchNotify : public Message {
::encode(ver, payload);
::encode(notify_id, payload);
::encode(bl, payload);
::encode(return_code, payload);
}

const char *get_type_name() const { return "watch-notify"; }
void print(ostream& out) const {
out << "watch-notify(c=" << cookie << " v=" << ver << " i=" << notify_id << " opcode=" << (int)opcode << ")";
out << "watch-notify(c=" << cookie << " v=" << ver << " i=" << notify_id << " opcode=" << (int)opcode << " r = " << return_code << ")";
}
};

Expand Down

0 comments on commit 3050262

Please sign in to comment.