HOPS
HOPS class reference
write_lock_mechanism.h
Go to the documentation of this file.
1 #ifndef WRITE_LOCK_MECHANISM_H__
2 #define WRITE_LOCK_MECHANISM_H__
3 
4 #include "fileset.h"
5 
6 //number of chars in lock file name
7 #define MAX_LOCKNAME_LEN 512
8 
9 //wait time allowed before a lock file is declared stale
10 //this is 5 minutes...probably much longer than needed
11 #define LOCK_STALE_SEC 300
12 
13 //number of lock attempts before time-out error
14 //this is roughly 15 minutes...probably much longer than needed
15 #define LOCK_TIMEOUT 9000
16 
17 //struct validity
18 #define LOCK_VALID 0
19 #define LOCK_INVALID -1
20 
21 //return error codes
22 #define LOCK_FILESET_FAIL -6
23 #define LOCK_TIMEOUT_ERROR -5
24 #define LOCK_FILE_ERROR -4
25 #define LOCK_STALE_ERROR -3
26 #define LOCK_PARSE_ERROR -2
27 #define LOCK_PROCESS_NO_PRIORITY -1
28 #define LOCK_STATUS_OK 0
29 #define LOCK_PROCESS_HAS_PRIORITY 1
30 
31 
32 //struct of holding data about the lock file's creation
34 {
35  int validity;
36  unsigned int seq_number;
37  unsigned int pid;
38  unsigned long int time_sec;
39  unsigned long int time_usec;
40  char hostname[256];
42 };
43 
44 typedef struct lockfile_data lockfile_data_struct;
45 
46 //global variables provided for signal handling and clean up
48 
50 
52 
53 void remove_lockfile(); //must go through global variables
54 
55 int parse_lockfile_name(char* lockfile_name_base, lockfile_data_struct* result);
56 
57 int create_lockfile(char *rootname, char* lockfile_name, int cand_seq_no);
58 
60 
62 
63 int at_front(char* rootname, char* lockfile_name, int cand_seq_no);
64 
65 int wait_for_write_lock(char* rootname, char* lockfile_name, struct fileset *fset);
66 
67 #endif /* end of include guard: WRITE_LOCK_MECHANISM_H__ */
Definition: fileset.h:9
char * rootname(rootsum *rsumm)
Definition: rootname.c:29
void init_lockfile_data(lockfile_data_struct *data)
Definition: create_lockfile.c:31
void remove_lockfile()
Definition: create_lockfile.c:48
lockfile_data_struct global_lockfile_data
Definition: fourfit3.c:72
int parse_lockfile_name(char *lockfile_name_base, lockfile_data_struct *result)
Definition: create_lockfile.c:57
unsigned long int time_usec
Definition: write_lock_mechanism.h:39
int at_front(char *rootname, char *lockfile_name, int cand_seq_no)
Definition: wait_for_write_lock.c:32
unsigned long int time_sec
Definition: write_lock_mechanism.h:38
#define MAX_LOCKNAME_LEN
Definition: write_lock_mechanism.h:7
void clear_global_lockfile_data()
Definition: create_lockfile.c:43
int create_lockfile(char *rootname, char *lockfile_name, int cand_seq_no)
Definition: create_lockfile.c:170
int validity
Definition: write_lock_mechanism.h:35
int wait_for_write_lock(char *rootname, char *lockfile_name, struct fileset *fset)
Definition: wait_for_write_lock.c:163
int check_stale(lockfile_data_struct *other)
Definition: create_lockfile.c:95
char lockfile_name[MAX_LOCKNAME_LEN]
Definition: write_lock_mechanism.h:41
char hostname[256]
Definition: write_lock_mechanism.h:40
unsigned int pid
Definition: write_lock_mechanism.h:37
unsigned int seq_number
Definition: write_lock_mechanism.h:36
int lock_has_priority(lockfile_data_struct *other)
Definition: create_lockfile.c:120
Definition: write_lock_mechanism.h:34