Commit Graph

7 Commits

Author SHA1 Message Date
Damien George
6e30f96b0b ports: Convert legacy uppercase macro names to lowercase. 2019-02-12 14:54:51 +11:00
Paul Sokolovsky
0c18633ea9 unix/modusocket: Finish socket.settimeout() implementation.
1. Return correct error code for non-blocking vs timed out socket
(POSIX returns EAGAIN for both, we want ETIMEDOUT in case of timed
out socket). To achieve this, blocking/non-blocking flag is added
to the mp_obj_socket_t, to avoid issuing fcntl() syscall each time
EAGAIN occurs. (mp_obj_socket_t used to be 8 bytes, having some room
in a standard 16-byte alloc block.)

2. Handle socket.settimeout(0) properly - in Python, that means
non-blocking mode, but SO_RCVTIMEO/SO_SNDTIMEO of 0 is infinite
timeout.

3. Overall, make sure that socket.settimeout() call switches blocking
state as expected.
2018-10-17 14:19:06 +11:00
Danielle Madeley
80a25810f9 unix/modusocket: Initial implementation of socket.settimeout(). 2018-10-17 14:19:06 +11:00
Damien George
ef554ef9a2 unix: Use MP_STREAM_GET_FILENO to allow uselect to poll general objects.
This mechanism will scale to to an arbitrary number of pollable objects, so
long as they implement the MP_STREAM_GET_FILENO ioctl.  Since ussl objects
pass through ioctl requests transparently to the underlying socket object,
it will allow ussl sockets to be polled.  And a user object with uio.IOBase
as a base could support polling.
2018-07-20 13:09:49 +10:00
Damien George
cf31d384f1 py/stream: Switch stream close operation from method to ioctl.
This patch moves the implementation of stream closure from a dedicated
method to the ioctl of the stream protocol, for each type that implements
closing.  The benefits of this are:

1. Rounds out the stream ioctl function, which already includes flush,
   seek and poll (among other things).

2. Makes calling mp_stream_close() on an object slightly more efficient
   because it now no longer needs to lookup the close method and call it,
   rather it just delegates straight to the ioctl function (if it exists).

3. Reduces code size and allows future types that implement the stream
   protocol to be smaller because they don't need a dedicated close method.

Code size reduction is around 200 bytes smaller for x86 archs and around
30 bytes smaller for the bare-metal archs.
2018-04-10 13:41:32 +10:00
Paul Sokolovsky
9a7e3469b2 unix/modusocket: Remove #if MICROPY_SOCKET_EXTRA code blocks.
These defined couple of functions added during initial experimentation,
which aren't part of MicroPython API and no longer used or needed.
2017-10-24 23:13:19 +03:00
Paul Sokolovsky
cfff12612f unix: Rename modsocket.c to modusocket.c.
Unix naming is historical, before current conventions were established.
All other ports however have it as "modusocket.c", so rename for
consistency and to avoid confusion.
2017-10-23 12:09:37 +03:00