extmod/modusocket: Provide config macro for socket.listen backlog deflt.
To make it possible to change this value for any given port or board. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
919f696ad2
commit
aab005c75b
|
@ -914,7 +914,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(lwip_socket_bind_obj, lwip_socket_bind);
|
|||
STATIC mp_obj_t lwip_socket_listen(size_t n_args, const mp_obj_t *args) {
|
||||
lwip_socket_obj_t *socket = MP_OBJ_TO_PTR(args[0]);
|
||||
|
||||
mp_int_t backlog = 2;
|
||||
mp_int_t backlog = MICROPY_PY_USOCKET_LISTEN_BACKLOG_DEFAULT;
|
||||
if (n_args > 1) {
|
||||
backlog = mp_obj_get_int(args[1]);
|
||||
backlog = (backlog < 0) ? 0 : backlog;
|
||||
|
|
|
@ -126,7 +126,7 @@ STATIC mp_obj_t socket_listen(size_t n_args, const mp_obj_t *args) {
|
|||
mp_raise_OSError(MP_ENOTCONN);
|
||||
}
|
||||
|
||||
mp_int_t backlog = 2;
|
||||
mp_int_t backlog = MICROPY_PY_USOCKET_LISTEN_BACKLOG_DEFAULT;
|
||||
if (n_args > 1) {
|
||||
backlog = mp_obj_get_int(args[1]);
|
||||
backlog = (backlog < 0) ? 0 : backlog;
|
||||
|
|
|
@ -489,7 +489,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_bind_obj, socket_bind);
|
|||
STATIC mp_obj_t socket_listen(size_t n_args, const mp_obj_t *args) {
|
||||
mod_network_socket_obj_t *self = args[0];
|
||||
|
||||
int32_t backlog = 2;
|
||||
int32_t backlog = MICROPY_PY_USOCKET_LISTEN_BACKLOG_DEFAULT;
|
||||
if (n_args > 1) {
|
||||
backlog = mp_obj_get_int(args[1]);
|
||||
backlog = (backlog < 0) ? 0 : backlog;
|
||||
|
|
|
@ -299,7 +299,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_bind_obj, socket_bind);
|
|||
STATIC mp_obj_t socket_listen(size_t n_args, const mp_obj_t *args) {
|
||||
socket_obj_t *self = MP_OBJ_TO_PTR(args[0]);
|
||||
|
||||
int backlog = 2;
|
||||
int backlog = MICROPY_PY_USOCKET_LISTEN_BACKLOG_DEFAULT;
|
||||
if (n_args > 1) {
|
||||
backlog = mp_obj_get_int(args[1]);
|
||||
backlog = (backlog < 0) ? 0 : backlog;
|
||||
|
|
|
@ -227,7 +227,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_bind_obj, socket_bind);
|
|||
STATIC mp_obj_t socket_listen(size_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_socket_t *self = MP_OBJ_TO_PTR(args[0]);
|
||||
|
||||
int backlog = SOMAXCONN < 128 ? SOMAXCONN : 128;
|
||||
int backlog = MICROPY_PY_USOCKET_LISTEN_BACKLOG_DEFAULT;
|
||||
if (n_args > 1) {
|
||||
backlog = (int)mp_obj_get_int(args[1]);
|
||||
backlog = (backlog < 0) ? 0 : backlog;
|
||||
|
|
|
@ -173,6 +173,7 @@
|
|||
#define MICROPY_PY_UTIME (1)
|
||||
#define MICROPY_PY_UTIME_MP_HAL (1)
|
||||
#define MICROPY_PY_UTIMEQ (1)
|
||||
#define MICROPY_PY_USOCKET_LISTEN_BACKLOG_DEFAULT (SOMAXCONN < 128 ? SOMAXCONN : 128)
|
||||
#if MICROPY_PY_USSL
|
||||
#define MICROPY_PY_UHASHLIB_MD5 (1)
|
||||
#define MICROPY_PY_UHASHLIB_SHA1 (1)
|
||||
|
|
|
@ -190,7 +190,7 @@ STATIC mp_obj_t socket_listen(size_t n_args, const mp_obj_t *args) {
|
|||
socket_obj_t *socket = args[0];
|
||||
socket_check_closed(socket);
|
||||
|
||||
mp_int_t backlog = 2;
|
||||
mp_int_t backlog = MICROPY_PY_USOCKET_LISTEN_BACKLOG_DEFAULT;
|
||||
if (n_args > 1) {
|
||||
backlog = mp_obj_get_int(args[1]);
|
||||
backlog = (backlog < 0) ? 0 : backlog;
|
||||
|
|
|
@ -1593,6 +1593,11 @@ typedef double mp_float_t;
|
|||
#define MICROPY_PY_MACHINE_SOFTSPI (0)
|
||||
#endif
|
||||
|
||||
// The default backlog value for socket.listen(backlog)
|
||||
#ifndef MICROPY_PY_USOCKET_LISTEN_BACKLOG_DEFAULT
|
||||
#define MICROPY_PY_USOCKET_LISTEN_BACKLOG_DEFAULT (2)
|
||||
#endif
|
||||
|
||||
#ifndef MICROPY_PY_USSL
|
||||
#define MICROPY_PY_USSL (0)
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue