xpra icon
Bug tracker and wiki

Ticket #475: xshm-fixleak.patch

File xshm-fixleak.patch, 1.6 KB (added by Antoine Martin, 7 years ago)

this seems to fix the leak

  • xpra/x11/bindings/ximage.pyx

     
    4343        pass
    4444    key_t IPC_PRIVATE
    4545    int IPC_CREAT
     46    int IPC_RMID
    4647
    4748cdef extern from "sys/shm.h":
    4849    int shmget(key_t __key, size_t __size, int __shmflg)
    4950    void *shmat(int __shmid, const void *__shmaddr, int __shmflg)
    5051    int shmdt (const void *__shmaddr)
     52    ctypedef struct shmid_ds:
     53        pass
     54    int shmctl(int shmid, int cmd, shmid_ds *buf)
    5155
    5256cdef extern from "errno.h" nogil:
    5357    int errno
     
    99103        int map_entries
    100104
    101105
     106    void XSync(Display * display, Bool discard)
     107
    102108    int XFree(void * data)
    103109
    104110    Bool XQueryExtension(Display * display, char *name,
     
    463469        xshm_debug("XShmWrapper.free() has_shm=%s", has_shm)
    464470        if has_shm:
    465471            XShmDetach(self.display, &self.shminfo)
     472        xshm_debug("XShmWrapper.free() image=%s", hex(<unsigned long> self.image))
     473        if self.image!=NULL:
     474            XDestroyImage(self.image)
     475            self.image = NULL
     476            XSync(self.display, False)
    466477        if has_shm:
     478            shmctl(self.shminfo.shmid, IPC_RMID, NULL)
    467479            shmdt(self.shminfo.shmaddr)
    468480            self.shminfo.shmaddr = <char *> -1
    469         if self.image!=NULL:
    470             XDestroyImage(self.image)
    471             self.image = NULL
     481            self.shminfo.shmid = -1
     482            XSync(self.display, False)
    472483
    473484
    474485cdef class XShmImageWrapper(XImageWrapper):