Contiki OS for 6502 based computers
Go to file
Peter 432f12e156 Several changes to fix bugs and harden mqtt code.
1. The PT_MQTT_WAIT_SEND() macro has several issues:

- It does not check the return value from process_post(), which
  sometimes returns an error code. See next issue.

- Each time the macro is called, is posts an event to itself. The idea
seems to be that the event should be absorbed by the macro itself, so
when the macro terminates there is NOT a net growth of the event
queue. This does not work.  The reason is that the
PROCESS_WAIT_EVENT() sometimes absorbs a broadcast event instead of
its own event, and then the number of events in the event queue
increases. This leads to event explosions and overflow in the event
queue.

- The macro cannot call PT_EXIT(). This will expand to a return
statement, causing a return from the function calling the macro
(mqtt_process), rather then exiting the protothread (which was
probably the intention). Protothreads have lexical scope...

Fixes: 1) Check return value from process_post() 2) Loop until the
event posted to itself is absorbed (rather than just absorbing the
next event) 3) Replace PT_EXIT() with PT_INIT() (doesn't really make a
difference, could probably just be removed).

2. Change order of the checks in the protothread-calling loops in
mqtt_process().  Reason: When a protothread has been cleared by
PT_MQTT_WAIT_SEND(), it will not return a value, so checking against
PT_EXITED does not make sense.

3. PT_MQTT_WRITE_BYTES() should initialize conn->out_write_pos to 0.
When PT_MQTT_WRITE_BYTES() does not finish (due to TCP disconnect for
instance), it may leave conn->out_write_pos with a non-zero
value. Next time PT_MQTT_WRITE_BYTES() is called, it will take data
from the wrong place.

4. Put MQTT_CONN_STATE_ABORT_IMMEDIATE before
MQTT_CONN_STATE_NOT_CONNECTED in the enum list, so that the check
if(conn->state > MQTT_CONN_STATE_NOT_CONNECTED) in mqtt_connect()
fails when in state MQTT_CONN_STATE_ABORT_IMMEDIATE. Otherwise, it
will deadlock and not reattempt connections while in this state.
2017-03-21 16:43:15 +01:00
apps Several changes to fix bugs and harden mqtt code. 2017-03-21 16:43:15 +01:00
core fix a macro related to multicast, which are not user configuration 2017-03-17 20:21:56 +02:00
cpu Merge pull request #2146 from oliverschmidt/slip 2017-03-18 15:56:06 +01:00
dev Merge pull request #1957 from alignan/pull/bme280-sensor 2016-12-10 18:37:21 +01:00
doc Update code-style.c 2016-12-03 12:21:04 +01:00
examples Merge pull request #2073 from cetic/pr-fix-send-na 2017-01-20 13:18:43 +01:00
lib Add support for the FAT file system 2016-11-27 22:50:44 +01:00
platform Merge pull request #2146 from oliverschmidt/slip 2017-03-18 15:56:06 +01:00
regression-tests Add a regression test for ringbufindex APIs 2017-03-09 16:47:24 +09:00
tools Added SLIP support to retro platforms. 2017-02-15 23:43:28 +01:00
.gitattributes Add binary files file extension 2015-10-22 16:19:39 +02:00
.gitignore Merge pull request #1469 from wbober/nrf52dk-pr 2016-06-01 23:11:39 +02:00
.gitmodules Add sensniff as a submodule 2016-12-04 18:43:17 +00:00
.travis.yml Enable TSCH regression testing 2017-03-09 16:47:54 +09:00
CONTRIBUTING.md Updated CONTRIBUTING.md to reflect Contiki's new merging policy 2015-08-18 22:06:56 +02:00
LICENSE
Makefile.include Extended SOURCEDIRS variable with EXTRALDIRS variable in Makefile.include 2016-02-15 09:37:38 +01:00
README-BUILDING.md Rename to md 2013-03-26 23:15:37 +01:00
README-EXAMPLES.md Several minor consistency improvements. 2013-07-31 00:55:31 +02:00
README.md Travis icon in README.md: show build status of the current master rather than latest build status (can be any pull request) 2015-08-19 09:21:38 +02:00

The Contiki Operating System

Build Status

Contiki is an open source operating system that runs on tiny low-power microcontrollers and makes it possible to develop applications that make efficient use of the hardware while providing standardized low-power wireless communication for a range of hardware platforms.

Contiki is used in numerous commercial and non-commercial systems, such as city sound monitoring, street lights, networked electrical power meters, industrial monitoring, radiation monitoring, construction site monitoring, alarm systems, remote house monitoring, and so on.

For more information, see the Contiki website:

http://contiki-os.org