initial implementation of new APIs of shared surface: AttachToSharedSurface(), GetSharedSurfaceInfo(), LockSharedSurfaceIfDirty(), UnlockSharedSurface(), and DetachFromSharedSurface()

This commit is contained in:
Vincent Wei
2023-08-29 16:21:49 +08:00
parent 96ecf5e9b7
commit 29ac6a4277
15 changed files with 230 additions and 102 deletions
+25 -27
View File
@@ -1704,10 +1704,10 @@ MG_EXPORT BOOL GUIAPI IsScreenDC (HDC hdc);
*/
MG_EXPORT BOOL GUIAPI IsWindowDC (HDC hdc);
#ifdef _MGSCHEMA_COMPOSITING
struct GAL_Surface;
typedef struct GAL_Surface *HSURF;
#ifdef _MGSCHEMA_COMPOSITING
/**
* \fn HSURF GUIAPI CreateSharedSurface (GHANDLE video,
* const char *name, DWORD flags,
@@ -1842,15 +1842,18 @@ MG_EXPORT HSURF GUIAPI AttachToSharedSurface (GHANDLE video, int fd,
size_t map_size, DWORD flags);
/**
* \fn int GUIAPI GetSharedSurfaceInfo (HSURF surf, SIZE *size, int *pitch,
* size_t *file_size, size_t *pixel_off)
* \brief Gets the file descriptor of a shared surface.
* \fn const char *GUIAPI GetSharedSurfaceInfo (HSURF surf, int *fd,
* SIZE *size, int *pitch, size_t *map_size, off_t *pixels_off)
* \brief Gets the basic information of a shared surface.
*
* This function gets the file descriptor of the shared surface. It also
* returns the size and the pitch of the surface if \a size or \a pitch is
* not NULL.
* This function gets the name and other information of
* the given shared surface \a surf. It also returns the file descriptor,
* the size, or the pitch of the surface if \a fd, \a size or \a pitch
* is not NULL.
*
* \param surf The handle to the shared surface.
* \param fd The pointer to a buffer of int to return the file descriptor of
* the shared surface; nullable.
* \param size The pointer to a buffer of SIZE to return the size of
* the shared surface; nullable.
* \param pitch The pointer to a buffer of int for value of pitch; nullable.
@@ -1859,8 +1862,8 @@ MG_EXPORT HSURF GUIAPI AttachToSharedSurface (GHANDLE video, int fd,
* \param pixel_off The pointer to a buffer of size_t for the offset of
* pixel data; nullable.
*
* \return The file descriptor of the shared surface on success;
* a value less than zero for failure.
* \return The name of the shared surface on success; NULL for failure.
* Note that if the name is an empty string, it is an anonymous surface.
*
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
*
@@ -1868,13 +1871,13 @@ MG_EXPORT HSURF GUIAPI AttachToSharedSurface (GHANDLE video, int fd,
*
* Since 5.2.0
*/
MG_EXPORT int GUIAPI GetSharedSurfaceInfo (HSURF surf, SIZE *size, int *pitch,
size_t *file_size, size_t *pixel_off);
MG_EXPORT const char *GUIAPI GetSharedSurfaceInfo (HSURF surf, int *fd,
SIZE *size, int *pitch, size_t *map_size, off_t *pixels_off);
/**
* \fn BOOL GUIAPI LockSharedSurfaceIfDirty (HSURF surf,
* unsigned old_dirty_age, unsigned *dirty_age,
* int *nr_dirty_rects, RECT *const *dirty_rects)
* int *nr_dirty_rects, const RECT **dirty_rects)
* \brief Locks the shared surface if it is dirty.
*
* This function compares the dirty age of the shared surface with the value
@@ -1884,14 +1887,14 @@ MG_EXPORT int GUIAPI GetSharedSurfaceInfo (HSURF surf, SIZE *size, int *pitch,
* \param surf The handle to the shared surface.
* \param old_dirty_age The old dirty age.
* \param dirty_age The pointer to a buffer of unsigned integer to return
* the current dirty age of the shared surface.
* the current dirty age of the shared surface; NOT nullable.
* \param nr_dirty_rects The pointer to a buffer of integer to return the valid
* dirty rectangles; nullable.
* \param dirty_rects The pointer to a buffer of (const RECT *) for the array
* of dirty rectangles; nullable.
*
* \return TRUE for success and if the value contains in \a dirty_age is larger
* than \a old_dirty_age, the surface was locked; otherwise failure.
* \return TRUE for success and if the value contains in \a dirty_age is not
* equal to \a old_dirty_age, the surface was locked; otherwise failure.
*
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
*
@@ -1901,7 +1904,7 @@ MG_EXPORT int GUIAPI GetSharedSurfaceInfo (HSURF surf, SIZE *size, int *pitch,
*/
MG_EXPORT BOOL GUIAPI LockSharedSurfaceIfDirty (HSURF surf,
unsigned old_dirty_age, unsigned *dirty_age,
int *nr_dirty_rects, RECT *const *dirty_rects);
int *nr_dirty_rects, const RECT **dirty_rects);
/**
* \fn BOOL GUIAPI UnlockSharedSurface (HSURF surf, BOOL clear_dirty)
@@ -1942,28 +1945,23 @@ MG_EXPORT BOOL GUIAPI UnlockSharedSurface (HSURF surf, BOOL clear_dirty);
* Since 5.2.0
*/
MG_EXPORT BOOL GUIAPI DetachFromSharedSurface (HSURF surf);
#endif /* _MGSCHEMA_COMPOSITING */
/**
* \fn HDC GUIAPI CreateMemDCOnSharedSurface (HSURF surf, const RECT *rect);
* \brief Creates a memory DC on a shared surface.
* \fn HDC GUIAPI CreateMemDCFromSurface (HSURF surf);
* \brief Creates a memory DC from a surface.
*
* This function creates a memory DC on the specified shared surface \a surf
* within the specified rectangle \a rect on the surface.
* This function creates a memory DC on the specified surface \a surf.
*
* \param surf The handle to the shared surface.
* \param rect A rectangle in the surface which defines the bounds of memory DC;
* NULL for whole surface.
*
* \return The handle to a new memory DC, HDC_INVALID indicates an error.
*
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
*
* \sa DeleteMemDC
*
* Since 5.0.13
* Since 5.2.0
*/
MG_EXPORT HDC GUIAPI CreateMemDCOnSharedSurface (HSURF surf, const RECT *rect);
#endif /* _MGSCHEMA_COMPOSITING */
MG_EXPORT HDC GUIAPI CreateMemDCFromSurface(HSURF surf);
/**
* \fn HDC GUIAPI CreateMemDCEx (int width, int height, int depth, DWORD flags, \
+1 -1
View File
@@ -6069,7 +6069,7 @@ error:
#ifdef _MGSCHEMA_COMPOSITING
int GUIAPI GetWindowSharedSurfaceFD (HWND hWnd, size_t *map_size, DWORD *flags)
{
MG_CHECK_RET (MG_IS_APP_WINDOW (hWnd), -1);
MG_CHECK_RET (MG_IS_NORMAL_WINDOW (hWnd), -1);
PMAINWIN pWin = (PMAINWIN)hWnd;
if (pWin->surf->shared_header) {
+8 -1
View File
@@ -105,8 +105,15 @@ int __mg_map_get_size (map_t* map);
map_entry_t* __mg_map_find (map_t* map, const void* key);
int __mg_map_insert_ex (map_t* map, const void* key,
map_entry_t* __mg_map_insert_ex2 (map_t* map, const void* key,
const void* val, free_val_fn free_val_alt);
static int __mg_map_insert_ex (map_t* map, const void* key,
const void* val, free_val_fn free_val_alt)
{
return __mg_map_insert_ex2(map, key, val, NULL) ? 0 : -1;
}
static inline int __mg_map_insert (map_t* map, const void* key,
const void* val)
{
+6 -4
View File
@@ -256,6 +256,8 @@ typedef struct GAL_Surface {
#define GAL_PREALLOC 0x01000000 /* Surface uses preallocated memory */
#define GAL_FORMAT_CHECKED 0x02000000 /* Pixman format checked */
#define GAL_SSURF_ATTACHED 0x04000000 /* The shared surface is attached to. */
#define GAL_SSURF_LOCKED 0x04000000 /* The shared surface is locked. */
/* Available for GAL_SetVideoMode() */
#define GAL_ANYFORMAT 0x10000000 /* Allow any video depth/pixel-format */
@@ -655,11 +657,11 @@ GAL_Surface *GAL_CreateSurfaceForZNodeAs (const GAL_Surface* ref_surf,
void GAL_FreeSharedSurfaceData (GAL_Surface *surface);
/* Attach to a shared RGB surface. */
GAL_Surface *GAL_AttachSharedRGBSurface (int fd, size_t map_size,
Uint32 flags, BOOL with_wr);
GAL_Surface *GAL_AttachSharedRGBSurface (GAL_VideoDevice* video,
int fd, size_t map_size, Uint32 flags, BOOL with_wr);
/* Dettach from a shared RGB surface from the specific video device. */
void GAL_DettachSharedSurfaceData (GAL_Surface *surface);
/* Detach from a shared RGB surface from the specific video device. */
void GAL_DetachSharedSurfaceData (GAL_Surface *surface);
/* Create a cursor surface from the specific video device. */
GAL_Surface* GAL_CreateCursorSurface (GAL_VideoDevice* video,
+4 -2
View File
@@ -837,7 +837,8 @@ static int srvAllocZOrderNode (int cli, HWND hwnd, HWND main_win,
surf->refcount++;
}
else if (fd >= 0) {
surf = GAL_AttachSharedRGBSurface (fd, surf_size, surf_flags, TRUE);
surf = GAL_AttachSharedRGBSurface (NULL, fd,
surf_size, surf_flags, TRUE);
close (fd);
}
else {
@@ -994,7 +995,8 @@ static int srvMoveWindow (int cli, int idx_znode, const RECT* rcWin,
surf->refcount++;
}
else {
surf = GAL_AttachSharedRGBSurface (fd, surf_size, surf_flags, TRUE);
surf = GAL_AttachSharedRGBSurface (NULL, fd,
surf_size, surf_flags, TRUE);
close (fd);
}
+2 -1
View File
@@ -1603,7 +1603,8 @@ static int srvStartTrackPopupMenu (int cli, const RECT* rc, HWND ptmi,
surf->refcount++;
}
else if (fd >= 0) {
surf = GAL_AttachSharedRGBSurface (fd, surf_size, surf_flags, TRUE);
surf = GAL_AttachSharedRGBSurface (NULL, fd,
surf_size, surf_flags, TRUE);
close (fd);
}
else {
+3 -3
View File
@@ -299,7 +299,7 @@ ret:
return retval;
}
int __mg_map_insert_ex (map_t* map, const void* key,
map_entry_t* __mg_map_insert_ex2 (map_t* map, const void* key,
const void* val, free_val_fn free_val_alt)
{
map_entry_t **pentry;
@@ -317,7 +317,7 @@ int __mg_map_insert_ex (map_t* map, const void* key,
while (*pentry) {
int ret;
if (map->comp_key)
ret = map->comp_key (key, (*pentry)->key);
else
@@ -354,7 +354,7 @@ int __mg_map_insert_ex (map_t* map, const void* key,
}
UNLOCK_MAP (map);
return 0;
return entry;
}
int __mg_map_find_replace_or_insert (map_t* map, const void* key,
+3 -3
View File
@@ -144,7 +144,7 @@ static int DRM_AllocSharedHWSurface(_THIS, GAL_Surface *surface,
static int DRM_FreeSharedHWSurface(_THIS, GAL_Surface *surface);
static int DRM_AttachSharedHWSurface(_THIS, GAL_Surface *surface,
int prime_fd, size_t mapsize, BOOL with_rw);
static int DRM_DettachSharedHWSurface(_THIS, GAL_Surface *surface);
static int DRM_DetachSharedHWSurface(_THIS, GAL_Surface *surface);
static int DRM_SetCursor(_THIS, GAL_Surface *surface, int hot_x, int hot_y);
static int DRM_MoveCursor(_THIS, int x, int y);
@@ -1410,7 +1410,7 @@ static GAL_VideoDevice *DRM_CreateDevice(int devindex)
device->AllocSharedHWSurface = DRM_AllocSharedHWSurface;
device->FreeSharedHWSurface = DRM_FreeSharedHWSurface;
device->AttachSharedHWSurface = DRM_AttachSharedHWSurface;
device->DettachSharedHWSurface = DRM_DettachSharedHWSurface;
device->DetachSharedHWSurface = DRM_DetachSharedHWSurface;
}
#endif /* IS_COMPOSITING_SCHEMA */
@@ -3127,7 +3127,7 @@ error:
return retval;
}
static int DRM_DettachSharedHWSurface(_THIS, GAL_Surface *surface)
static int DRM_DetachSharedHWSurface(_THIS, GAL_Surface *surface)
{
int retval = -1;
DrmVideoData* vdata = this->hidden;
+1 -1
View File
@@ -247,7 +247,7 @@ static GAL_Surface* create_wp_surface(GAL_Surface* screen)
_DBG_PRINTF ("REQID_GETSHAREDSURFACE: size (%lu), flags (0x%x), fd: %d\n",
info.size, info.flags, fd);
wp_surf = GAL_AttachSharedRGBSurface (fd, info.size,
wp_surf = GAL_AttachSharedRGBSurface (NULL, fd, info.size,
info.flags, TRUE);
close (fd);
+15 -14
View File
@@ -68,7 +68,7 @@
/*
* Create a shared empty RGB surface of the appropriate depth and pixel format
*/
GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video,
GAL_Surface *GAL_CreateSharedRGBSurface (GAL_VideoDevice *video,
Uint32 flags, Uint32 rw_modes, int width, int height, int depth,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
{
@@ -337,10 +337,9 @@ void GAL_FreeSharedSurfaceData (GAL_Surface *surface)
/*
* Attach to a shared RGB surface
*/
GAL_Surface * GAL_AttachSharedRGBSurface (int fd, size_t map_size,
Uint32 flags, BOOL with_wr)
GAL_Surface * GAL_AttachSharedRGBSurface (GAL_VideoDevice *video,
int fd, size_t map_size, Uint32 flags, BOOL with_wr)
{
GAL_VideoDevice *video = NULL;
GAL_Surface *surface;
void* data_map = MAP_FAILED;
GAL_SharedSurfaceHeader* hdr;
@@ -362,11 +361,10 @@ GAL_Surface * GAL_AttachSharedRGBSurface (int fd, size_t map_size,
goto error;
}
if ((flags & GAL_HWSURFACE) == GAL_HWSURFACE) {
video = __mg_current_video;
}
else {
video = NULL;
if (video == NULL) {
if ((flags & GAL_HWSURFACE) == GAL_HWSURFACE) {
video = __mg_current_video;
}
}
surface->video = video;
@@ -439,14 +437,17 @@ GAL_Surface * GAL_AttachSharedRGBSurface (int fd, size_t map_size,
goto error;
}
/* Since 5.2.0 */
surface->flags |= GAL_SSURF_ATTACHED;
/* The surface is ready to go */
surface->refcount = 1;
return (surface);
error:
if (video && surface && surface->hwdata) {
assert (video->DettachSharedHWSurface);
video->DettachSharedHWSurface (video, surface);
assert (video->DetachSharedHWSurface);
video->DetachSharedHWSurface (video, surface);
}
else if (data_map != MAP_FAILED) {
munmap (data_map, map_size);
@@ -462,15 +463,15 @@ error:
/*
* Free data of a shared surface created by the above function.
*/
void GAL_DettachSharedSurfaceData (GAL_Surface *surface)
void GAL_DetachSharedSurfaceData (GAL_Surface *surface)
{
GAL_VideoDevice *video = surface->video;
assert (surface->shared_header);
if (video && surface->hwdata) {
assert (video->DettachSharedHWSurface);
video->DettachSharedHWSurface (video, surface);
assert (video->DetachSharedHWSurface);
video->DetachSharedHWSurface (video, surface);
surface->hwdata = NULL;
}
else {
+3 -3
View File
@@ -1836,10 +1836,10 @@ void GAL_FreeSurface (GAL_Surface *surface)
}
if (surface->shared_header) {
if (surface->shared_header->creator == getpid())
GAL_FreeSharedSurfaceData(surface);
if (surface->flags & GAL_SSURF_ATTACHED)
GAL_DetachSharedSurfaceData(surface);
else
GAL_DettachSharedSurfaceData(surface);
GAL_FreeSharedSurfaceData(surface);
surface->hwdata = NULL;
surface->pixels = NULL;
+2 -2
View File
@@ -174,10 +174,10 @@ struct GAL_VideoDevice {
int (*AttachSharedHWSurface)(_THIS, GAL_Surface *surface,
int prime_fd, size_t mapsize, BOOL with_rw);
/* Dettach from a shared surface in hardware video memory.
/* Detach from a shared surface in hardware video memory.
Set to NULL if no hardware shared surface supported.
Return 0 if success, otherwise -1. */
int (*DettachSharedHWSurface)(_THIS, GAL_Surface *surface);
int (*DetachSharedHWSurface)(_THIS, GAL_Surface *surface);
/* Allocate a dumb surface from hardware.
Set to NULL if dumb surface is not supported.
+2 -26
View File
@@ -3346,8 +3346,8 @@ HDC GUIAPI CreateMemDCEx (int width, int height, int depth, DWORD flags,
return (HDC)pmem_dc;
}
/* Since 5.0.0 */
HDC CreateMemDCFromSurface (GAL_Surface* surface)
/* Since 5.0.0; exported as API since 5.2.0 */
HDC GUIAPI CreateMemDCFromSurface (HSURF surface)
{
PDC pmem_dc = NULL;
@@ -3391,29 +3391,6 @@ struct GAL_Surface* GetSurfaceFromDC (HDC hdc)
return pdc->surface;
}
#ifdef _MGSCHEMA_COMPOSITING
HDC GUIAPI CreateMemDCFromSharedSurfaceFD (int fd)
{
HDC memdc = HDC_INVALID;
GAL_Surface* surf;
surf = GAL_AttachSharedRGBSurface (fd, 0, GAL_HWSURFACE, TRUE);
if (surf) {
memdc = CreateMemDCFromSurface (surf);
if (memdc == HDC_INVALID) {
GAL_FreeSurface(surf);
_ERR_PRINTF("failed to create memory dc from surface: %p\n", surf);
}
}
else {
_ERR_PRINTF("failed to attach to surface buffer via fd: %d\n", fd);
}
return memdc;
}
#endif /* _MGSCHEMA_COMPOSITING */
HDC GUIAPI CreateSubMemDC (HDC parent, int off_x, int off_y,
int width, int height, BOOL comp_to_parent)
{
@@ -3438,7 +3415,6 @@ HDC GUIAPI CreateSubMemDC (HDC parent, int off_x, int off_y,
if (width < 0) width = 0;
if (height < 0) height = 0;
if (off_x + width > pdc_parent->DevRC.right)
width = pdc_parent->DevRC.right - off_x;
if (off_y + height > pdc_parent->DevRC.bottom)
+130 -2
View File
@@ -170,8 +170,17 @@ BOOL GUIAPI DestroySharedSurface(HSURF surf)
goto failed;
}
if (surf->shared_header->creator == getpid() &&
surf->shared_header->name[0]) {
if (surf->flags & GAL_SSURF_ATTACHED) {
_ERR_PRINTF("INVALID_CALL: surface is created by attaching: %p\n", surf);
goto failed;
}
if (surf->shared_header->creator != getpid()) {
_ERR_PRINTF("INVALID_CALL: surface is not created by current process: %p\n", surf);
goto failed;
}
if (surf->shared_header->name[0]) {
/* This is a named shared surface created by this client */
OPERATENSSURFINFO nssurf_req = {};
@@ -278,5 +287,124 @@ int GUIAPI GetSharedSurfaceFDByName(const char *name,
return get_shared_surface(itn_name, map_size, flags);
}
HSURF GUIAPI AttachToSharedSurface(GHANDLE video, int fd,
size_t map_size, DWORD flags)
{
return GAL_AttachSharedRGBSurface(video, fd, map_size, flags, TRUE);
}
const char *GUIAPI GetSharedSurfaceInfo(HSURF surf, int *fd,
SIZE *size, int *pitch, size_t *map_size, off_t *pixels_off)
{
if (surf->shared_header == NULL) {
_ERR_PRINTF("INVALID_ARG: surface handle: %p\n", surf);
goto failed;
}
if (fd) {
*fd = surf->shared_header->fd;
}
if (size) {
size->cx = surf->shared_header->width;
size->cy = surf->shared_header->height;
}
if (pitch) {
*pitch = surf->shared_header->pitch;
}
if (map_size) {
*map_size = surf->shared_header->map_size;
}
if (pixels_off) {
*pixels_off = surf->shared_header->pixels_off;
}
return surf->shared_header->name;
failed:
return NULL;
}
BOOL GUIAPI LockSharedSurfaceIfDirty(HSURF surf,
unsigned old_dirty_age, unsigned *dirty_age,
int *nr_dirty_rcs, const RECT **dirty_rcs)
{
if (surf->shared_header == NULL) {
_ERR_PRINTF("INVALID_ARG: surface handle: %p\n", surf);
goto failed;
}
if (surf->flags & GAL_SSURF_LOCKED) {
_ERR_PRINTF("INVALID_CALL: surface locked: %p\n", surf);
goto failed;
}
/* FIXME: use atomic types */
if (old_dirty_age != surf->shared_header->dirty_info.dirty_age) {
LOCK_SURFACE_SEM(surf->shared_header->sem_num);
surf->flags |= GAL_SSURF_LOCKED;
*dirty_age = surf->shared_header->dirty_info.dirty_age;
if (nr_dirty_rcs) {
*nr_dirty_rcs = surf->shared_header->dirty_info.nr_dirty_rcs;
}
if (dirty_rcs) {
*dirty_rcs = surf->shared_header->dirty_info.dirty_rcs;
}
}
return TRUE;
failed:
return FALSE;
}
BOOL GUIAPI UnlockSharedSurface(HSURF surf, BOOL clear_dirty)
{
if (surf->shared_header == NULL) {
_ERR_PRINTF("INVALID_ARG: surface handle: %p\n", surf);
goto failed;
}
if (!(surf->flags & GAL_SSURF_LOCKED)) {
_ERR_PRINTF("INVALID_CALL: surface is not locked: %p\n", surf);
goto failed;
}
if (clear_dirty) {
surf->dirty_info->nr_dirty_rcs = 0;
}
UNLOCK_SURFACE_SEM(surf->shared_header->sem_num);
surf->flags &= ~GAL_SSURF_LOCKED;
return TRUE;
failed:
return FALSE;
}
BOOL GUIAPI DetachFromSharedSurface(HSURF surf)
{
if (surf->shared_header == NULL) {
_ERR_PRINTF("INVALID_ARG: not a shared surface: %p\n", surf);
goto failed;
}
if (!(surf->flags & GAL_SSURF_ATTACHED)) {
_ERR_PRINTF("INVALID_CALL: surface was not created by attaching: %p\n", surf);
goto failed;
}
GAL_FreeSurface(surf);
return TRUE;
failed:
return FALSE;
}
#endif /* defined _MGSCHEMA_COMPOSITING */
+25 -12
View File
@@ -788,18 +788,10 @@ struct nssurf_info {
size_t map_size;
};
static void my_free_val(void *val)
{
struct nssurf_info *nssurf_info = val;
if (nssurf_info->fd >= 0)
close(nssurf_info->fd);
free(val);
}
int __mg_nssurf_map_new(void)
{
__nssurf_map = __mg_map_create(copy_key_string,
free_key_string, NULL, my_free_val, comp_key_string);
free_key_string, NULL, NULL, comp_key_string);
if (__nssurf_map == NULL)
return -1;
@@ -809,9 +801,27 @@ int __mg_nssurf_map_new(void)
void __mg_nssurf_map_delete(void)
{
assert(__nssurf_map);
int sz = __mg_map_get_size(__nssurf_map);
if (sz > 0) {
_WRN_PRINTF("There are still not freed named shared surface(s): %d\n", sz);
}
__mg_map_destroy(__nssurf_map);
}
static void release_nssurf_info(void *res)
{
map_entry_t *entry;
entry = __mg_map_find(__nssurf_map, res);
if (entry) {
struct nssurf_info *nssurf_info = entry->val;
if (nssurf_info->fd >= 0)
close(nssurf_info->fd);
free(nssurf_info);
__mg_map_erase(__nssurf_map, res);
}
}
int __mg_nssurf_map_operate_srv(const OPERATENSSURFINFO* req_info,
int cli, int fd)
{
@@ -831,10 +841,14 @@ int __mg_nssurf_map_operate_srv(const OPERATENSSURFINFO* req_info,
nssurf_info->creator = cli;
nssurf_info->fd = -1;
nssurf_info->map_size = 0;
if (__mg_map_insert(__nssurf_map, req_info->name, nssurf_info)) {
entry = __mg_map_insert_ex2(__nssurf_map, req_info->name,
nssurf_info, NULL);
if (entry == NULL) {
free(nssurf_info);
goto done;
}
add_global_res(cli, __nssurf_map, entry->key, release_nssurf_info);
break;
case ID_NAMEDSSURFOP_SET:
@@ -865,8 +879,7 @@ int __mg_nssurf_map_operate_srv(const OPERATENSSURFINFO* req_info,
if (nssurf_info->creator != cli)
goto done;
if (__mg_map_erase(__nssurf_map, req_info->name))
goto done;
del_global_res(cli, __nssurf_map, entry->key);
result = 0;
break;