mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-02 16:26:48 +00:00
work on write queue/flow control
This commit is contained in:
@@ -495,6 +495,9 @@ public:
|
||||
|
||||
// new prepare frame stuff
|
||||
void prepare_frame(message::data_ptr msg, bool masked, int32_t mask) {
|
||||
if (msg->get_prepared()) {
|
||||
return;
|
||||
}
|
||||
m_write_header.reset();
|
||||
m_write_header.set_fin(true);
|
||||
m_write_header.set_opcode(msg->get_opcode());
|
||||
@@ -503,6 +506,11 @@ public:
|
||||
m_write_header.complete();
|
||||
|
||||
msg->set_header(m_write_header.get_header_bytes());
|
||||
if (masked) {
|
||||
msg->mask();
|
||||
}
|
||||
|
||||
msg->set_prepared(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -112,16 +112,16 @@ void hybi_header::set_masked(bool masked,int32_t key) {
|
||||
}
|
||||
void hybi_header::set_payload_size(uint64_t size) {
|
||||
if (size <= frame::limits::PAYLOAD_SIZE_BASIC) {
|
||||
m_header[1] &= (size & BPB1_PAYLOAD);
|
||||
m_header[1] |= size;
|
||||
m_payload_size = size;
|
||||
} else if (size <= frame::limits::PAYLOAD_SIZE_EXTENDED) {
|
||||
if (get_masked()) {
|
||||
// shift mask bytes to the correct position given the new size
|
||||
unsigned int mask_offset = get_header_len()-4;
|
||||
m_header[1] &= (BASIC_PAYLOAD_16BIT_CODE & BPB1_PAYLOAD);
|
||||
m_header[1] |= BASIC_PAYLOAD_16BIT_CODE;
|
||||
memcpy(&m_header[get_header_len()-4], &m_header[mask_offset], 4);
|
||||
} else {
|
||||
m_header[1] &= (BASIC_PAYLOAD_16BIT_CODE & BPB1_PAYLOAD);
|
||||
m_header[1] |= BASIC_PAYLOAD_16BIT_CODE;
|
||||
}
|
||||
m_payload_size = size;
|
||||
*(reinterpret_cast<uint16_t*>(&m_header[BASIC_HEADER_LENGTH])) = htons(size);
|
||||
@@ -129,16 +129,17 @@ void hybi_header::set_payload_size(uint64_t size) {
|
||||
if (get_masked()) {
|
||||
// shift mask bytes to the correct position given the new size
|
||||
unsigned int mask_offset = get_header_len()-4;
|
||||
m_header[1] &= (BASIC_PAYLOAD_64BIT_CODE & BPB1_PAYLOAD);
|
||||
m_header[1] |= BASIC_PAYLOAD_64BIT_CODE;
|
||||
memcpy(&m_header[get_header_len()-4], &m_header[mask_offset], 4);
|
||||
} else {
|
||||
m_header[1] &= (BASIC_PAYLOAD_64BIT_CODE & BPB1_PAYLOAD);
|
||||
m_header[1] |= BASIC_PAYLOAD_64BIT_CODE;
|
||||
}
|
||||
m_payload_size = size;
|
||||
*(reinterpret_cast<uint64_t*>(&m_header[BASIC_HEADER_LENGTH])) = htonll(size);
|
||||
} else {
|
||||
throw processor::exception("set_payload_size called with value that was too large (>2^63)",processor::error::MESSAGE_TOO_BIG);
|
||||
}
|
||||
|
||||
}
|
||||
void hybi_header::complete() {
|
||||
validate_basic_header();
|
||||
|
||||
@@ -256,6 +256,16 @@ public:
|
||||
return response;
|
||||
}
|
||||
|
||||
void prepare_frame(message::data_ptr msg, bool masked, int32_t mask) {
|
||||
if (msg->get_prepared()) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg->set_header(std::string(0x00));
|
||||
// TODO: append 0xFF
|
||||
msg->set_prepared(true);
|
||||
}
|
||||
|
||||
private:
|
||||
uint32_t decode_client_key(const std::string& key) {
|
||||
int spaces = 0;
|
||||
|
||||
@@ -132,7 +132,7 @@ public:
|
||||
bool mask,
|
||||
const std::string& reason) = 0;
|
||||
|
||||
|
||||
virtual void prepare_frame(message::data_ptr msg, bool masked, int32_t mask) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user