pidentd  3.0.19
About: implementation of the RFC1413 identification server (more or less complete rewrite compared to version 2)
  Fossies Dox: pidentd-3.0.19.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

avail.c
Go to the documentation of this file.
1 /*
2 ** avail.c - Data availability control functions.
3 **
4 ** Copyright (c) 1997-1998 Peter Eriksson <pen@lysator.liu.se>
5 **
6 ** This program is free software; you can redistribute it and/or
7 ** modify it as you wish - as long as you don't claim that you wrote
8 ** it.
9 **
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 */
14 
15 #include "config.h"
16 
17 #include <stdio.h>
18 
19 #include "pidentd.h"
20 
21 
22 int
24 {
25  pthread_mutex_init(&ap->mtx, NULL);
26  pthread_cond_init(&ap->cv, NULL);
27  ap->avail = 0;
28  return 0;
29 }
30 
31 int
33 {
34  pthread_mutex_lock(&ap->mtx);
35  if (ap->avail)
37  else
38  {
39  ap->avail = 1;
42  }
43 
44  return 0;
45 }
46 
47 int
49 {
50  pthread_mutex_lock(&ap->mtx);
51  while (ap->avail == 0)
52  pthread_cond_wait(&ap->cv, &ap->mtx);
54 
55  return 0;
56 }
pthread_mutex_init
int pthread_mutex_init(pthread_mutex_t *, pthread_mutexattr_t)
avail_signal
int avail_signal(avail_t *ap)
Definition: avail.c:32
avail_t::mtx
pthread_mutex_t mtx
Definition: avail.h:21
pthread_cond_init
int pthread_cond_init(pthread_cond_t *, pthread_condattr_t)
avail_t
Definition: avail.h:18
pidentd.h
pthread_cond_broadcast
int pthread_cond_broadcast(pthread_cond_t *)
avail_wait
int avail_wait(avail_t *ap)
Definition: avail.c:48
pthread_cond_wait
int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *)
avail_init
int avail_init(avail_t *ap)
Definition: avail.c:23
avail_t::cv
pthread_cond_t cv
Definition: avail.h:22
avail_t::avail
int avail
Definition: avail.h:20
pthread_mutex_unlock
int pthread_mutex_unlock(pthread_mutex_t *)
pthread_mutex_lock
int pthread_mutex_lock(pthread_mutex_t *)