Changeset 1e3ea91 in mainline


Ignore:
Timestamp:
2013-04-21T16:45:39Z (11 years ago)
Author:
Petr Koupy <petr.koupy@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
21eeb653
Parents:
289cb7dd
Message:

Destroy orphaned windows in the compositor after the client is killed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/compositor/compositor.c

    r289cb7dd r1e3ea91  
    9090typedef struct {
    9191        link_t link;
     92        atomic_t ref_cnt;
    9293        service_id_t in_dsid;
    9394        service_id_t out_dsid;
     
    215216
    216217        link_initialize(&win->link);
     218        atomic_set(&win->ref_cnt, 0);
    217219        prodcons_initialize(&win->queue);
    218220        transform_identity(&win->transform);
     
    232234static void window_destroy(window_t *win)
    233235{
    234         if (win) {
     236        if (win && atomic_get(&win->ref_cnt) == 0) {
     237                while (!list_empty(&win->queue.list)) {
     238                        window_event_t *event = (window_event_t *) list_first(&win->queue.list);
     239                        list_remove(&event->link);
     240                        free(event);
     241                }
     242
    235243                if (win->surface) {
    236244                        surface_destroy(win->surface);
     
    695703        }
    696704
     705        loc_service_unregister(win->in_dsid);
     706        loc_service_unregister(win->out_dsid);
     707
     708        /* In case the client was killed, input fibril of the window might be
     709         * still blocked on the condition within comp_window_get_event. */
     710        window_event_t *event_dummy = (window_event_t *) malloc(sizeof(window_event_t));
     711        if (event_dummy) {
     712                link_initialize(&event_dummy->link);
     713                prodcons_produce(&win->queue, &event_dummy->link);
     714        }
     715
    697716        /* Calculate damage. */
    698717        sysarg_t x = 0;
     
    706725        }
    707726
    708         /* Release window resources. */
    709         loc_service_unregister(win->in_dsid);
    710         loc_service_unregister(win->out_dsid);
    711         while (!list_empty(&win->queue.list)) {
    712                 list_remove(list_first(&win->queue.list));
    713         }
    714         window_destroy(win);
    715 
    716727        comp_damage(x, y, width, height);
    717728
     
    813824
    814825        if (win) {
     826                atomic_inc(&win->ref_cnt);
    815827                async_answer_0(iid, EOK);
    816828        } else {
     
    825837
    826838                        if (!IPC_GET_IMETHOD(call)) {
    827                                 async_answer_0(callid, EINVAL);
     839                                async_answer_0(callid, EOK);
     840                                atomic_dec(&win->ref_cnt);
     841                                window_destroy(win);
    828842                                return;
    829843                        }
     
    842856
    843857                        if (!IPC_GET_IMETHOD(call)) {
    844                                 async_answer_0(callid, EINVAL);
     858                                comp_window_close(win, callid, &call);
     859                                atomic_dec(&win->ref_cnt);
     860                                window_destroy(win);
    845861                                return;
    846862                        }
     
    857873                                break;
    858874                        case WINDOW_CLOSE:
    859                                 comp_window_close(win, callid, &call);
     875                                /* Postpone the closing until the phone is hung up to cover
     876                                 * the case when the client is killed abruptly. */
     877                                async_answer_0(callid, EOK);
    860878                                break;
    861879                        case WINDOW_CLOSE_REQUEST:
Note: See TracChangeset for help on using the changeset viewer.