| 1857 | |
| 1858 | |
| 1859 | void SocketManager::send(Encoder* encoder, bool persist, const Socket& socket) |
| 1860 | { |
| 1861 | CHECK(encoder != nullptr); |
| 1862 | |
| 1863 | synchronized (mutex) { |
| 1864 | if (sockets.count(socket) > 0) { |
| 1865 | // Update whether or not this socket should get disposed after |
| 1866 | // there is no more data to send. |
| 1867 | if (!persist) { |
| 1868 | dispose.insert(socket); |
| 1869 | } |
| 1870 | |
| 1871 | if (outgoing.count(socket) > 0) { |
| 1872 | outgoing[socket].push(encoder); |
| 1873 | encoder = nullptr; |
| 1874 | } else { |
| 1875 | // Initialize the outgoing queue. |
| 1876 | outgoing[socket]; |
| 1877 | } |
| 1878 | } else { |
| 1879 | VLOG(1) << "Attempting to send on a no longer valid socket!"; |
| 1880 | delete encoder; |
| 1881 | encoder = nullptr; |
| 1882 | } |
| 1883 | } |
| 1884 | |
| 1885 | if (encoder != nullptr) { |
| 1886 | internal::send(encoder, socket); |
| 1887 | } |
| 1888 | } |
| 1889 | |
| 1890 | |
| 1891 | void SocketManager::send( |