2020-07-26 07:58:15 +00:00
|
|
|
|
#ifndef ODYSSEY_SEMA_H
|
|
|
|
|
#define ODYSSEY_SEMA_H
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Odyssey.
|
|
|
|
|
*
|
|
|
|
|
* Scalable PostgreSQL connection pooler.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* A named semaphore is identified by a name of the form /somename;
|
|
|
|
|
* that is, a null-terminated string of up to NAME_MAX-4 (i.e., 251)
|
|
|
|
|
* characters consisting of an initial slash, followed by one or more
|
|
|
|
|
* characters, none of which are slashes.
|
|
|
|
|
* Two processes can operate on the same named semaphore by
|
|
|
|
|
* passing the same name to sem_open.
|
|
|
|
|
* */
|
|
|
|
|
|
|
|
|
|
#define __odyssey_internal_ch_to_int(ch) \
|
|
|
|
|
(unsigned int)(ch >= 'A' && ch <= 'Z' ? ch - 'A' : ch - 'a')
|
|
|
|
|
|
|
|
|
|
#define ODYSSEY_CTRL_LOCK_HASH \
|
2020-12-28 10:43:31 +00:00
|
|
|
|
(((__odyssey_internal_ch_to_int('O') << 6) | \
|
|
|
|
|
(__odyssey_internal_ch_to_int('d') << 5) | \
|
|
|
|
|
(__odyssey_internal_ch_to_int('y') << 4) | \
|
|
|
|
|
(__odyssey_internal_ch_to_int('s') << 3) | \
|
|
|
|
|
(__odyssey_internal_ch_to_int('s') << 2) | \
|
|
|
|
|
(__odyssey_internal_ch_to_int('e') << 1) | \
|
|
|
|
|
(__odyssey_internal_ch_to_int('y') << 0)) ^ \
|
2020-07-26 07:58:15 +00:00
|
|
|
|
1729u) // Hardy–Ramanujan number 1 ^ 3 + 12 ^ 3 = 9 ^ 3 + 10 ^ 3 = 1729
|
|
|
|
|
|
|
|
|
|
#define ODYSSEY_EXEC_LOCK_HASH \
|
2020-12-28 10:43:31 +00:00
|
|
|
|
(((__odyssey_internal_ch_to_int('P') << 5) | \
|
|
|
|
|
(__odyssey_internal_ch_to_int('o') << 4) | \
|
|
|
|
|
(__odyssey_internal_ch_to_int('o') << 3) | \
|
|
|
|
|
(__odyssey_internal_ch_to_int('l') << 2) | \
|
|
|
|
|
(__odyssey_internal_ch_to_int('e') << 1) | \
|
|
|
|
|
(__odyssey_internal_ch_to_int('r') << 0)) | \
|
2020-07-26 07:58:15 +00:00
|
|
|
|
1729u) // Hardy–Ramanujan number 1 ^ 3 + 12 ^ 3 = 9 ^ 3 + 10 ^ 3 = 1729
|
|
|
|
|
|
|
|
|
|
#define ODYSSEY_DEFAULT_LOCK_DIR "/tmp"
|
2020-12-28 10:43:31 +00:00
|
|
|
|
#define ODYSSEY_LOCK_PREFIX "odyssey-restart-lock"
|
|
|
|
|
#define ODYSSEY_LOCK_MAXPATH PATH_MAX
|
2020-07-26 07:58:15 +00:00
|
|
|
|
|
|
|
|
|
typedef int od_file_lock_t;
|
|
|
|
|
|
2020-12-28 10:43:31 +00:00
|
|
|
|
extern od_file_lock_t od_get_control_lock(char *prefix);
|
2020-07-26 07:58:15 +00:00
|
|
|
|
|
2020-12-28 10:43:31 +00:00
|
|
|
|
extern od_file_lock_t od_get_execution_lock(char *prefix);
|
2020-07-26 07:58:15 +00:00
|
|
|
|
|
|
|
|
|
#endif /* ODYSSEY_SEMA_H */
|