diff --git a/include/minigui.h b/include/minigui.h index 58d394a9..3290b356 100644 --- a/include/minigui.h +++ b/include/minigui.h @@ -1222,9 +1222,6 @@ typedef struct _ZNODEHEADER { int lock_count; #ifdef _MGSCHEMA_COMPOSITING - /** The file descriptor of the surface; since 5.2.0. */ - int fd; - /** The count for changes of the content. */ unsigned int changes; /** diff --git a/src/gui/window.c b/src/gui/window.c index b2d93660..556a6330 100644 --- a/src/gui/window.c +++ b/src/gui/window.c @@ -4478,8 +4478,8 @@ HWND GUIAPI CreateMainWindowEx2 (PMAINWINCREATE pCreateInfo, LINT id, #ifdef _MGSCHEMA_COMPOSITING /* Since 5.2.0: keep fd available. */ if (0 && pWin->surf->shared_header) { - close (pWin->surf->shared_header->fd); - pWin->surf->shared_header->fd = -1; + close (pWin->surf->fd); + pWin->surf->fd = -1; } #endif @@ -6038,8 +6038,8 @@ HWND GUIAPI CreateWindowEx2 (const char* spClassName, #ifdef _MGSCHEMA_COMPOSITING /* Since 5.2.0: keep fd available. */ if (0 && dwExStyle & WS_EX_CTRLASMAINWIN && pNewCtrl->surf->shared_header) { - close (pNewCtrl->surf->shared_header->fd); - pNewCtrl->surf->shared_header->fd = -1; + close (pNewCtrl->surf->fd); + pNewCtrl->surf->fd = -1; } #endif @@ -6081,7 +6081,7 @@ int GUIAPI GetWindowSharedSurfaceFD (HWND hWnd, size_t *map_size, DWORD *flags) *flags |= MEMDC_FLAG_HWSURFACE; } - return pWin->surf->shared_header->fd; + return pWin->surf->fd; } return -1; diff --git a/src/include/dc.h b/src/include/dc.h index 52279879..c0291322 100644 --- a/src/include/dc.h +++ b/src/include/dc.h @@ -521,14 +521,16 @@ static inline void _dc_step_y (PDC pdc, int step) # define BLOCK_DRAW_SEM(pdc) \ do { \ - if (pdc->surface->shared_header) \ - LOCK_SURFACE_SEM (pdc->surface->shared_header->sem_num); \ + if (pdc->surface->shared_header) { \ + __mg_lock_file_for_write(pdc->surface->fd); \ + } \ } while (0) # define UNBLOCK_DRAW_SEM(pdc) \ do { \ - if (pdc->surface->shared_header) \ - UNLOCK_SURFACE_SEM (pdc->surface->shared_header->sem_num); \ + if (pdc->surface->shared_header) { \ + __mg_unlock_file_for_write(pdc->surface->fd); \ + } \ } while (0) # define IS_SCREEN_SURFACE(pdc) \ diff --git a/src/include/drawsemop.h b/src/include/drawsemop.h index 052bcd1f..907ee068 100644 --- a/src/include/drawsemop.h +++ b/src/include/drawsemop.h @@ -51,12 +51,10 @@ #ifndef GUI_DRAWSEMOP_H #define GUI_DRAWSEMOP_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include +#include "misc.h" + static inline void my_sem_op (int semid, int num, int op) { struct sembuf sb; @@ -70,6 +68,9 @@ again: if (errno == EINTR) { goto again; } + else { + _ERR_PRINTF("Failed semop: %m\n"); + } } } @@ -79,9 +80,21 @@ again: #define LOCK_SCREEN_SEM() my_sem_op(SHAREDRES_SEMID, _IDX_SEM_SCR, -1) #define UNLOCK_SCREEN_SEM() my_sem_op(SHAREDRES_SEMID, _IDX_SEM_SCR, 1) +extern int __mg_client_id; + +#if 0 #ifdef _MGSCHEMA_COMPOSITING -# define LOCK_SURFACE_SEM(num) my_sem_op(SHAREDRES_SEMID_SHARED_SURF, num, -1) -# define UNLOCK_SURFACE_SEM(num) my_sem_op(SHAREDRES_SEMID_SHARED_SURF, num, 1) +# define LOCK_SURFACE_SEM(num) \ + do { \ + printf("Locking semaphor %d for client: %d\n", num, __mg_client_id); \ + my_sem_op(SHAREDRES_SEMID_SHARED_SURF, num, -1); \ + } while (0) +# define UNLOCK_SURFACE_SEM(num) \ + do { \ + my_sem_op(SHAREDRES_SEMID_SHARED_SURF, num, 1); \ + printf("Unlocked semaphor %d for client: %d\n", num, __mg_client_id); \ + } while (0) +#endif #endif #ifdef _MGHAVE_CURSOR @@ -157,6 +170,10 @@ again: # define UNLOCK_MOUSEMOVE_SEM() my_sem_op(SHAREDRES_SEMID, _IDX_SEM_MOUSEMOVE, 1) #endif /* _MGRM_PROCESSES */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/src/include/misc.h b/src/include/misc.h index 99b5af04..4bf2a604 100644 --- a/src/include/misc.h +++ b/src/include/misc.h @@ -79,6 +79,11 @@ struct timezone { extern "C" { #endif /* __cplusplus */ +void __mg_lock_file_for_read(int fd); +void __mg_unlock_file_for_read(int fd); +void __mg_lock_file_for_write(int fd); +void __mg_unlock_file_for_write(int fd); + unsigned int __mg_os_get_random_seed (void); void __mg_os_time_delay (int ms); void __mg_os_start_time (void); diff --git a/src/include/newgal.h b/src/include/newgal.h index 9ef1145e..70f05d59 100644 --- a/src/include/newgal.h +++ b/src/include/newgal.h @@ -145,20 +145,19 @@ typedef struct _SharedSurfaceHeader { /* The client identifier of the creator. */ int create_cli; - /* The number of semphore for this surface. - The SysV semaphore set id for synchronizing this shared surface: - SHAREDRES_SEMID_SHARED_SURF. */ - int sem_num; - - /* the size of the whole buffer */ - size_t map_size; - /* the offset of pixels data */ - off_t pixels_off; - - /* The file descriptor in context of the creator. */ - int fd; /* Not zero for hardware surface. */ int byhw; + + /* Deprecated since 5.2.0. + The number of semphore for this surface. + The SysV semaphore set id for synchronizing this shared surface: + SHAREDRES_SEMID_SHARED_SURF. + int sem_num; */ + + /* Deprecated since 5.2.0. + The file descriptor in context of the creator. + int fd; */ + /* the size of the surface */ int width, height; /* the pitch of the surface */ @@ -168,6 +167,11 @@ typedef struct _SharedSurfaceHeader { /* the RGBA masks */ Uint32 Rmask, Gmask, Bmask, Amask; + /* the size of the whole buffer */ + size_t map_size; + /* the offset of pixels data */ + off_t pixels_off; + /* The dirty information */ GAL_DirtyInfo dirty_info; } GAL_SharedSurfaceHeader; @@ -234,6 +238,8 @@ typedef struct GAL_Surface { GAL_SharedSurfaceHeader *shared_header; /* Private */ /* The dirty info for non-shared surface. */ GAL_DirtyInfo *dirty_info; /* Private */ + /* The file descriptor if the surface is a shared surface. */ + int fd; /* Private; since 5.2.0. */ #endif } GAL_Surface; diff --git a/src/include/zorder.h b/src/include/zorder.h index 4d33c0c2..0e22920d 100644 --- a/src/include/zorder.h +++ b/src/include/zorder.h @@ -79,7 +79,6 @@ typedef struct _ZORDERNODE { unsigned int lock_count; /* the lock count */ #ifdef _MGSCHEMA_COMPOSITING - int fd; /* the file descriptor; since 5.2.0. */ unsigned int changes; /* count for changes of content */ int ct; /* the compositing type */ DWORD ct_arg; /* the argument for compositing */ diff --git a/src/kernel/compsor-manager.c b/src/kernel/compsor-manager.c index 000381d2..81b0c1d9 100644 --- a/src/kernel/compsor-manager.c +++ b/src/kernel/compsor-manager.c @@ -56,7 +56,6 @@ #include #include -#define _DEBUG #include "common.h" #if defined(_MGRM_PROCESSES) && defined(_MGSCHEMA_COMPOSITING) @@ -131,9 +130,10 @@ static const CompositorOps* load_default_compositor (void) static void lock_znode_surface (PDC pdc, ZORDERNODE* node) { + _DBG_PRINTF("lock count for node %p: %d\n", node, node->lock_count); if (node->lock_count == 0) { if (pdc->surface->shared_header) { - LOCK_SURFACE_SEM (pdc->surface->shared_header->sem_num); + __mg_lock_file_for_read(pdc->surface->fd); } node->dirty_age = pdc->surface->dirty_info->dirty_age; @@ -147,11 +147,13 @@ static void lock_znode_surface (PDC pdc, ZORDERNODE* node) static void unlock_znode_surface (PDC pdc, ZORDERNODE* node) { + _DBG_PRINTF("lock count for node %p: %d\n", node, node->lock_count); if (node->lock_count > 0) { node->lock_count--; if (node->lock_count == 0) { - if (pdc->surface->shared_header) - UNLOCK_SURFACE_SEM (pdc->surface->shared_header->sem_num); + if (pdc->surface->shared_header) { + __mg_unlock_file_for_read(pdc->surface->fd); + } node->dirty_age = 0; node->nr_dirty_rcs = 0; diff --git a/src/kernel/desktop-procs.c b/src/kernel/desktop-procs.c index b72e36db..21988d4d 100644 --- a/src/kernel/desktop-procs.c +++ b/src/kernel/desktop-procs.c @@ -365,7 +365,7 @@ static intptr_t cliAllocZOrderNode (PMAINWIN pWin, const COMPOSITINGINFO* ct_inf } if (ClientRequestEx2 (&req, caption, strlen(caption) + 1, - pWin->surf->shared_header->fd, + pWin->surf->fd, &ret, sizeof (intptr_t), NULL) < 0) return -1; #else /* ndef _MGSCHEMA_COMPOSITING */ @@ -524,7 +524,7 @@ static intptr_t cliStartTrackPopupMenu (PTRACKMENUINFO ptmi) info.surf_flags = surf->flags; info.surf_size = surf->shared_header->map_size; - if (ClientRequestEx2 (&req, NULL, 0, surf->shared_header->fd, + if (ClientRequestEx2 (&req, NULL, 0, surf->fd, &ret, sizeof (intptr_t), NULL) < 0) return -1; } @@ -2211,7 +2211,7 @@ static int resize_window_surface (PMAINWIN pWin, const RECT* prcResult) pWin->surf = new_surf; if (pWin->surf->shared_header) - return pWin->surf->shared_header->fd; + return pWin->surf->fd; else return 0; } @@ -2257,9 +2257,9 @@ static int dskMoveGlobalControl (PMAINWIN pCtrl, RECT* prcExpect) #ifdef _MGSCHEMA_COMPOSITING /* Since 5.2.0: keep fd available. */ - if (0 && pCtrl->surf->shared_header && pCtrl->surf->shared_header->fd >= 0) { - close (pCtrl->surf->shared_header->fd); - pCtrl->surf->shared_header->fd = -1; + if (0 && pCtrl->surf->shared_header && pCtrl->surf->fd >= 0) { + close (pCtrl->surf->fd); + pCtrl->surf->fd = -1; } #endif @@ -2289,9 +2289,9 @@ static int dskMoveMainWindow (PMAINWIN pWin, RECT* prcExpect) } /* Since 5.2.0: keep fd available. */ - if (0 && pWin->surf->shared_header && pWin->surf->shared_header->fd >= 0) { - close (pWin->surf->shared_header->fd); - pWin->surf->shared_header->fd = -1; + if (0 && pWin->surf->shared_header && pWin->surf->fd >= 0) { + close (pWin->surf->fd); + pWin->surf->fd = -1; } #endif diff --git a/src/kernel/desktop.c b/src/kernel/desktop.c index b451ced3..867f199c 100644 --- a/src/kernel/desktop.c +++ b/src/kernel/desktop.c @@ -1535,10 +1535,6 @@ static int srvForceCloseMenu (int cli) for (i = (zi->nr_popupmenus - 1); i >= 0; i--) { DO_COMPSOR_OP_ARGS (on_hiding_ppp, i); DeleteMemDC (menu_nodes[i].mem_dc); - /* Since 5.2.0 */ - assert (menu_nodes[i].fd >= 0); - close (menu_nodes[i].fd); - menu_nodes[i].fd = -1; } #endif /* defined _MGSCHEMA_COMPOSITING */ @@ -1653,7 +1649,6 @@ static int srvStartTrackPopupMenu (int cli, const RECT* rc, HWND ptmi, menu_nodes [zi->nr_popupmenus].rc = *rc; menu_nodes [zi->nr_popupmenus].hwnd = ptmi; #ifdef _MGSCHEMA_COMPOSITING - menu_nodes [zi->nr_popupmenus].fd = fd; menu_nodes [zi->nr_popupmenus].changes = 0; menu_nodes [zi->nr_popupmenus].ct = CT_OPAQUE; menu_nodes [zi->nr_popupmenus].ct_arg = 0; @@ -1699,8 +1694,6 @@ static int srvEndTrackPopupMenu (int cli, int idx_znode) #ifdef _MGSCHEMA_COMPOSITING DO_COMPSOR_OP_ARGS (on_hiding_ppp, idx_znode); - close(menu_nodes [idx_znode].fd); - menu_nodes [idx_znode].fd = -1; DeleteMemDC (menu_nodes [idx_znode].mem_dc); #else /* not defined _MGSCHEMA_COMPOSITING */ rc = menu_nodes [idx_znode].rc; @@ -2361,7 +2354,6 @@ static int AllocZOrderNodeEx (ZORDERINFO* zi, int cli, HWND hwnd, HWND main_win, nodes [free_slot].main_win = main_win; nodes [free_slot].lock_count = 0; #ifdef _MGSCHEMA_COMPOSITING - nodes [free_slot].fd = fd; nodes [free_slot].changes = 0; nodes [free_slot].ct = validate_compositing_type (flags, ct); nodes [free_slot].ct_arg = ct_arg; @@ -2577,14 +2569,6 @@ static int FreeZOrderNodeEx (ZORDERINFO* zi, int idx_znode, HDC* memdc) nodes[idx_znode].caption = NULL; } -#ifdef _MGSCHEMA_COMPOSITING - /* Since 5.2.0 */ - if (nodes[idx_znode].fd >= 0) { - close(nodes[idx_znode].fd); - nodes[idx_znode].fd = -1; - } -#endif - /* Free mask rects */ if (nodes[idx_znode].idx_mask_rect) { release_znode_maskrect (nodes, idx_znode); @@ -3728,10 +3712,6 @@ static int dskMoveWindow (int cli, int idx_znode, HDC memdc, int fd, if (memdc != HDC_INVALID) { DeleteMemDC (nodes [idx_znode].mem_dc); nodes [idx_znode].mem_dc = memdc; - /* Since 5.2.0 */ - assert (nodes [idx_znode].fd >= 0); - close (nodes [idx_znode].fd); - nodes [idx_znode].fd = fd; } unlock_zi_for_change (zi); diff --git a/src/misc/Makefile.am b/src/misc/Makefile.am index 9a0dff38..245daa28 100644 --- a/src/misc/Makefile.am +++ b/src/misc/Makefile.am @@ -7,7 +7,7 @@ EXTRA_DIST= misc.c systext.c rwops.c endianrw.c nposix.c clipboard.c \ libmisc_la_SOURCES = misc.c systext.c rwops.c endianrw.c nposix.c clipboard.c \ math.c about.c license.c anon_file.c rbtree.c map.c \ - error.c sockio.c + error.c sockio.c lock_file.c SRC_FILES = $(libmisc_la_SOURCES) LIB_NAME=libmisc diff --git a/src/newgal/surface-shared.c b/src/newgal/surface-shared.c index 9346c515..95a31628 100644 --- a/src/newgal/surface-shared.c +++ b/src/newgal/surface-shared.c @@ -15,7 +15,7 @@ * and Graphics User Interface (GUI) support system for embedded systems * and smart IoT devices. * - * Copyright (C) 2002~2020, Beijing FMSoft Technologies Co., Ltd. + * Copyright (C) 2002~2023, Beijing FMSoft Technologies Co., Ltd. * Copyright (C) 1998~2002, WEI Yongming * * This program is free software: you can redistribute it and/or modify @@ -143,6 +143,7 @@ GAL_Surface *GAL_CreateSharedRGBSurface (GAL_VideoDevice *video, #endif surface->shared_header = NULL; surface->dirty_info = NULL; + surface->fd = -1; GAL_SetClipRect (surface, NULL); #ifdef _MGUSE_UPDATE_REGION @@ -202,10 +203,12 @@ GAL_Surface *GAL_CreateSharedRGBSurface (GAL_VideoDevice *video, surface->shared_header = hdr = (GAL_SharedSurfaceHeader*)data_map; } + surface->fd = fd; /* Since 5.2.0 */ + /* fill fileds of shared header */ memset (hdr, 0, sizeof(GAL_SharedSurfaceHeader)); hdr->create_cli = __mg_client_id; - hdr->fd = fd; + // hdr->fd = fd; hdr->byhw = byhw; hdr->width = surface->w; hdr->height = surface->h; @@ -222,7 +225,8 @@ GAL_Surface *GAL_CreateSharedRGBSurface (GAL_VideoDevice *video, surface->dirty_info->dirty_age = 0; surface->dirty_info->nr_dirty_rcs = 0; - /* allocate semaphore from semaphore for shared surface */ + /* Deprecated since 5.2.0. + allocate semaphore from semaphore for shared surface if (IsServer() && __gal_fake_screen == NULL) { // use 0 for wallpaper pattern, // because the semaphore set manager is not ready. @@ -233,7 +237,7 @@ GAL_Surface *GAL_CreateSharedRGBSurface (GAL_VideoDevice *video, if (hdr->sem_num < 0) { goto error; } - } + } */ surface->pixels = (uint8_t*)surface->shared_header + pixels_off; @@ -255,16 +259,16 @@ GAL_Surface *GAL_CreateSharedRGBSurface (GAL_VideoDevice *video, error: if (surface) { - if (surface->shared_header) { -#if 0 - if (sem_inited) { - sem_destroy (&surface->shared_header->sem_lock); - } -#endif + if (surface->fd >= 0) { + close(surface->fd); + surface->fd = -1; + } + if (surface->shared_header) { + /* Deprecated since 5.2.0 if (surface->shared_header->sem_num >= 0) { __mg_free_sem_for_shared_surf (surface->shared_header->sem_num); - } + } */ if (surface->shared_header->byhw) { assert(video->FreeSharedHWSurface); @@ -272,7 +276,6 @@ error: surface->hwdata = NULL; /* set to NULL for GAL_FreeSurface */ } else { - close (surface->shared_header->fd); munmap (surface->shared_header, surface->shared_header->map_size); } @@ -301,20 +304,16 @@ void GAL_FreeSharedSurfaceData (GAL_Surface *surface) GAL_VideoDevice *video = surface->video; assert (surface->shared_header); + assert (surface->fd >= 0); #if 0 sem_destroy (&surface->shared_header->sem_lock); #endif + /* Deprecated since 5.2.0 if (surface->shared_header->sem_num >= 0) { __mg_free_sem_for_shared_surf (surface->shared_header->sem_num); - } - - // the file descriptor may have been closed. - if (surface->shared_header->fd >= 0) { - close (surface->shared_header->fd); - surface->shared_header->fd = -1; - } + } */ if (surface->shared_header->byhw) { assert (video->FreeSharedHWSurface); @@ -326,6 +325,8 @@ void GAL_FreeSharedSurfaceData (GAL_Surface *surface) surface->shared_header->map_size); } + close(surface->fd); + surface->pixels = NULL; #ifdef _MGUSE_PIXMAN surface->pix_img = NULL; @@ -333,6 +334,7 @@ void GAL_FreeSharedSurfaceData (GAL_Surface *surface) #endif surface->shared_header = NULL; surface->dirty_info = NULL; + surface->fd = -1; } /* @@ -373,6 +375,8 @@ GAL_Surface * GAL_AttachSharedRGBSurface (GAL_VideoDevice *video, surface->shared_header = NULL; surface->hwdata = NULL; + surface->fd = fd; + if (video && video->AttachSharedHWSurface) { // this method should fill hwdata and shared_header fields if success video->AttachSharedHWSurface (video, surface, fd, map_size, with_wr); diff --git a/src/newgal/surface.c b/src/newgal/surface.c index d3da44b2..b9544af8 100644 --- a/src/newgal/surface.c +++ b/src/newgal/surface.c @@ -1841,6 +1841,11 @@ void GAL_FreeSurface (GAL_Surface *surface) else GAL_FreeSharedSurfaceData(surface); + if (surface->fd >= 0) { + close(surface->fd); + surface->fd = -1; + } + surface->hwdata = NULL; surface->pixels = NULL; } diff --git a/src/newgal/video.c b/src/newgal/video.c index c1653446..65fdc13d 100644 --- a/src/newgal/video.c +++ b/src/newgal/video.c @@ -918,9 +918,9 @@ BOOL GAL_SyncUpdate (GAL_Surface *surface) #ifdef _MGSCHEMA_COMPOSITING if (surface->shared_header) { - LOCK_SURFACE_SEM (surface->shared_header->sem_num); + __mg_lock_file_for_write (surface->fd); mark_surface_dirty (surface, numrects, rects); - UNLOCK_SURFACE_SEM (surface->shared_header->sem_num); + __mg_unlock_file_for_write (surface->fd); } else if (surface->dirty_info) { mark_surface_dirty (surface, numrects, rects); diff --git a/src/newgdi/shared-surface.c b/src/newgdi/shared-surface.c index 0db0ca87..b952e79a 100644 --- a/src/newgdi/shared-surface.c +++ b/src/newgdi/shared-surface.c @@ -128,8 +128,7 @@ HSURF GUIAPI CreateSharedSurface(GHANDLE video, const char *name, DWORD flags, int result; if (IsServer()) { - result = __mg_nssurf_map_operate_srv(&nssurf_req, 0, - nssurf->shared_header->fd); + result = __mg_nssurf_map_operate_srv(&nssurf_req, 0, nssurf->fd); } else { REQUEST req; @@ -138,7 +137,7 @@ HSURF GUIAPI CreateSharedSurface(GHANDLE video, const char *name, DWORD flags, req.data = &nssurf_req; req.len_data = sizeof(OPERATENSSURFINFO); - if (ClientRequestEx2(&req, NULL, 0, nssurf->shared_header->fd, + if (ClientRequestEx2(&req, NULL, 0, nssurf->fd, &result, sizeof(result), NULL)) { _ERR_PRINTF("BAD_REQUEST: when setting fd of the new shared surface.\n"); goto failed; @@ -307,7 +306,7 @@ const char *GUIAPI GetSharedSurfaceInfo(HSURF surf, int *fd, } if (fd) { - *fd = surf->shared_header->fd; + *fd = surf->fd; } if (size) { @@ -341,13 +340,7 @@ BOOL GUIAPI LockSharedSurface(HSURF surf, unsigned *dirty_age, goto failed; } - if (surf->flags & GAL_SSURF_LOCKED) { - _WRN_PRINTF("INVALID_CALL: surface locked: %p\n", surf); - goto failed; - } - - LOCK_SURFACE_SEM(surf->shared_header->sem_num); - surf->flags |= GAL_SSURF_LOCKED; + __mg_lock_file_for_read(surf->fd); if (dirty_age) { *dirty_age = surf->shared_header->dirty_info.dirty_age; @@ -374,13 +367,7 @@ BOOL GUIAPI UnlockSharedSurface(HSURF surf, BOOL clear_dirty) goto failed; } - if (!(surf->flags & GAL_SSURF_LOCKED)) { - _WRN_PRINTF("INVALID_CALL: surface not locked: %p\n", surf); - goto failed; - } - - UNLOCK_SURFACE_SEM(surf->shared_header->sem_num); - surf->flags &= ~GAL_SSURF_LOCKED; + __mg_unlock_file_for_read(surf->fd); if (clear_dirty) { surf->dirty_info->nr_dirty_rcs = 0; diff --git a/src/server/layer.c b/src/server/layer.c index e9ae868e..1add76bc 100644 --- a/src/server/layer.c +++ b/src/server/layer.c @@ -910,7 +910,7 @@ const ZNODEHEADER* GUIAPI ServerGetWinZNodeHeader (MG_Layer* layer, if (hdr->lock_count == 0) { if (pdc->surface->shared_header) { // XXX: consider timeout. - LOCK_SURFACE_SEM (pdc->surface->shared_header->sem_num); + __mg_lock_file_for_read(pdc->surface->fd); } hdr->dirty_age = pdc->surface->dirty_info->dirty_age; @@ -962,7 +962,7 @@ const ZNODEHEADER* GUIAPI ServerGetPopupMenuZNodeHeader (int idx, if (hdr->lock_count == 0) { if (pdc->surface->shared_header) { // XXX: consider timeout - LOCK_SURFACE_SEM (pdc->surface->shared_header->sem_num); + __mg_lock_file_for_read(pdc->surface->fd); } hdr->dirty_age = pdc->surface->dirty_info->dirty_age; @@ -1006,7 +1006,7 @@ BOOL GUIAPI ServerReleaseWinZNodeHeader (MG_Layer* layer, int idx_znode) hdr->lock_count--; if (hdr->lock_count == 0) { if (pdc->surface->shared_header) - UNLOCK_SURFACE_SEM (pdc->surface->shared_header->sem_num); + __mg_unlock_file_for_read(pdc->surface->fd); hdr->dirty_age = 0; hdr->nr_dirty_rcs = 0; @@ -1035,7 +1035,7 @@ BOOL GUIAPI ServerReleasePopupMenuZNodeHeader (int idx) hdr->lock_count--; if (hdr->lock_count == 0) { if (pdc->surface->shared_header) - UNLOCK_SURFACE_SEM (pdc->surface->shared_header->sem_num); + __mg_unlock_file_for_read(pdc->surface->fd); hdr->dirty_age = 0; hdr->nr_dirty_rcs = 0; diff --git a/src/server/request.c b/src/server/request.c index 2128e684..cd7309b9 100644 --- a/src/server/request.c +++ b/src/server/request.c @@ -903,7 +903,7 @@ int __mg_get_shared_surface_srv(const char *itn_name, SHAREDSURFINFO *info) __gal_fake_screen->shared_header) { info->flags = __gal_fake_screen->flags; info->size = __gal_fake_screen->shared_header->map_size; - fd = __gal_fake_screen->shared_header->fd; + fd = __gal_fake_screen->fd; } else if (strncmp(itn_name, APPSF_NAME_PREFIX, sizeof(APPSF_NAME_PREFIX) - 1) == 0) { @@ -940,7 +940,7 @@ int __mg_get_shared_surface_srv(const char *itn_name, SHAREDSURFINFO *info) info->height = pdc->surface->shared_header->height; info->pitch = pdc->surface->shared_header->pitch; info->offset = pdc->surface->shared_header->pixels_off; - fd = znode->fd; + fd = pdc->surface->fd; } done: