rvsharer.h

来自「h.248协议源码」· C头文件 代码 · 共 109 行

H
109 行
字号

#if (0)
******************************************************************************
Filename    :
Description :
******************************************************************************
                Copyright (c) 1999 RADVision Inc.
************************************************************************
NOTICE:
This document contains information that is proprietary to RADVision LTD.
No part of this publication may be reproduced in any form whatsoever 
without written prior approval by RADVision LTD..

RADVision LTD. reserves the right to revise this publication and make 
changes without obligation to notify any person of such revisions or 
changes.
******************************************************************************
$Revision:$
$Date:$
$Author: S. Cipolli$
******************************************************************************
#endif

#ifndef RV_SHARER_H
#define RV_SHARER_H 


/* The following code implements a socket sharing service required to
   circumvent thread-local socket concept's like PSoS/PNA.  

   The service creates and destroys all sockets from it's thread and
   allows other threads to request socket sharing.  Once a thread has 
   shared a given socket, the information is cached so future references
   to the socket from that thread do not access the service.   
*/

#include "rvtypes.h"
#include "rvhash.h"
#include "rvthread.h"
#include "rvqueue.h"
#include "rvmutex.h"
#include "rvsocket_.h"


/* If RV_DIRTY_SOCKETS is defined, use faster method for sharing sockets. */
/* The downside is that sockets are not actually closed until all tasks */
/* which used them exit, including the user application tasks. This leaves */
/* a large number of unused socket structures floating around. */
#define RV_DIRTY_SOCKETS
   
typedef struct {
	char verb;
	int family;
	int type;
	int proto;
	int sock;
	int task;
} RvSharerCmd;

typedef struct {
	int sock;
	int task;
} RvSharerKey;

#if defined(__cplusplus)
extern "C" {
#endif

RvSharerKey* rvSharerKeyConstruct(RvSharerKey* x, int s, int task);
#define RvSharerKeyConstructCopy(d, s, a)	rvDefaultConstructCopy((d), (s), (a))
#define RvSharerKeyDestruct(x)				rvDefaultDestruct(x)
#define RvSharerKeyEqual(a, b)				(((a)->sock == (b)->sock) && ((a)->task == (b)->task))

#if defined(__cplusplus)
}
#endif

rvDeclareHash(RvSharerKey, int)

typedef struct {
	RvMutex mutex;
	RvThread thread;
	RvQueue server;
	RvQueue client;
	RvHash(RvSharerKey, int) table;
} RvSharer;

#if defined(RV_DIRTY_SOCKETS)
#define rvSharerClose(s)
#else
#define rvSharerClose(s) close(s)
#endif

#if defined(__cplusplus)
extern "C" {
#endif

RvBool rvSharerInit(void);
void rvSharerEnd(void);
int rvSharerCreateSocket(int family, int type, int proto);
int rvSharerDestroySocket(int sock);
int rvSharerShareSocket(int sock);

#if defined(__cplusplus)
}
#endif

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?