Exemplo n.º 1
0
void
freerdp_chanman_free(rdpChanMan * chan_man)
{
	rdpChanManList * list;
	rdpChanManList * prev;

	SEMAPHORE_DESTROY(chan_man->sem);
	SEMAPHORE_DESTROY(chan_man->sem_event);
#ifdef _WIN32
	if (chan_man->chan_event)
	{
		CloseHandle(chan_man->chan_event);
		chan_man->chan_event = 0;
	}
#else
	if (chan_man->pipe_fd[0] != -1)
	{
		close(chan_man->pipe_fd[0]);
		chan_man->pipe_fd[0] = -1;
	}
	if (chan_man->pipe_fd[1] != -1)
	{
		close(chan_man->pipe_fd[1]);
		chan_man->pipe_fd[1] = -1;
	}
#endif

	/* Remove from global list */
	MUTEX_LOCK(g_mutex_list);
	for (prev = NULL, list = g_chan_man_list; list; prev = list, list = list->next)
	{
		if (list->chan_man == chan_man)
		{
			break;
		}
	}
	if (list)
	{
		if (prev)
		{
			prev->next = list->next;
		}
		else
		{
			g_chan_man_list = list->next;
		}
		free(list);
	}
	MUTEX_UNLOCK(g_mutex_list);

	free(chan_man);
}
Exemplo n.º 2
0
void msocket_server_destroy(msocket_server_t *self){
#ifndef _WIN32
   void *result;
#endif

   if(self != 0){
      if(self->acceptSocket != 0){
         msocket_close(self->acceptSocket);
#ifdef _WIN32
      WaitForSingleObject( self->acceptThread, INFINITE );
      CloseHandle( self->acceptThread );
#else
     pthread_join(self->acceptThread,&result);
#endif
      }
      MUTEX_LOCK(self->mutex);
      self->cleanupStop = 1;
      MUTEX_UNLOCK(self->mutex);
#ifdef _WIN32
      WaitForSingleObject( self->cleanupThread, INFINITE );
      CloseHandle( self->cleanupThread );
#else
      pthread_join(self->cleanupThread,&result);
#endif
      adt_ary_destroy(&self->cleanupItems);
      SEMAPHORE_DESTROY(self->sem);
      MUTEX_DESTROY(self->mutex);
      if(self->udpAddr != 0){
         free(self->udpAddr);
      }
      if(self->socketPath != 0){
#ifdef _WIN32
            _unlink(self->socketPath);
#else
            unlink(self->socketPath);
#endif
         free(self->socketPath);
      }
   }
}