Talk to connectd about an active channel */
| 1454 | |
| 1455 | /* Talk to connectd about an active channel */ |
| 1456 | static void connect_activate_subd(struct lightningd *ld, struct channel *channel) |
| 1457 | { |
| 1458 | const u8 *error; |
| 1459 | struct peer_fd *pfd; |
| 1460 | int other_fd; |
| 1461 | |
| 1462 | /* If we have a canned error for this channel, send it now */ |
| 1463 | if (channel->error) { |
| 1464 | error = channel->error; |
| 1465 | goto send_error; |
| 1466 | } |
| 1467 | |
| 1468 | switch (channel->state) { |
| 1469 | case ONCHAIN: |
| 1470 | case FUNDING_SPEND_SEEN: |
| 1471 | case CLOSINGD_COMPLETE: |
| 1472 | case CLOSED: |
| 1473 | case DUALOPEND_OPEN_INIT: |
| 1474 | /* Channel is active */ |
| 1475 | abort(); |
| 1476 | case AWAITING_UNILATERAL: |
| 1477 | /* channel->error is not saved in db, so this can |
| 1478 | * happen if we restart. */ |
| 1479 | error = towire_errorfmt(tmpctx, &channel->cid, |
| 1480 | "Awaiting unilateral close"); |
| 1481 | goto send_error; |
| 1482 | |
| 1483 | case DUALOPEND_OPEN_COMMIT_READY: |
| 1484 | case DUALOPEND_OPEN_COMMITTED: |
| 1485 | case DUALOPEND_AWAITING_LOCKIN: |
| 1486 | assert(!channel->owner); |
| 1487 | pfd = sockpair(tmpctx, channel, &other_fd, &error); |
| 1488 | if (!pfd) |
| 1489 | goto send_error; |
| 1490 | |
| 1491 | if (peer_restart_dualopend(channel->peer, |
| 1492 | pfd, |
| 1493 | channel, false)) |
| 1494 | goto tell_connectd; |
| 1495 | close(other_fd); |
| 1496 | return; |
| 1497 | |
| 1498 | case CHANNELD_AWAITING_LOCKIN: |
| 1499 | case CHANNELD_NORMAL: |
| 1500 | case CHANNELD_AWAITING_SPLICE: |
| 1501 | case CHANNELD_SHUTTING_DOWN: |
| 1502 | case CLOSINGD_SIGEXCHANGE: |
| 1503 | assert(!channel->owner); |
| 1504 | pfd = sockpair(tmpctx, channel, &other_fd, &error); |
| 1505 | if (!pfd) |
| 1506 | goto send_error; |
| 1507 | |
| 1508 | if (peer_start_channeld(channel, |
| 1509 | pfd, |
| 1510 | NULL, true)) { |
| 1511 | goto tell_connectd; |
| 1512 | } |
| 1513 | close(other_fd); |
no test coverage detected