Exemplo n.º 1
0
static void
crSDPFree( CRConnection *conn, void *buf )
{
	CRSDPBuffer *sdp_buffer = (CRSDPBuffer *) buf - 1;

	CRASSERT( sdp_buffer->magic == CR_SDP_BUFFER_MAGIC );
	conn->recv_credits += sdp_buffer->len;

	switch ( sdp_buffer->kind )
	{
	case CRSDPMemory:
#ifdef CHROMIUM_THREADSAFE
		crLockMutex(&cr_sdp.mutex);
#endif
		if (cr_sdp.bufpool) {
			/* pool may have been deallocated just a bit earlier in response
			 * to a SIGPIPE (Broken Pipe) signal.
			 */
			crBufferPoolPush( cr_sdp.bufpool, sdp_buffer, sdp_buffer->allocated );
		}
#ifdef CHROMIUM_THREADSAFE
		crUnlockMutex(&cr_sdp.mutex);
#endif
		break;

	case CRSDPMemoryBig:
		crFree( sdp_buffer );
		break;

	default:
		crError( "Weird buffer kind trying to free in crSDPFree: %d", sdp_buffer->kind );
	}
}
Exemplo n.º 2
0
static void _crVBoxHGSMIFree(CRConnection *conn, void *buf)
{
    CRVBOXHGSMIBUFFER *hgsmi_buffer = (CRVBOXHGSMIBUFFER *) buf - 1;

    CRASSERT(hgsmi_buffer->magic == CR_VBOXHGSMI_BUFFER_MAGIC);

    if (hgsmi_buffer->bIsBuf)
    {
        PVBOXUHGSMI_BUFFER pBuf = hgsmi_buffer->pBuffer;
        PCRVBOXHGSMI_CLIENT pClient = (PCRVBOXHGSMI_CLIENT)pBuf->pvUserData;
        pBuf->pfnUnlock(pBuf);
        _crVBoxHGSMIBufFree(pClient, pBuf);
    }
    else
    {
        /*@todo wrong len for redir buffers*/
        conn->recv_credits += hgsmi_buffer->u32Len;

#ifdef CHROMIUM_THREADSAFE
            crLockMutex(&g_crvboxhgsmi.mutex);
#endif
            crBufferPoolPush(g_crvboxhgsmi.mempool, hgsmi_buffer, hgsmi_buffer->cbLock);
#ifdef CHROMIUM_THREADSAFE
            crUnlockMutex(&g_crvboxhgsmi.mutex);
#endif
    }
}
Exemplo n.º 3
0
static void
crFileFree( CRConnection *conn, void *buf )
{
	CRFileBuffer *file_buffer = (CRFileBuffer *) buf - 1;

	CRASSERT( file_buffer->magic == CR_FILE_BUFFER_MAGIC );
	conn->recv_credits += file_buffer->len;

	switch ( file_buffer->kind )
	{
		case CRFileMemory:
#ifdef CHROMIUM_THREADSAFE
			crLockMutex(&cr_file.mutex);
#endif
			crBufferPoolPush( cr_file.bufpool, file_buffer, conn->buffer_size );
#ifdef CHROMIUM_THREADSAFE
			crUnlockMutex(&cr_file.mutex);
#endif
			break;

		case CRFileMemoryBig:
			crFree( file_buffer );
			break;

		default:
			crError( "Weird buffer kind trying to free in crFileFree: %d", file_buffer->kind );
	}
}
Exemplo n.º 4
0
static void
crSDPSend( CRConnection *conn, void **bufp,
           const void *start, unsigned int len )
{
	CRSDPBuffer *sdp_buffer;
	unsigned int      *lenp;
  
	if ( !conn || conn->type == CR_NO_CONNECTION )
		return;
  
	if ( bufp == NULL )
	{
		/* we are doing synchronous sends from user memory, so no need
		 * to get fancy.  Simply write the length & the payload and
		 * return. */
		const int sendable_len = conn->swap ? SWAP32(len) : len;
    
		crSDPWriteExact( conn, &sendable_len, sizeof(len) );
		if ( !conn || conn->type == CR_NO_CONNECTION) return;
		crSDPWriteExact( conn, start, len );
		return;
	}
	sdp_buffer = (CRSDPBuffer *)(*bufp) - 1;
  
	CRASSERT( sdp_buffer->magic == CR_SDP_BUFFER_MAGIC );
  
	/* All of the buffers passed to the send function were allocated
	 * with crSDPAlloc(), which includes a header with a 4 byte
	 * length field, to insure that we always have a place to write
	 * the length field, even when start == *bufp. */
	lenp = (unsigned int *) start - 1;
	if (conn->swap)
	{
		*lenp = SWAP32(len);
	}
	else
	{
		*lenp = len;
	}
  
	if ( __sdp_write_exact( conn->sdp_socket, lenp, len + sizeof(int) ) < 0 )
	{
		__sdp_dead_connection( conn );
	}
	/* reclaim this pointer for reuse and try to keep the client from
		 accidentally reusing it directly */
#ifdef CHROMIUM_THREADSAFE
	crLockMutex(&cr_sdp.mutex);
#endif
	crBufferPoolPush( cr_sdp.bufpool, sdp_buffer, sdp_buffer->allocated );
	/* Since the buffer's now in the 'free' buffer pool, the caller can't
	 * use it any more.  Setting bufp to NULL will make sure the caller
	 * doesn't try to re-use the buffer.
	 */
	*bufp = NULL;
#ifdef CHROMIUM_THREADSAFE
	crUnlockMutex(&cr_sdp.mutex);
#endif
}
Exemplo n.º 5
0
/*
 * Put the given buffer list into the free buffer pool.  We do this when
 * we've finished rendering a frame and no longer need the buffer list.
 */
