xref: /haiku/src/add-ons/kernel/file_systems/nfs/RPCPendingCalls.h (revision f4783a9fb9129819d76ecd61907238780345ea9c)
1 #ifndef _RPCPENDINGCALLS_H
2 
3 #define _RPCPENDINGCALLS_H
4 
5 #include <malloc.h>
6 #include <OS.h>
7 #include <sys/socket.h>
8 #include <netinet/in.h>
9 
10 struct SemaphorePool
11 {
12 	sem_id *fPool;
13 	int32 fPoolCount;
14 	int32 fPoolSize;
15 	sem_id fPoolSem;
16 };
17 
18 void SemaphorePoolInit (struct SemaphorePool *pool);
19 void SemaphorePoolDestroy (struct SemaphorePool *pool);
20 sem_id SemaphorePoolGet(struct SemaphorePool *pool);
21 void SemaphorePoolPut (struct SemaphorePool *pool, sem_id sem);
22 
23 struct PendingCall
24 {
25 	struct PendingCall *next;
26 
27 	sem_id sem;
28 	struct sockaddr_in addr;
29 	int32 xid;
30 	uint8 *buffer;
31 };
32 
33 void PendingCallInit (struct PendingCall *call);
34 void PendingCallDestroy (struct PendingCall *call);
35 
36 struct RPCPendingCalls
37 {
38 	struct PendingCall *fFirst;
39 	sem_id fSem;
40 	struct SemaphorePool fPool;
41 };
42 
43 void RPCPendingCallsInit (struct RPCPendingCalls *calls);
44 void RPCPendingCallsDestroy (struct RPCPendingCalls *calls);
45 
46 struct PendingCall *RPCPendingCallsAddPendingCall (struct RPCPendingCalls *calls,
47 													int32 xid, const struct sockaddr_in *addr);
48 
49 struct PendingCall *RPCPendingCallsFindAndRemovePendingCall (struct RPCPendingCalls *calls,
50 													int32 xid, const struct sockaddr_in *addr);
51 
52 #endif
53