Exemplo n.º 1
0
VNCServer::Client::~Client()
{
	//Close just in case
	Close();

	if (cl->prev)
		cl->prev->next = cl->next;
	else
		cl->screen->clientHead = cl->next;
	if (cl->next)
		cl->next->prev = cl->prev;

	if (cl->scaledScreen!=NULL)
		cl->scaledScreen->scaledScreenRefCount--;

#ifdef LIBVNCSERVER_HAVE_LIBZ
	rfbFreeZrleData(cl);
#endif

	rfbFreeUltraData(cl);

	/* free buffers holding pixel data before and after encoding */
	free(cl->beforeEncBuf);
	free(cl->afterEncBuf);


	free(cl->host);

#ifdef LIBVNCSERVER_HAVE_LIBZ
	/* Release the compression state structures if any. */
	if ( cl->compStreamInited )
		deflateEnd( &(cl->compStream) );

#ifdef LIBVNCSERVER_HAVE_LIBJPEG
	for (int i = 0; i < 4; i++)
		if (cl->zsActive[i])
			deflateEnd(&cl->zsStruct[i]);
#endif
#endif

	if (cl->screen->pointerClient == cl) cl->screen->pointerClient = NULL;

	if (cl->modifiedRegion) sraRgnDestroy(cl->modifiedRegion);
	if (cl->requestedRegion) sraRgnDestroy(cl->requestedRegion);
	if (cl->copyRegion) sraRgnDestroy(cl->copyRegion);

	if (cl->translateLookupTable) free(cl->translateLookupTable);

	TINI_COND(cl->updateCond);
	TINI_MUTEX(cl->updateMutex);

	rfbPrintStats(cl);
	rfbResetStats(cl);

	//Free mem
	free(cl);
}
Exemplo n.º 2
0
void rfbScreenCleanup(rfbScreenInfoPtr rfbScreen)
{
  rfbClientIteratorPtr i=rfbGetClientIterator(rfbScreen);
  rfbClientPtr cl,cl1=rfbClientIteratorNext(i);
  while(cl1) {
    cl=rfbClientIteratorNext(i);
    rfbClientConnectionGone(cl1);
    cl1=cl;
  }
  rfbReleaseClientIterator(i);
    
  /* TODO: hang up on all clients and free all reserved memory */
#define FREE_IF(x) if(rfbScreen->x) free(rfbScreen->x)
  FREE_IF(colourMap.data.bytes);
  FREE_IF(underCursorBuffer);
  TINI_MUTEX(rfbScreen->cursorMutex);
  free(rfbScreen);
}
Exemplo n.º 3
0
void rfbScreenCleanup(rfbScreenInfoPtr screen)
{
  rfbClientIteratorPtr i=rfbGetClientIterator(screen);
  rfbClientPtr cl,cl1=rfbClientIteratorNext(i);
  while(cl1) {
    cl=rfbClientIteratorNext(i);
    rfbClientConnectionGone(cl1);
    cl1=cl;
  }
  rfbReleaseClientIterator(i);
    
#define FREE_IF(x) if(screen->x) free(screen->x)
  FREE_IF(colourMap.data.bytes);
  FREE_IF(underCursorBuffer);
  TINI_MUTEX(screen->cursorMutex);
  if(screen->cursor && screen->cursor->cleanup)
    rfbFreeCursor(screen->cursor);

  rfbRRECleanup(screen);
  rfbCoRRECleanup(screen);
  rfbUltraCleanup(screen);
#ifdef LIBVNCSERVER_HAVE_LIBZ
  rfbZlibCleanup(screen);
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
  rfbTightCleanup(screen);
#endif

  /* free all 'scaled' versions of this screen */
  while (screen->scaledScreenNext!=NULL)
  {
      rfbScreenInfoPtr ptr;
      ptr = screen->scaledScreenNext;
      screen->scaledScreenNext = ptr->scaledScreenNext;
      free(ptr->frameBuffer);
      free(ptr);
  }

#endif
  free(screen);
}