Back to index

openldap  2.4.31
alock.h
Go to the documentation of this file.
00001 /* alock.h - access lock header */
00002 /* $OpenLDAP$ */
00003 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00004  *
00005  * Copyright 2005-2012 The OpenLDAP Foundation.
00006  * Portions Copyright 2004-2005 Symas Corporation.
00007  * All rights reserved.
00008  *
00009  * Redistribution and use in source and binary forms, with or without
00010  * modification, are permitted only as authorized by the OpenLDAP
00011  * Public License.
00012  *
00013  * A copy of this license is available in the file LICENSE in the
00014  * top-level directory of the distribution or, alternatively, at
00015  * <http://www.OpenLDAP.org/license.html>.
00016  */
00017 /* ACKNOWLEDGEMENTS:
00018  * This work was initially developed by Matthew Backes at Symas
00019  * Corporation for inclusion in OpenLDAP Software.
00020  */
00021 
00022 #ifndef _ALOCK_H_
00023 #define _ALOCK_H_
00024 
00025 #include "portable.h"
00026 #include <ac/time.h>
00027 #include <ac/unistd.h>
00028 
00029 /* environment states (all the slots together) */
00030 #define ALOCK_CLEAN         (0)
00031 #define ALOCK_RECOVER       (1)
00032 #define ALOCK_BUSY          (2)
00033 #define ALOCK_UNSTABLE      (3)
00034 
00035 /* lock user types and states */
00036 #define ALOCK_UNLOCKED      (0)
00037 #define ALOCK_LOCKED (1)
00038 #define ALOCK_UNIQUE (2)
00039 #define ALOCK_DIRTY         (3)
00040 
00041 #define ALOCK_SMASK         3
00042 
00043 /* lock/state where recovery is not available */
00044 #define       ALOCK_NOSAVE  4
00045 
00046 /* constants */
00047 #define ALOCK_SLOT_SIZE            (1024)
00048 #define ALOCK_SLOT_IATTRS   (4)
00049 #define ALOCK_MAX_APPNAME   (ALOCK_SLOT_SIZE - 8 * ALOCK_SLOT_IATTRS)
00050 #define ALOCK_MAGIC                (0x12345678)
00051 
00052 LDAP_BEGIN_DECL
00053 
00054 typedef struct alock_info {
00055        int al_fd;
00056        int al_slot;
00057 } alock_info_t;
00058 
00059 typedef struct alock_slot {
00060        unsigned int al_lock;
00061        time_t al_stamp;
00062        pid_t al_pid;
00063        char * al_appname;
00064 } alock_slot_t;
00065 
00066 LDAP_SLAPD_F (int) alock_open LDAP_P(( alock_info_t * info, const char * appname,
00067        const char * envdir, int locktype ));
00068 LDAP_SLAPD_F (int) alock_scan LDAP_P(( alock_info_t * info ));
00069 LDAP_SLAPD_F (int) alock_close LDAP_P(( alock_info_t * info, int nosave ));
00070 LDAP_SLAPD_F (int) alock_recover LDAP_P(( alock_info_t * info ));
00071 
00072 LDAP_END_DECL
00073 
00074 #endif