| 1232 | } |
| 1233 | |
| 1234 | void peer_connect_subd(struct daemon *daemon, const u8 *msg, int fd) |
| 1235 | { |
| 1236 | struct node_id id; |
| 1237 | u64 counter; |
| 1238 | struct peer *peer; |
| 1239 | struct channel_id channel_id; |
| 1240 | struct subd *subd; |
| 1241 | |
| 1242 | if (!fromwire_connectd_peer_connect_subd(msg, &id, &counter, &channel_id)) |
| 1243 | master_badmsg(WIRE_CONNECTD_PEER_CONNECT_SUBD, msg); |
| 1244 | |
| 1245 | /* Races can happen: this might be gone by now (or reconnected!). */ |
| 1246 | peer = peer_htable_get(&daemon->peers, &id); |
| 1247 | if (!peer || peer->counter != counter) { |
| 1248 | close(fd); |
| 1249 | return; |
| 1250 | } |
| 1251 | |
| 1252 | /* Could be disconnecting now */ |
| 1253 | if (!peer->to_peer) { |
| 1254 | close(fd); |
| 1255 | return; |
| 1256 | } |
| 1257 | |
| 1258 | /* If peer said something, we created this and queued msg. */ |
| 1259 | subd = find_subd(peer, &channel_id); |
| 1260 | if (!subd) |
| 1261 | subd = new_subd(peer, &channel_id); |
| 1262 | |
| 1263 | assert(!subd->conn); |
| 1264 | |
| 1265 | /* This sets subd->conn inside subd_conn_init, and reparents subd! */ |
| 1266 | io_new_conn(peer, fd, subd_conn_init, subd); |
| 1267 | } |
| 1268 | |
| 1269 | /* Lightningd says to send a ping */ |
| 1270 | void send_manual_ping(struct daemon *daemon, const u8 *msg) |
no test coverage detected