zephyr/include
Andy Ross 5d6e0d425b net: tcp: Clean up net_context lifecycle
The death of a network context was sort of a mess.  There was one
function, net_context_put(), which was used both by the user as a way
to "close" the connection and by the internals to delete it and to
"clean up" a TCP connection at the end of its life.

This has led to repeated gotchas where contexts die before you are
ready for them (one example: when a user callback decides the
transation is complete and calls net_context_put() underneath the
receive callback for the EOF, which then returns and tries to inspect
the now-freed memory inside the TCP internals).  I've now stepped into
this mess four times now, and it's time to fix the architecture:

Swap the solitary put() call for a more conventional reference
counting implementation.  The put() call now is a pure user API (and
maybe should be renamed "close" or "shutdown").  For compatibility,
it still calls unref() where appropriate (i.e. when the context can be
synchronously deleted) and the FIN processing will still do an unref()
when the FIN packets have been both transmitted and acked.  The
context will start with a refcount of 1, and all TCP callbacks made on
it will increment the refcount around the callback to prevent
premature deletion.

Note that this gives the user a "destroy" mechanism for an in-progress
connection that doesn't require a network round trip.  That might be
useful in some circumstances.

Change-Id: I44cb355e42941605913b2f84eb14d4eb3c134570
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2017-02-03 15:59:14 +02:00
..
arch arm: scb: Move SCB asm defines into cpu_idle.S 2017-01-30 11:02:39 -06:00
bluetooth Bluetooth: A2DP: Stream End Point Structure 2017-01-28 08:43:41 +02:00
debug license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
display license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
drivers drivers/console/telnet: Provide minimal input handling. 2017-01-27 12:35:53 +02:00
fs license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
linker build: remove obsolete sections from linker scripts 2017-01-18 18:47:17 +00:00
logging kernel_event_logger: add additional function prototypes 2017-01-19 20:17:29 +00:00
misc license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
net net: tcp: Clean up net_context lifecycle 2017-02-03 15:59:14 +02:00
shell license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
toolchain license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
usb usb: Change transfer_len type to int32_t in usb_request_handler typedef 2017-01-30 12:01:49 +00:00
adc.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
aio_comparator.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
atomic.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
cache.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
clock_control.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
counter.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
device.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
disk_access.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
dma.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
eth.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
flash.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
fs.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
gpio.h gpio: Merge the OPEN_DRAIN interface with the DRIVE_STRENGTH interface. 2017-01-25 08:47:22 +00:00
i2c.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
init.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
ipm.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
irq.h irq: introduce 'direct' interrupt API definition 2017-02-02 17:46:33 +00:00
irq_offload.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
kernel.h kernel/poll: add k_poll_signal_init() runtime init 2017-02-03 13:54:01 +00:00
kernel_version.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
legacy.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
linker-defs.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
linker-tool-gcc.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
linker-tool.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
microkernel.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
nanokernel.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
pinmux.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
power.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
pwm.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
random.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
rtc.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
section_tags.h k64: Rename security_frdm_k64f section 2017-01-30 11:02:35 -06:00
sections.h k64: Rename security_frdm_k64f section 2017-01-30 11:02:35 -06:00
sensor.h sensor: add SENSOR_CHAN_*_XYZ enum values 2017-01-27 17:46:18 +00:00
shared_irq.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
spi.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
sw_isr_table.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
sys_clock.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
sys_io.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
toolchain.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
uart.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
watchdog.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
zephyr.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00