Changeset c11ee605 in mainline for uspace/srv/hid/display/dsops.c


Ignore:
Timestamp:
2020-05-11T15:36:46Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
83cb672
Parents:
e49b7997
Message:

Display server needs some locking

Sometimes destroying a window would race with event delivery. We add
one big lock for the display object that is taken before servicing
any client request or input event.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/display/dsops.c

    re49b7997 rc11ee605  
    7676        log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_create()");
    7777
     78        ds_display_lock(client->display);
     79
    7880        rc = ds_window_create(client, params, &wnd);
    7981        log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_create() - ds_window_create -> %d", rc);
    80         if (rc != EOK)
     82        if (rc != EOK) {
     83                ds_display_unlock(client->display);
    8184                return rc;
     85        }
    8286
    8387        log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_create() -> EOK, id=%zu",
     
    9296        (void) ds_display_paint(wnd->display, NULL);
    9397
     98        ds_display_unlock(client->display);
     99
    94100        *rwnd_id = wnd->id;
    95101        return EOK;
     
    101107        ds_window_t *wnd;
    102108
    103         wnd = ds_client_find_window(client, wnd_id);
    104         if (wnd == NULL)
    105                 return ENOENT;
     109        ds_display_lock(client->display);
     110
     111        wnd = ds_client_find_window(client, wnd_id);
     112        if (wnd == NULL) {
     113                ds_display_unlock(client->display);
     114                return ENOENT;
     115        }
    106116
    107117        log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_destroy()");
    108118        ds_client_remove_window(wnd);
    109119        ds_window_destroy(wnd);
     120        ds_display_unlock(client->display);
    110121        return EOK;
    111122}
     
    117128        ds_window_t *wnd;
    118129
    119         wnd = ds_client_find_window(client, wnd_id);
    120         if (wnd == NULL)
    121                 return ENOENT;
     130        ds_display_lock(client->display);
     131
     132        wnd = ds_client_find_window(client, wnd_id);
     133        if (wnd == NULL) {
     134                ds_display_unlock(client->display);
     135                return ENOENT;
     136        }
    122137
    123138        log_msg(LVL_NOTE, LVL_DEBUG, "disp_window_move_req()");
    124139        ds_window_move_req(wnd, pos);
     140        ds_display_unlock(client->display);
    125141        return EOK;
    126142}
     
    131147        ds_window_t *wnd;
    132148
    133         wnd = ds_client_find_window(client, wnd_id);
    134         if (wnd == NULL)
    135                 return ENOENT;
     149        ds_display_lock(client->display);
     150
     151        wnd = ds_client_find_window(client, wnd_id);
     152        if (wnd == NULL) {
     153                ds_display_unlock(client->display);
     154                return ENOENT;
     155        }
    136156
    137157        log_msg(LVL_NOTE, LVL_DEBUG, "disp_window_move()");
    138158        ds_window_move(wnd, pos);
     159        ds_display_unlock(client->display);
    139160        return EOK;
    140161}
     
    146167        ds_window_t *wnd;
    147168
    148         wnd = ds_client_find_window(client, wnd_id);
    149         if (wnd == NULL)
    150                 return ENOENT;
     169        ds_display_lock(client->display);
     170
     171        wnd = ds_client_find_window(client, wnd_id);
     172        if (wnd == NULL) {
     173                ds_display_unlock(client->display);
     174                return ENOENT;
     175        }
    151176
    152177        log_msg(LVL_NOTE, LVL_DEBUG, "disp_window_resize_req()");
    153178        ds_window_resize_req(wnd, rsztype, pos);
     179        ds_display_unlock(client->display);
    154180        return EOK;
    155181}
     
    160186        ds_client_t *client = (ds_client_t *) arg;
    161187        ds_window_t *wnd;
    162 
    163         wnd = ds_client_find_window(client, wnd_id);
    164         if (wnd == NULL)
    165                 return ENOENT;
     188        errno_t rc;
     189
     190        ds_display_lock(client->display);
     191
     192        wnd = ds_client_find_window(client, wnd_id);
     193        if (wnd == NULL) {
     194                ds_display_unlock(client->display);
     195                return ENOENT;
     196        }
    166197
    167198        log_msg(LOG_DEFAULT, LVL_NOTE, "disp_window_resize()");
    168         return ds_window_resize(wnd, offs, nbound);
     199        rc = ds_window_resize(wnd, offs, nbound);
     200        ds_display_unlock(client->display);
     201        return rc;
    169202}
    170203
     
    178211        log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_get_event()");
    179212
     213        ds_display_lock(client->display);
     214
    180215        rc = ds_client_get_event(client, &wnd, event);
    181         if (rc != EOK)
     216        if (rc != EOK) {
     217                ds_display_unlock(client->display);
    182218                return rc;
     219        }
    183220
    184221        *wnd_id = wnd->id;
     222        ds_display_unlock(client->display);
    185223        return EOK;
    186224}
     
    192230        log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_get_info()");
    193231
     232        ds_display_lock(client->display);
    194233        ds_display_get_info(client->display, info);
     234        ds_display_unlock(client->display);
    195235        return EOK;
    196236}
Note: See TracChangeset for help on using the changeset viewer.