void hiddenlineReclaimPackBuffer( BufList *bl )
{
	if (bl->can_reclaim)
	{
		GET_CONTEXT(context);
		crBufferPoolPush( context->bufpool, bl->buf, hiddenline_spu.buffer_size );
	}
	else
	{
		crPackFree( bl->buf );
	}
}
Exemplo n.º 6
0
static void
crFileSend( CRConnection *conn, void **bufp, const void *start, unsigned int len )
{
	CRFileBuffer *file_buffer;
	unsigned int      *lenp;

	if ( bufp == NULL )
	{
		/* we are doing synchronous sends from user memory, so no need
		 * to get fancy.  Simply write the length & the payload and
		 * return. */
		if (conn->swap)
		{
			len = SWAP32(len);
		}
		crFileWriteExact( conn, &len, sizeof(len) );
		crFileWriteExact( conn, start, len );
		return;
	}

	file_buffer = (CRFileBuffer *)(*bufp) - 1;

	CRASSERT( file_buffer->magic == CR_FILE_BUFFER_MAGIC );

	/* All of the buffers passed to the send function were allocated
	 * with crFileAlloc(), which includes a header with a 4 byte
	 * length field, to insure that we always have a place to write
	 * the length field, even when start == *bufp. */
	lenp = (unsigned int *) start - 1;
	*lenp = len;

	crFileWriteExact(conn, lenp, len + sizeof(int) );

	/* reclaim this pointer for reuse and try to keep the client from
		 accidentally reusing it directly */
#ifdef CHROMIUM_THREADSAFE
	crLockMutex(&cr_file.mutex);
#endif
	crBufferPoolPush( cr_file.bufpool, file_buffer, conn->buffer_size );
#ifdef CHROMIUM_THREADSAFE
	crUnlockMutex(&cr_file.mutex);
#endif
	*bufp = NULL;
}
Exemplo n.º 7
0
static void _crVBoxHGSMIBufFree(PCRVBOXHGSMI_CLIENT pClient, PVBOXUHGSMI_BUFFER pBuf)
{
    crBufferPoolPush(pClient->bufpool, pBuf, pBuf->cbBuffer);
}