|
54 | 54 | #include "shared-bindings/hashlib/Hash.h"
|
55 | 55 | #include "lib/oofatfs/diskio.h"
|
56 | 56 |
|
| 57 | +#if CIRCUITPY_FOURWIRE |
| 58 | +#include "shared-module/displayio/__init__.h" |
| 59 | +#endif |
| 60 | + |
57 | 61 | #if CIRCUITPY_MDNS
|
58 | 62 | #include "shared-bindings/mdns/RemoteService.h"
|
59 | 63 | #include "shared-bindings/mdns/Server.h"
|
@@ -1564,9 +1568,32 @@ static void _process_request(socketpool_socket_obj_t *socket, _request *request)
|
1564 | 1568 | }
|
1565 | 1569 | }
|
1566 | 1570 |
|
| 1571 | +static bool supervisor_filesystem_access_could_block(void) { |
| 1572 | + #if CIRCUITPY_FOURWIRE |
| 1573 | + mp_vfs_mount_t *vfs = MP_STATE_VM(vfs_mount_table); |
| 1574 | + if (!vfs->next) { |
| 1575 | + // Assume that the CIRCUITPY root is not sharing a SPI bus with the display SPI bus |
| 1576 | + return false; |
| 1577 | + } |
| 1578 | + // Check display 0 to see if it's on a fourwire (SPI) bus. If it is, blocking is possible |
| 1579 | + // in theory other displays could block but also in reality there's generally 0 or 1 displays |
| 1580 | + for (size_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) { |
| 1581 | + if (display_buses[i].bus_base.type != &fourwire_fourwire_type) { |
| 1582 | + continue; |
| 1583 | + } |
| 1584 | + if (!common_hal_fourwire_fourwire_bus_free(MP_OBJ_FROM_PTR(&display_buses[i].bus_base))) { |
| 1585 | + return true; |
| 1586 | + } |
| 1587 | + } |
| 1588 | + #endif |
| 1589 | + return false; |
| 1590 | +} |
1567 | 1591 |
|
1568 | 1592 | void supervisor_web_workflow_background(void *data) {
|
1569 |
| - while (true) { |
| 1593 | + // If "/sd" is mounted AND shared with a display, access could block. |
| 1594 | + // We don't have a good way to defer a filesystem action way down inside _process_request |
| 1595 | + // when this happens, so just postpone if there's a chance of blocking. (#8980) |
| 1596 | + while (!supervisor_filesystem_access_could_block()) { |
1570 | 1597 | // If we have a request in progress, continue working on it. Do this first
|
1571 | 1598 | // so that we can accept another socket after finishing this request.
|
1572 | 1599 | if (common_hal_socketpool_socket_get_connected(&active)) {
|
|
0 commit comments