core-lightning/common
Christian Decker bb38541d9e common: Added a small locking mechanism to simplify how we lock IO
We've done this a number of times already where we're getting
exclusive access to either the out direction of a connection, or we
try to lock out the read side while we are responding to a previous
request. They usually are really cumbersome because we reach around to
the other direction to stop it from proceeding, or we flag our
exclusive access somewhere, and we always need to know whom to notify.

PR ElementsProject/lightning#1970 adds two new instances of this:

 - Streaming a JSON response requires that nothing else should write
   while the stream is active.
 - We also want to stop reading new requests while we are responding
   to one.

To remove the complexity of having to know whom to stop and notify
when we're done, this adds a simple `io_lock` primitive that can be
used to get exclusive access to a connection. This inverts the
requirement for notifications, since everybody registers interest in
the lock and they get notified if the lock holder releases it.
2018-10-11 01:43:55 +00:00
..
test Use localfeatures and globalfeatures consistently. 2018-09-28 04:14:28 +00:00
base32.c Remove tal_len, use tal_count() or tal_bytelen(). 2018-07-30 11:31:17 +02:00
base32.h common/base32: make this a simple tal-wrapper around ccan/base32. 2018-05-10 02:28:44 +00:00
bech32_util.c Remove tal_len, use tal_count() or tal_bytelen(). 2018-07-30 11:31:17 +02:00
bech32_util.h common: Moving some bech32 related utilities to bech32_util 2018-04-25 12:34:55 +02:00
bech32.c Remove include in file foo.c that is already included in foo.h 2018-03-25 23:54:21 +00:00
bech32.h Use expected LIGHTNING_DIR_FILE_H define 2018-03-25 23:54:21 +00:00
bip32.c common: move some files out of lightningd/ 2017-08-29 17:54:14 +02:00
bip32.h headers: fix up header idempotent lines. 2017-08-29 17:54:14 +02:00
bolt11.c common/utils.h: add tal_arr_expand helper. 2018-09-27 22:57:19 +02:00
bolt11.h bolt11: allow multiple fallback addresses. 2018-04-06 14:26:53 +02:00
channel_config.c common: move some files out of lightningd/ 2017-08-29 17:54:14 +02:00
channel_config.h Revert "Send/receive cltv_expiry_delta in open/accept channel." 2017-10-11 11:54:50 +02:00
close_tx.c bitcoin: create new wrapper type bitcoin_txid, log backward endianness. 2017-12-21 11:05:38 +00:00
close_tx.h Use expected LIGHTNING_DIR_FILE_H define 2018-03-25 23:54:21 +00:00
configdir.c lightningd: fix double-specified args. 2018-05-05 17:55:10 +02:00
configdir.h options: don't leak memory when people override options. 2017-12-13 22:46:10 +01:00
crypto_state.c crypto_state: move to its own file. 2017-10-20 18:31:32 +02:00
crypto_state.h crypto_state: move to its own file. 2017-10-20 18:31:32 +02:00
crypto_sync.c crypto_sync: sync_crypto_write_no_delay to flush TCP after critical packets. 2018-08-10 12:46:45 +02:00
crypto_sync.h crypto_sync: sync_crypto_write_no_delay to flush TCP after critical packets. 2018-08-10 12:46:45 +02:00
cryptomsg.c common/cryptomsg: remove unused async routines. 2018-09-28 04:14:28 +00:00
cryptomsg.h common/cryptomsg: remove unused async routines. 2018-09-28 04:14:28 +00:00
daemon_conn.c daemon_conn: fix memory leak when passing an fd. 2018-08-24 19:54:32 +02:00
daemon_conn.h common/daemon_conn: add daemon_conn_wake() helper. 2018-07-25 02:13:52 +00:00
daemon.c lightningd: minor cleanups 2018-09-03 05:01:40 +00:00
daemon.h lightningd: minor cleanups 2018-09-03 05:01:40 +00:00
decode_short_channel_ids.c common/utils.h: add tal_arr_expand helper. 2018-09-27 22:57:19 +02:00
decode_short_channel_ids.h Update to latest BOLT version. 2018-07-01 17:37:03 +02:00
derive_basepoints.c derive_basepoints: harden checking. 2018-08-23 14:46:22 +02:00
derive_basepoints.h derive_basepoints: harden checking. 2018-08-23 14:46:22 +02:00
dev_disconnect.c Spelling corrections (#824) 2018-01-29 04:46:54 +00:00
dev_disconnect.h Add DEVELOPER flag, set by default. 2017-10-26 12:53:09 +02:00
features.c Use localfeatures and globalfeatures consistently. 2018-09-28 04:14:28 +00:00
features.h More renaming of gfeatures to globalfeatures. 2018-10-09 08:40:52 +00:00
funding_tx.c common: remove unused assert() headers. 2017-10-26 12:53:09 +02:00
funding_tx.h bitcoin: create new wrapper type bitcoin_txid, log backward endianness. 2017-12-21 11:05:38 +00:00
hash_u5.c common/hash_u5: routines to hash 5 bit values. 2017-11-01 01:09:23 +00:00
hash_u5.h common/hash_u5: routines to hash 5 bit values. 2017-11-01 01:09:23 +00:00
htlc_state.c common: absorb remaining files from daemon/ 2017-08-29 17:54:14 +02:00
htlc_state.h Fix a-vs-an typos 2018-02-08 22:49:34 +01:00
htlc_tx.c common: fix up BOLT 3 references. 2018-06-18 12:31:09 +02:00
htlc_tx.h common: fix up BOLT 3 references. 2018-06-18 12:31:09 +02:00
htlc_wire.c Remove tal_len, use tal_count() or tal_bytelen(). 2018-07-30 11:31:17 +02:00
htlc_wire.h channeld: always receive and maintain short_channel_id of failing channel. 2018-07-27 14:12:00 +02:00
htlc.h Remove unused functions not covered by unit tests 2018-03-28 11:22:05 +02:00
initial_channel.c channeld: Do not fail if we get a chain_hash we don't know 2018-09-14 21:18:11 +02:00
initial_channel.h channeld: Keep track of the chainparams for the chain we are using 2018-09-14 21:18:11 +02:00
initial_commit_tx.c BOLT updates: broken link fixes 2018-09-21 00:24:12 +00:00
initial_commit_tx.h common: fix up BOLT 3 references. 2018-06-18 12:31:09 +02:00
io_lock.c common: Added a small locking mechanism to simplify how we lock IO 2018-10-11 01:43:55 +00:00
io_lock.h common: Added a small locking mechanism to simplify how we lock IO 2018-10-11 01:43:55 +00:00
json_escaped.c param: upgraded json_tok_escaped_string 2018-09-03 00:40:27 +00:00
json_escaped.h param: upgraded json_tok_escaped_string 2018-09-03 00:40:27 +00:00
json.c json: Support streaming JSON messages 2018-09-25 05:47:23 +00:00
json.h param: upgraded json_tok_label 2018-09-03 00:40:27 +00:00
key_derive.c common: fix up BOLT 3 references. 2018-06-18 12:31:09 +02:00
key_derive.h headers: fix up header idempotent lines. 2017-08-29 17:54:14 +02:00
keyset.c common/keyset: use struct basepoints rather than open-coding fields. 2018-07-24 00:40:01 +02:00
keyset.h common/keyset: use struct basepoints rather than open-coding fields. 2018-07-24 00:40:01 +02:00
Makefile common: Added a small locking mechanism to simplify how we lock IO 2018-10-11 01:43:55 +00:00
memleak.c common/utils.h: add tal_arr_expand helper. 2018-09-27 22:57:19 +02:00
memleak.h memleak: allow for scanning non-talloc regions. 2018-08-24 19:54:32 +02:00
msg_queue.c common/utils.h: add tal_arr_expand helper. 2018-09-27 22:57:19 +02:00
msg_queue.h headers: fix up header idempotent lines. 2017-08-29 17:54:14 +02:00
overflows.h The overflow check mul_overflows_s64(int64_t, int64_t) overflows and triggers UB :-) Remove it 2018-03-27 23:18:48 +00:00
peer_billboard.c common: peer_billboard() helper for updating the billboard. 2018-02-23 18:02:00 +01:00
peer_billboard.h common: peer_billboard() helper for updating the billboard. 2018-02-23 18:02:00 +01:00
peer_failed.c peer_failed: write error message to peer directly. 2018-08-09 19:44:27 +02:00
peer_failed.h common/read_peer_msg: deconstruct into individual helper routines. 2018-08-05 02:03:58 +00:00
peer_status_wire.csv gossipd: drain fd instead of passing around gossip index. 2018-04-26 05:47:57 +00:00
permute_tx.c Remove tal_len, use tal_count() or tal_bytelen(). 2018-07-30 11:31:17 +02:00
permute_tx.h headers: fix up header idempotent lines. 2017-08-29 17:54:14 +02:00
ping.c Remove tal_len, use tal_count() or tal_bytelen(). 2018-07-30 11:31:17 +02:00
ping.h pong: embed version string into ping replies if DEVELOPER=1. 2018-02-22 12:24:26 +01:00
pseudorand.c common: absorb remaining files from daemon/ 2017-08-29 17:54:14 +02:00
pseudorand.h headers: fix up header idempotent lines. 2017-08-29 17:54:14 +02:00
read_peer_msg.c common/read_peer_msg: remove. 2018-08-05 02:03:58 +00:00
read_peer_msg.h common/read_peer_msg: remove. 2018-08-05 02:03:58 +00:00
socket_close.c closingd: Ensure proper closing of TCP socket. 2018-05-09 04:43:21 +00:00
socket_close.h closingd: Ensure proper closing of TCP socket. 2018-05-09 04:43:21 +00:00
sphinx.c Remove tal_len, use tal_count() or tal_bytelen(). 2018-07-30 11:31:17 +02:00
sphinx.h common: fix up BOLT 4 references. 2018-06-18 12:31:09 +02:00
status_levels.h status: separate types for peer failure vs "impossible" failures. 2018-02-08 19:07:12 +01:00
status_wire.c status: generate messages rather than marshal/unmarshal manually. 2018-02-08 19:07:12 +01:00
status_wire.csv status: make status_io a more generic mechanism. 2018-05-10 02:28:44 +00:00
status_wire.h status: generate messages rather than marshal/unmarshal manually. 2018-02-08 19:07:12 +01:00
status.c common: log when we toggle IO logging, don't edit env in tests! 2018-08-23 14:46:22 +02:00
status.h status: make status_io a more generic mechanism. 2018-05-10 02:28:44 +00:00
subdaemon.c subdaemon: better GDB support. 2018-09-04 14:36:05 +02:00
subdaemon.h common/daemon: common routines for all daemons. 2018-04-03 14:03:28 +02:00
timeout.c utils: remove tal_tmpctx altogether, use global. 2018-03-16 00:16:10 +00:00
timeout.h headers: fix up header idempotent lines. 2017-08-29 17:54:14 +02:00
type_to_string.c Fix order of includes 2018-03-06 19:26:21 +01:00
type_to_string.h wireaddr_internal: new type for where we can also use a local socket. 2018-05-07 22:37:28 +02:00
utils.c common/utils: don't free tmpctx, just the children. 2018-08-05 02:03:58 +00:00
utils.h common/utils.h: add tal_arr_expand helper. 2018-09-27 22:57:19 +02:00
utxo.c tools/generate_wire.py: generate varlen arrays properly. 2018-02-08 19:07:12 +01:00
utxo.h cleanup: Make blockheights unsigned 2018-03-27 23:17:17 +00:00
version.c Make version output simpler/more user-friendly 2018-04-04 02:32:44 +00:00
version.h Onboarding: Make log output texts friendlier to new users 2018-01-29 03:22:27 +00:00
wallet_tx.c fundchannel: cap 'all' at 2^24-1 satoshi. 2018-07-30 11:46:41 +02:00
wallet_tx.h fundchannel: cap 'all' at 2^24-1 satoshi. 2018-07-30 11:46:41 +02:00
wire_error.c Remove tal_len, use tal_count() or tal_bytelen(). 2018-07-30 11:31:17 +02:00
wire_error.h common: fix up BOLT 1 references. 2018-06-18 12:31:09 +02:00
wireaddr.c wireaddr: add wireaddr_eq. 2018-09-28 18:20:17 +02:00
wireaddr.h wireaddr: add wireaddr_eq. 2018-09-28 18:20:17 +02:00
withdraw_tx.c travis: reenable check-source (without BOLT text). 2017-12-21 14:33:27 +01:00
withdraw_tx.h Change withdraw_tx to accept scriptpubkey rather than plain address. 2017-12-13 03:10:04 +00:00