Talk to connectd about an active channel */
| 1429 | |
| 1430 | /* Talk to connectd about an active channel */ |
| 1431 | static void connect_activate_subd(struct lightningd *ld, struct channel *channel) |
| 1432 | { |
| 1433 | const u8 *error; |
| 1434 | struct peer_fd *pfd; |
| 1435 | int other_fd; |
| 1436 | |
| 1437 | /* If we have a canned error for this channel, send it now */ |
| 1438 | if (channel->error) { |
| 1439 | error = channel->error; |
| 1440 | goto send_error; |
| 1441 | } |
| 1442 | |
| 1443 | switch (channel->state) { |
| 1444 | case ONCHAIN: |
| 1445 | case FUNDING_SPEND_SEEN: |
| 1446 | case CLOSINGD_COMPLETE: |
| 1447 | case CLOSED: |
| 1448 | case DUALOPEND_OPEN_INIT: |
| 1449 | /* Channel is active */ |
| 1450 | abort(); |
| 1451 | case AWAITING_UNILATERAL: |
| 1452 | /* channel->error is not saved in db, so this can |
| 1453 | * happen if we restart. */ |
| 1454 | error = towire_errorfmt(tmpctx, &channel->cid, |
| 1455 | "Awaiting unilateral close"); |
| 1456 | goto send_error; |
| 1457 | |
| 1458 | case DUALOPEND_OPEN_COMMIT_READY: |
| 1459 | case DUALOPEND_OPEN_COMMITTED: |
| 1460 | case DUALOPEND_AWAITING_LOCKIN: |
| 1461 | assert(!channel->owner); |
| 1462 | pfd = sockpair(tmpctx, channel, &other_fd, &error); |
| 1463 | if (!pfd) |
| 1464 | goto send_error; |
| 1465 | |
| 1466 | if (peer_restart_dualopend(channel->peer, |
| 1467 | pfd, |
| 1468 | channel, false)) |
| 1469 | goto tell_connectd; |
| 1470 | close(other_fd); |
| 1471 | return; |
| 1472 | |
| 1473 | case CHANNELD_AWAITING_LOCKIN: |
| 1474 | case CHANNELD_NORMAL: |
| 1475 | case CHANNELD_AWAITING_SPLICE: |
| 1476 | case CHANNELD_SHUTTING_DOWN: |
| 1477 | case CLOSINGD_SIGEXCHANGE: |
| 1478 | assert(!channel->owner); |
| 1479 | pfd = sockpair(tmpctx, channel, &other_fd, &error); |
| 1480 | if (!pfd) |
| 1481 | goto send_error; |
| 1482 | |
| 1483 | if (peer_start_channeld(channel, |
| 1484 | pfd, |
| 1485 | NULL, true)) { |
| 1486 | goto tell_connectd; |
| 1487 | } |
| 1488 | close(other_fd); |
no test coverage detected