rx-race-condition-cleanup-by-adding-busy-status-20010605
[openafs.git] / src / rx / rx_multi.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #ifndef _RX_MULTI_
11 #define _RX_MULTI_
12
13 #ifdef  KERNEL
14 #include "../rx/rx.h"
15 #else /* KERNEL */
16 # include "rx.h"
17 #endif /* KERNEL */
18
19 struct multi_handle {
20     int nConns;
21     struct rx_call **calls;
22     short *ready;
23     short nReady;        /* XXX UNALIGNED */
24     short *nextReady;
25     short *firstNotReady;
26 #ifdef RX_ENABLE_LOCKS
27     afs_kmutex_t lock;
28     afs_kcondvar_t cv;
29 #endif /* RX_ENABLE_LOCKS */
30 };
31
32 extern struct multi_handle *multi_Init();
33 extern int multi_Select();
34 extern void multi_Finalize();
35
36 #define multi_Rx(conns, nConns) \
37     do {\
38         register struct multi_handle *multi_h;\
39         register int multi_i;\
40         register struct rx_call *multi_call;\
41         multi_h = multi_Init(conns, nConns);\
42         for (multi_i = 0; multi_i < nConns; multi_i++)
43
44 #define multi_Body(startProc, endProc)\
45         multi_call = multi_h->calls[multi_i];\
46         startProc;\
47         rx_FlushWrite(multi_call);\
48         }\
49         while ((multi_i = multi_Select(multi_h)) >= 0) {\
50             register afs_int32 multi_error;\
51             multi_call = multi_h->calls[multi_i];\
52             multi_error = rx_EndCall(multi_call, endProc);\
53             multi_h->calls[multi_i] = (struct rx_call *) 0
54
55 #define multi_Abort break
56
57 #define multi_End\
58         multi_Finalize(multi_h);\
59     } while (0)
60
61 /* Ignore remaining multi RPC's */
62 #define multi_End_Ignore\
63         multi_Finalize_Ignore(multi_h);\
64     } while (0)
65
66 #endif /* _RX_MULTI_     End of rx_multi.h */