From 621580d7a8d39ab7beac255d747af9fe6998063a Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Fri, 4 May 2018 14:58:01 +0200 Subject: [PATCH] Proper cleanup on termination of Xvnc/libvnc.so --- unix/xserver/hw/vnc/vncExt.c | 1 + unix/xserver/hw/vnc/vncExtInit.cc | 12 ++++++++++++ unix/xserver/hw/vnc/vncExtInit.h | 1 + 3 files changed, 14 insertions(+) diff --git a/unix/xserver/hw/vnc/vncExt.c b/unix/xserver/hw/vnc/vncExt.c index f7ba9fa8..fd65eab6 100644 --- a/unix/xserver/hw/vnc/vncExt.c +++ b/unix/xserver/hw/vnc/vncExt.c @@ -585,6 +585,7 @@ static int SProcVncExtDispatch(ClientPtr client) static void vncResetProc(ExtensionEntry* extEntry) { + vncExtensionClose(); } static void vncClientStateChange(CallbackListPtr * l, void * d, void * p) diff --git a/unix/xserver/hw/vnc/vncExtInit.cc b/unix/xserver/hw/vnc/vncExtInit.cc index e4135b3c..d6f6b742 100644 --- a/unix/xserver/hw/vnc/vncExtInit.cc +++ b/unix/xserver/hw/vnc/vncExtInit.cc @@ -262,6 +262,18 @@ void vncExtensionInit(void) vncRegisterBlockHandlers(); } +void vncExtensionClose(void) +{ + try { + for (int scr = 0; scr < vncGetScreenCount(); scr++) { + delete desktop[scr]; + desktop[scr] = NULL; + } + } catch (rdr::Exception& e) { + vncFatalError("vncExtInit: %s",e.str()); + } +} + void vncHandleSocketEvent(int fd, int scrIdx, int read, int write) { desktop[scrIdx]->handleSocketEvent(fd, read, write); diff --git a/unix/xserver/hw/vnc/vncExtInit.h b/unix/xserver/hw/vnc/vncExtInit.h index e8294340..9414723f 100644 --- a/unix/xserver/hw/vnc/vncExtInit.h +++ b/unix/xserver/hw/vnc/vncExtInit.h @@ -48,6 +48,7 @@ extern int vncFbstride[]; extern int vncInetdSock; void vncExtensionInit(void); +void vncExtensionClose(void); void vncHandleSocketEvent(int fd, int scrIdx, int read, int write); void vncCallBlockHandlers(int* timeout); -- 2.39.5