MCPcopy Create free account
hub / github.com/ElementsProject/lightning / set_urgent_flag

Function set_urgent_flag

connectd/multiplex.c:314–346  ·  view source on GitHub ↗

We're happy for the kernel to batch update and gossip messages, but a * commitment message, for example, should be instantly sent. There's no * great way of doing this, unfortunately. * * Setting TCP_NODELAY on Linux flushes the socket, which really means * we'd want to toggle on then off it *after* sending. But Linux has * TCP_CORK. On FreeBSD, it seems (looking at source) not to, so *

Source from the content-addressed store, hash-verified

312 * only means one extra packet.
313 */
314static void set_urgent_flag(struct peer *peer, bool urgent)
315{
316 int val;
317 int opt;
318 const char *optname;
319 static bool complained = false;
320
321 if (urgent == peer->urgent)
322 return;
323
324#ifdef TCP_CORK
325 opt = TCP_CORK;
326 optname = "TCP_CORK";
327#elif defined(TCP_NODELAY)
328 opt = TCP_NODELAY;
329 optname = "TCP_NODELAY";
330#else
331#error "Please report platform with neither TCP_CORK nor TCP_NODELAY?"
332#endif
333
334 val = urgent;
335 if (setsockopt(io_conn_fd(peer->to_peer),
336 IPPROTO_TCP, opt, &val, sizeof(val)) != 0) {
337 /* This actually happens in testing, where we blackhole the fd */
338 if (!complained) {
339 status_unusual("setsockopt %s=1: %s",
340 optname,
341 strerror(errno));
342 complained = true;
343 }
344 }
345 peer->urgent = urgent;
346}
347
348static bool is_urgent(enum peer_wire type)
349{

Callers 1

encrypt_and_sendFunction · 0.85

Calls 1

io_conn_fdFunction · 0.85

Tested by

no test coverage detected