IDZEBRA  2.1.2
Data Structures | Functions | Variables
flock.c File Reference
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/types.h>
#include <idzebra/flock.h>
#include <zebra-lock.h>
#include <yaz/xmalloc.h>
#include <yaz/log.h>

Go to the source code of this file.

Data Structures

struct  zebra_lock_handle
 
struct  zebra_lock_info
 

Functions

char * zebra_mk_fname (const char *dir, const char *name)
 
ZebraLockHandle zebra_lock_create (const char *dir, const char *name)
 
void zebra_lock_destroy (ZebraLockHandle h)
 
static int unixLock (int fd, int type, int cmd)
 
int zebra_lock_w (ZebraLockHandle h)
 
int zebra_lock_r (ZebraLockHandle h)
 
int zebra_unlock (ZebraLockHandle h)
 
static int check_for_linuxthreads (void)
 see if the fcntl locking is not POSIX More...
 
void zebra_flock_init ()
 

Variables

static int initialized = 0
 
static int posix_locks = 1
 
Zebra_mutex lock_list_mutex
 
static struct zebra_lock_infolock_list = 0
 
static int log_level = 0
 

Function Documentation

static int check_for_linuxthreads ( void  )
static

see if the fcntl locking is not POSIX

The default posix_locks=1 is assumed.. This function sets posix_locks to zero if linuxthreads is in use.

Definition at line 371 of file flock.c.

References posix_locks.

Referenced by zebra_flock_init().

static int unixLock ( int  fd,
int  type,
int  cmd 
)
static

Definition at line 232 of file flock.c.

References log_level.

Referenced by zebra_lock_r(), zebra_lock_w(), and zebra_unlock().

void zebra_flock_init ( void  )

Definition at line 391 of file flock.c.

References check_for_linuxthreads(), initialized, log_level, posix_locks, and zebra_mutex_init().

Referenced by main(), and zebra_start_res().

ZebraLockHandle zebra_lock_create ( const char *  dir,
const char *  name 
)
void zebra_lock_destroy ( ZebraLockHandle  h)
int zebra_lock_r ( ZebraLockHandle  h)
int zebra_lock_w ( ZebraLockHandle  h)
char* zebra_mk_fname ( const char *  dir,
const char *  name 
)

Definition at line 84 of file flock.c.

References zebra_lock_info::fname.

Referenced by zebra_get_state(), zebra_lock_create(), and zebra_set_state().

int zebra_unlock ( ZebraLockHandle  h)

Variable Documentation

int initialized = 0
static

have this module (mutex) been initialized?

Definition at line 44 of file flock.c.

Referenced by zebra_flock_init(), and zebra_lock_create().

struct zebra_lock_info* lock_list = 0
static

our list of file locked files

Definition at line 53 of file flock.c.

Referenced by zebra_lock_create(), and zebra_lock_destroy().

Zebra_mutex lock_list_mutex

mutex for lock_list below

Definition at line 50 of file flock.c.

int log_level = 0
static
int posix_locks = 1
static

whether fcntl locks are shared for all threads in a process (POSIX)

Definition at line 47 of file flock.c.

Referenced by check_for_linuxthreads(), zebra_flock_init(), zebra_lock_create(), zebra_lock_destroy(), zebra_lock_r(), zebra_lock_w(), and zebra_unlock().