Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 87822ce in mainline for uspace/lib/ui/src/ui.c


Ignore:
Timestamp:
2021-03-04T19:14:30Z (2 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial
Children:
d6c4d40
Parents:
760a392
Message:

Avoid infinite loop when console communication is broken

Need to make sure callers of console_get_event_timeout() can distinguish
between timeout and I/O error. Fix all callers of console_get_event()
and console_get_event_timeout() not to enter infinite loop when console
connection is broken. Also avoid setting of errno variable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/src/ui.c

    r760a392 r87822ce  
    3939#include <fibril.h>
    4040#include <io/console.h>
     41#include <stdbool.h>
    4142#include <stdlib.h>
    4243#include <str.h>
     
    220221void ui_run(ui_t *ui)
    221222{
    222         bool have_event;
    223223        cons_event_t event;
    224224        usec_t timeout;
     225        errno_t rc;
    225226
    226227        /* Only return command prompt if we are running in a separate window */
     
    231232                if (ui->console != NULL) {
    232233                        timeout = 100000;
    233                         have_event = console_get_event_timeout(ui->console,
     234                        rc = console_get_event_timeout(ui->console,
    234235                            &event, &timeout);
    235                         if (have_event)
     236
     237                        /* Do we actually have an event? */
     238                        if (rc == EOK) {
    236239                                ui_cons_event_process(ui, &event);
     240                        } else if (rc != ETIMEOUT) {
     241                                /* Error, quit */
     242                                break;
     243                        }
    237244                } else {
    238245                        fibril_usleep(100000);
Note: See TracChangeset for help on using the changeset viewer.