File: alock.h

package info (click to toggle)
openldap2.3 2.3.30-5%2Betch3
  • links: PTS
  • area: main
  • in suites: etch
  • size: 18,316 kB
  • ctags: 15,854
  • sloc: ansic: 210,071; sh: 28,305; cpp: 4,231; sql: 1,661; makefile: 1,515; perl: 870
file content (74 lines) | stat: -rw-r--r-- 2,018 bytes parent folder | download | duplicates (2)
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
/* alock.h - access lock header */
/* $OpenLDAP: pkg/ldap/servers/slapd/alock.h,v 1.1.2.3 2006/01/23 19:09:56 kurt Exp $ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
 *
 * Copyright 2005-2006 The OpenLDAP Foundation.
 * Portions Copyright 2004-2005 Symas Corporation.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted only as authorized by the OpenLDAP
 * Public License.
 *
 * A copy of this license is available in the file LICENSE in the
 * top-level directory of the distribution or, alternatively, at
 * <http://www.OpenLDAP.org/license.html>.
 */
/* ACKNOWLEDGEMENTS:
 * This work was initially developed by Matthew Backes at Symas
 * Corporation for inclusion in OpenLDAP Software.
 */

#ifndef _ALOCK_H_
#define _ALOCK_H_

#include "portable.h"
#include <ac/time.h>
#include <ac/unistd.h>

/* environment states (all the slots together) */
#define ALOCK_CLEAN		(0)
#define ALOCK_RECOVER	(1)
#define ALOCK_BUSY		(2)
#define ALOCK_UNSTABLE	(3)

/* lock user types and states */
#define ALOCK_UNLOCKED	(0)
#define ALOCK_LOCKED	(1)
#define ALOCK_UNIQUE	(2)
#define ALOCK_DIRTY		(3)

#define ALOCK_SMASK		3

/* lock/state where recovery is not available */
#define	ALOCK_NOSAVE	4

/* constants */
#define ALOCK_SLOT_SIZE		(1024)
#define ALOCK_SLOT_IATTRS	(4)
#define ALOCK_MAX_APPNAME	(ALOCK_SLOT_SIZE - 8 * ALOCK_SLOT_IATTRS)
#define ALOCK_MAGIC			(0x12345678)

LDAP_BEGIN_DECL

typedef struct alock_info {
	int al_fd;
	int al_slot;
} alock_info_t;

typedef struct alock_slot {
	unsigned int al_lock;
	time_t al_stamp;
	pid_t al_pid;
	char * al_appname;
} alock_slot_t;

LDAP_SLAPD_F (int) alock_open LDAP_P(( alock_info_t * info, const char * appname,
	const char * envdir, int locktype ));
LDAP_SLAPD_F (int) alock_scan LDAP_P(( alock_info_t * info ));
LDAP_SLAPD_F (int) alock_close LDAP_P(( alock_info_t * info ));
LDAP_SLAPD_F (int) alock_recover LDAP_P(( alock_info_t * info ));

LDAP_END_DECL

#endif