implement setblocking() for modussl_axtls #2631

Open
wants to merge 25 commits into
from

Projects

None yet

2 participants

@nupha
nupha commented Nov 14, 2016

No description provided.

@nupha nupha implement setblocking() for modussl_axtls
9809ff6
@pfalcon
Member
pfalcon commented Nov 14, 2016

Please explain how this is supposed to work and how you tested this (and test script(s) should be included too likely).

@nupha
nupha commented Nov 15, 2016
  1. Proxing SSLSocket.setblocking(flag) call to wrapped socket.setblocking(flag);
  2. Within modussl_axtls.c fix socket_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) function, if a ssl_read() a) returns no data (SSL_OK) and b) SSLSocket is non-blocking and c) current stream errno is EAGAIN, then set errcode arg to EAGAIN, and returns 0; otherwise adopt current code

I use module umqtt.simple to test it. Calling mqtt.check_msg() should raise NotImplemented exception (because check_msg() set socket to non-blocking), after apply the fix, it seem work. Please refer to following code. check_msg() will not block, so console may show word "loop" repeatedly, when a topic arrives, the topic and payload is shown.

from umqtt.simple import MQTTClient
import time

def sub_cb(topic, msg):
    print(topic, msg)


mqtt = MQTTClient("test-client", "192.168.0.7", port=8883, user="1234567890-abcdef", password="1234567890", ssl=True)
mqtt.set_callback(sub_cb)
mqtt.connect()

mqtt.subscribe("test-topic")

while True:
    print("loop")
    mqtt.check_msg()
    time.sleep(1)
nupha added some commits Nov 16, 2016
@nupha nupha Merge remote-tracking branch 'upstream/master' 2d726b4
@nupha nupha Merge remote-tracking branch 'upstream/master'
67d9f8c
@nupha nupha Merge remote-tracking branch 'upstream/master' dc46f7c
@pfalcon
Member
pfalcon commented Dec 15, 2016

So, I very much doubt that everything in the current axTLS config works automagically yo support non-blocking streams, as this patch implies. It's not ready for merging without extensive axTLS code review and testing.

nupha added some commits Dec 23, 2016
@nupha nupha Merge remote-tracking branch 'upstream/master'
5bd153c
@nupha nupha Merge remote-tracking branch 'upstream/master' 3154d71
@nupha nupha Merge remote-tracking branch 'upstream/master'
e769230
@nupha nupha Merge remote-tracking branch 'upstream/master' 66124fe
@nupha nupha Merge remote-tracking branch 'upstream/master' 403707e
@nupha nupha fix bug in ssl ussl.socket_read to determine a nonblocking return 9b6f580
@nupha nupha Merge remote-tracking branch 'upstream/master'
da97ec9
@nupha nupha fix axtls ussl.socket_write check nonblocking error code, and returns 0
7acc312
@nupha nupha Merge remote-tracking branch 'upstream/master' 8155bb3
@nupha nupha Merge remote-tracking branch 'upstream/master'
c72a4ef
@nupha nupha fix modlwip compile error with MICROPY_PY_SLIP=1
12967ff
@nupha nupha adjust macro mp_is_nonblocking_error to use MP_EAGAIN/MP_EWOULDBLOCK …
…instead of EAGIN/EWOULDBLOCK
8a51fff
@nupha nupha Merge remote-tracking branch 'upstream/master' 14ae132
@nupha nupha Merge remote-tracking branch 'upstream/master' e0a5f5e
@nupha nupha ensure lwip.slit() first argument must be a stream object
1aabacc
@nupha nupha add c module for NRF24L01. build with command Use make V=1 or set BUI…
…LD_VERBOSE in your environment to increase build verbosity. to enjoy
2c1537a
@nupha nupha fix function lwip_slip_make_new: check first arg must be a stream com…
…patible object
0d5415d
@nupha nupha add mp_type_nrf24l01 to objmodule.c list
e31c4c6
@nupha nupha Merge remote-tracking branch 'upstream/master'
9d13768
@nupha nupha refactoring methods and stream read/write impl aadfece
@nupha nupha Merge remote-tracking branch 'upstream/master'
a1e0155
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment