MCPcopy Create free account
hub / github.com/XTXMarkets/ternfs / write

Method write

cpp/core/XmonAgent.cpp:20–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18};
19
20void XmonRequest::write(int fd) const {
21 ALWAYS_ASSERT(message.size() < 1<<16);
22 XmonRequestHeader header = {
23 .alertId = alertId,
24 .quietPeriod = quietPeriod,
25 .msgType = msgType,
26 .appType = appType,
27 .binnable = binnable,
28 .messageLen = (uint16_t)message.size(),
29 };
30 static thread_local char buf[PIPE_BUF];
31 ALWAYS_ASSERT(sizeof(header) + header.messageLen < PIPE_BUF);
32 memcpy(buf, &header, sizeof(header));
33 memcpy(buf+sizeof(header), message.data(), header.messageLen);
34 {
35 // pipe writes of < PIPE_BUF are guaranteed to be atomic, see pipe(7)
36 int written = ::write(fd, buf, sizeof(header)+header.messageLen);
37 if (written != sizeof(header)+header.messageLen) {
38 throw SYSCALL_EXCEPTION("write");
39 }
40 }
41}
42
43bool XmonRequest::read(int fd) {
44 static thread_local char buf[PIPE_BUF];

Callers 3

_createAlertMethod · 0.45
updateAlertMethod · 0.45
clearAlertMethod · 0.45

Calls 2

sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected