Changeset 870f78c in mainline for uspace/srv/hid/rfb/rfb.c


Ignore:
Timestamp:
2013-09-12T14:34:35Z (11 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f9f45e7
Parents:
47b27b40
Message:

rfb: Do not hold lock while sending framebuffer update

File:
1 edited

Legend:

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

    r47b27b40 r870f78c  
    301301}
    302302
    303 static int rfb_send_palette(int conn_sd, rfb_t *rfb)
     303static void *rfb_send_palette_message(rfb_t *rfb, size_t *psize)
    304304{
    305305        size_t size = sizeof(rfb_set_color_map_entries_t) +
     
    308308        void *buf = malloc(size);
    309309        if (buf == NULL)
    310                 return ENOMEM;
     310                return NULL;
    311311       
    312312        void *pos = buf;
     
    327327        }
    328328       
    329         int rc = send(conn_sd, buf, size, 0);
    330         free(buf);
    331        
    332         return rc;
     329        *psize = size;
     330        return buf;
    333331}
    334332
     
    481479static int rfb_send_framebuffer_update(rfb_t *rfb, int conn_sd, bool incremental)
    482480{
     481        fibril_mutex_lock(&rfb->lock);
    483482        if (!incremental || !rfb->damage_valid) {
    484483                rfb->damage_rect.x = 0;
     
    496495       
    497496        void *buf = malloc(buf_size);
    498         if (buf == NULL)
     497        if (buf == NULL) {
     498                fibril_mutex_unlock(&rfb->lock);
    499499                return ENOMEM;
     500        }
    500501        memset(buf, 0, buf_size);
    501502       
     
    522523        rfb_rectangle_to_be(rect, rect);
    523524       
     525        rfb->damage_valid = false;
     526       
     527        size_t send_palette_size = 0;
     528        void *send_palette = NULL;
     529       
    524530        if (!rfb->pixel_format.true_color) {
    525                 int rc = rfb_send_palette(conn_sd, rfb);
     531                send_palette = rfb_send_palette_message(rfb, &send_palette_size);
     532                if (send_palette == NULL) {
     533                        free(buf);
     534                        fibril_mutex_unlock(&rfb->lock);
     535                        return ENOMEM;
     536                }
     537        }
     538       
     539        fibril_mutex_unlock(&rfb->lock);
     540       
     541        if (!rfb->pixel_format.true_color) {
     542                int rc = send(conn_sd, send_palette, send_palette_size, 0);
    526543                if (rc != EOK) {
    527544                        free(buf);
     
    532549        int rc = send(conn_sd, buf, buf_size, 0);
    533550        free(buf);
    534         rfb->damage_valid = false;
     551       
    535552        return rc;
    536553}
     
    694711                        log_msg(LOG_DEFAULT, LVL_DEBUG2,
    695712                            "Received FramebufferUpdateRequest message");
    696                         fibril_mutex_lock(&rfb->lock);
    697713                        rfb_send_framebuffer_update(rfb, conn_sd, fbur.incremental);
    698                         fibril_mutex_unlock(&rfb->lock);
    699714                        break;
    700715                case RFB_CMSG_KEY_EVENT:
Note: See TracChangeset for help on using the changeset viewer.