File: globals.c

package info (click to toggle)
mbuffer 20200929%2Bds2-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,072 kB
  • sloc: ansic: 4,189; sh: 3,384; makefile: 160
file content (90 lines) | stat: -rw-r--r-- 2,244 bytes parent folder | download | duplicates (4)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
 *  Copyright (C) 2000-2020, Thomas Maier-Komor
 *
 *  This file is part of mbuffer's source code.
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "dest.h"
#include "globals.h"
#include <fcntl.h>
#include <time.h>

dest_t *Dest = 0;

int
	Hashers = 0,		/* number of hashing threads */
	In = -1,
	OptMode = O_EXCL,
	Terminal = 0,		/* do we have a controlling terminal? */
	TermQ[2],
	Tmp = -1;

volatile int
	ActSenders = 0,
	NumSenders = -1,	/* number of sender threads */
	SendSize = 0,
	Terminate = 0,		/* abort execution, because of error or signal */
	Watchdog = 0;		/* 0: off, 1: started, 2: raised */

volatile unsigned
	Done = 0,
	EmptyCount = 0,		/* counter incremented when buffer runs empty */
	FullCount = 0,		/* counter incremented when buffer gets full */
	MainOutOK = 1;		/* is the main outputThread still writing or just coordinating senders */

volatile unsigned long long
	Rest = 0,
	Numin = 0,
	Numout = 0,
	InSize = 0;

char *volatile
	SendAt = 0;

size_t
	IDevBSize = 0,
	PrefixLen = 0;

long
	PgSz = 0,
	Finish = -1,		/* this is for graceful termination */
	TickTime = 0;

char
	*Prefix,
	**Buffer;

pthread_mutex_t
	TermMut = PTHREAD_MUTEX_INITIALIZER,	/* prevents statusThread from interfering with request*Volume */
	LowMut = PTHREAD_MUTEX_INITIALIZER,
	HighMut = PTHREAD_MUTEX_INITIALIZER,
	SendMut = PTHREAD_MUTEX_INITIALIZER;

sem_t
	Dev2Buf,
	Buf2Dev;

pthread_cond_t
	PercLow = PTHREAD_COND_INITIALIZER,	/* low watermark */
	PercHigh = PTHREAD_COND_INITIALIZER,	/* high watermark */
	SendCond = PTHREAD_COND_INITIALIZER;

pthread_t
	ReaderThr,
	WatchdogThr;

struct timespec
	Starttime;