MCPcopy Create free account
hub / github.com/alibaba/PhotonLibOS / recv

Method recv

common/memory-stream/memory-stream.cpp:206–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204 bool _closed = false;
205 #define ERROR_RETURN(code, retv) {errno = code; return retv; }
206 virtual ssize_t recv(void *buf, size_t count, int flags = 0) override {
207 if (_closed) ERROR_RETURN(ECANCELED, -1);
208 size_t n = rand() % 8 + 1;
209 if (n > _inv.size()) n = _inv.size();
210 if (n > count) n = count;
211 memcpy(buf, _inv.data(), n);
212 _inv = _inv.substr(n);
213 return n;
214 }
215 virtual ssize_t recv(const struct iovec *iov, int iovcnt, int flags = 0) override {
216 if (_closed) ERROR_RETURN(ECANCELED, -1);
217 while(!iov->iov_base || !iov->iov_len)

Callers 2

run_real_socketFunction · 0.45
main_loopMethod · 0.45

Calls 4

recvFunction · 0.85
sizeMethod · 0.45
dataMethod · 0.45
substrMethod · 0.45

Tested by 1

run_real_socketFunction · 0.36