server boilerplate reduction

This commit is contained in:
Michael Davidsaver
2019-12-15 10:50:13 -08:00
parent 8a70c95409
commit aa973c9adc
6 changed files with 34 additions and 58 deletions
+2 -10
View File
@@ -82,8 +82,6 @@ struct ServerGetControl : public server::Get
if(!conn || !conn->bev)
return;
const bool be = EPICS_BYTE_ORDER==EPICS_ENDIAN_BIG;
Status sts{};
uint8_t cmd = oper->state==ServerOp::Creating ? 0x08 : oper->lastRequest ? 0x50 : 0x40;
@@ -123,7 +121,7 @@ struct ServerGetControl : public server::Get
{
(void)evbuffer_drain(conn->txBody.get(), evbuffer_get_length(conn->txBody.get()));
EvOutBuf R(be, conn->txBody.get());
EvOutBuf R(hostBE, conn->txBody.get());
to_wire(R, uint32_t(oper->ioid));
to_wire(R, cmd);
to_wire(R, sts);
@@ -141,13 +139,7 @@ struct ServerGetControl : public server::Get
}
}
auto tx = bufferevent_get_output(conn->bev.get());
to_evbuf(tx, Header{CMD_GET,
pva_flags::Server,
uint32_t(evbuffer_get_length(conn->txBody.get()))},
be);
auto err = evbuffer_add_buffer(tx, conn->txBody.get());
assert(!err);
conn->enqueueTxBody(CMD_GET);
if(oper->state == ServerOp::Dead) {
conn->opByIOID.erase(oper->ioid);