This is the common pattern for the tail of each handler in this file. */
| 250 | |
| 251 | /* This is the common pattern for the tail of each handler in this file. */ |
| 252 | static struct io_plan *req_reply(struct io_conn *conn, |
| 253 | struct client *c, |
| 254 | const u8 *msg_out TAKES) |
| 255 | { |
| 256 | /*~ Write this out, then read the next one. This works perfectly for |
| 257 | * a simple request/response system like this. |
| 258 | * |
| 259 | * Internally, the ccan/io subsystem gathers all the file descriptors, |
| 260 | * figures out which want to write and read, asks the OS which ones |
| 261 | * are available, and for those file descriptors, tries to do the |
| 262 | * reads/writes we've asked it. It handles retry in the case where a |
| 263 | * read or write is done partially. |
| 264 | * |
| 265 | * Since the OS does buffering internally (on my system, over 100k |
| 266 | * worth) writes will normally succeed immediately. However, if the |
| 267 | * client is slow or malicious, and doesn't read from the socket as |
| 268 | * fast as we're writing, eventually the socket buffer will fill up; |
| 269 | * we don't care, because ccan/io will wait until there's room to |
| 270 | * write this reply before it will read again. The client just hurts |
| 271 | * themselves, and there's no Denial of Service on us. |
| 272 | * |
| 273 | * If we were to queue outgoing messages ourselves, we *would* have to |
| 274 | * consider such scenarios; this is why our daemons generally avoid |
| 275 | * buffering from untrusted parties. */ |
| 276 | return io_write_wire(conn, msg_out, client_read_next, c); |
| 277 | } |
| 278 | |
| 279 | /*~ This encrypts the content of the `struct secret hsm_secret` and |
| 280 | * stores it in hsm_secret, this is called instead of create_hsm() if |
no outgoing calls
no test coverage detected