-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathctable.h
More file actions
97 lines (84 loc) · 2.19 KB
/
ctable.h
File metadata and controls
97 lines (84 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
* interface and data structures for table holding connection records
*
* ctable_init(), ctable_lock() assume that the table is not locked
* ctable_getMutex() works independent of lock status
* all other methods assume that the table has previously been locked via a
* call to ctable_lock()
*/
#ifndef _CTABLE_H_INCLUDED_
#define _CTABLE_H_INCLUDED_
#include "endpoint.h"
#include "crecord.h"
#include <pthread.h>
/*
* lock the connection table
*/
void ctable_lock(void);
/*
* unlock the connection table
*/
void ctable_unlock(void);
/*
* return the address of the table mutex
* needed by crecord_create()
*/
pthread_mutex_t *ctable_getMutex(void);
/*
* initialize the data structures for holding connection records
*/
void ctable_init(void);
/*
* issue a new subport for this process
*/
unsigned long ctable_newSubport(void);
/*
* insert a connection record
*/
void ctable_insert(CRecord *cr);
/*
* lookup the connection record associated with a particular endpoint
*
* if successful, returns the associated connection record
* if not, returns NULL
*/
CRecord *ctable_lookup(RpcEndpoint *ep);
/*
* remove a connection record
*
* there is no return value
*/
void ctable_remove(CRecord *cr);
/*
* scan table for timer-based processing
*
* for each connection
* if ST_TIMEDOUT, thread onto purge list
* elsif CONNECT_SENT|QUERY_SENT|RESPONSE_SENT|DISCONNECT_SENT|FRAGMENT_SENT
* decrement ticksLeft
* if reach 0
* decrement nattempts
* if reach 0
* thread CRecord onto timed linked list
* else
* double ticks
* set ticksLeft to ticks
* thread CRecord onto retry linked list
* else
* decrement ticksTilPing
* if reach 0, thread onto ping list
* decrement pingsTilPurge
* if reach 0
* thread Crecord onto timed linked list
* else
* reset ticksTilPing
* thread CRecord onto ping linked list
* return retry, timed, ping and purge linked lists
*/
void ctable_scan(CRecord **retry, CRecord **timed, CRecord **ping, CRecord **purge);
/*
* purge all entries from the table
*/
void ctable_purge(void);
void ctable_dump(char *str);
#endif /* _CTABLE_H_INCLUDED_ */