-
Notifications
You must be signed in to change notification settings - Fork 1
/
lock.h
60 lines (51 loc) · 1.74 KB
/
lock.h
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
/* lock.h - request and grant locks among cloud boxes
*
* Copyright (C) 2012, Greg Johnson
* Released under the terms of the GNU GPL v2.0.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* $Id: lock.h,v 1.6 2012-02-22 18:55:25 greg Exp $
*/
#ifndef LOCK_H
#define LOCK_H
#include "cloud.h"
#include "mac.h"
/* when changing cloud connectivity, boxes can request temporary locks
* on arcs between boxes. these locks time out by themselves if they
* are not released in a timely manner.
*/
typedef struct {
message_type_t type;
long sec, usec;
mac_address_t node_1;
mac_address_t node_2;
stp_beacon_t stp_beacon;
mac_address_t neighbor;
byte repeats;
} lockable_resource_t;
extern lockable_resource_t pending_requests[];
extern int pending_request_count;
/* locks we have given to another node */
extern lockable_resource_t locks_granted[];
extern int locks_granted_count;
/* locks we own */
extern lockable_resource_t locks_owned[];
extern int locks_owned_count;
/* locks we have timed out, for use in routines that do post-processing
* after a lock timeout
*/
extern lockable_resource_t timed_out_lockables[];
extern int timed_out_lockable_count;
extern void timeout_lockable(lockable_resource_t *lock_vector, int *len,
int recv_timeout, char *list_name);
extern void timeout_lockables();
extern void delete_lockable(lockable_resource_t *lock_vector, int *len,
mac_address_ptr_t name);
extern void timeout_locks();
extern void print_lockable_list(lockable_resource_t *list, int list_len,
char *title);
#endif