MCPcopy Create free account
hub / github.com/apache/mesos / _send

Function _send

3rdparty/libprocess/src/process.cpp:1802–1854  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1800
1801
1802Future<Nothing> _send(Encoder* encoder, Socket socket)
1803{
1804 // Loop until all of the data in the provided encoder is sent.
1805 return process::loop(
1806 None(),
1807 [=] {
1808 size_t size;
1809 Future<size_t> send;
1810
1811 switch (encoder->kind()) {
1812 case Encoder::DATA: {
1813 const char* data =
1814 static_cast<DataEncoder*>(encoder)->next(&size);
1815 send = socket.send(data, size);
1816 break;
1817 }
1818 case Encoder::FILE: {
1819 off_t offset;
1820 int_fd fd =
1821 static_cast<FileEncoder*>(encoder)->next(&offset, &size);
1822 send = socket.sendfile(fd, offset, size);
1823 break;
1824 }
1825 }
1826
1827 return send
1828 .then([=](size_t sent) {
1829 // Update the encoder with the amount sent.
1830 encoder->backup(size - sent);
1831 return Nothing();
1832 })
1833 .recover([=](const Future<Nothing>& f) {
1834 if (f.isFailed()) {
1835 Try<Address> peer = socket.peer();
1836
1837 LOG(WARNING)
1838 << "Failed to send on socket " << socket.get() << " to peer '"
1839 << (peer.isSome() ? stringify(peer.get()) : "unknown")
1840 << "': " << f.failure();
1841 }
1842 socket_manager->close(socket);
1843 delete encoder;
1844 return f; // Break the loop by propagating the "failure".
1845 });
1846 },
1847 [=](Nothing) -> ControlFlow<Nothing> {
1848 if (encoder->remaining() == 0) {
1849 delete encoder;
1850 return Break();
1851 }
1852 return Continue();
1853 });
1854}
1855
1856} // namespace internal {
1857

Callers 2

sendMethod · 0.85
sendFunction · 0.85

Calls 15

loopFunction · 0.85
NoneClass · 0.85
NothingClass · 0.85
isFailedMethod · 0.80
failureMethod · 0.80
sendMethod · 0.65
stringifyClass · 0.50
BreakFunction · 0.50
ContinueClass · 0.50
kindMethod · 0.45
nextMethod · 0.45
sendfileMethod · 0.45

Tested by

no test coverage detected