-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresults.cpp
More file actions
112 lines (92 loc) · 1.36 KB
/
results.cpp
File metadata and controls
112 lines (92 loc) · 1.36 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <stdio.h>
#include "postal.h"
#include "results.h"
results::results( )
: m_connections( 0 )
#ifdef USE_SSL
, m_ssl_connections( 0 )
#endif
, m_mut( true )
, m_msgs( 0 )
, m_bytes( 0 )
, m_errors( 0 )
{
}
results::~results( )
{
m_print( );
}
void
results::error( )
{
Lock l( m_mut );
m_errors++;
}
void
results::dataBytes( int bytes )
{
Lock l( m_mut );
m_bytes += bytes;
}
void
results::message( )
{
Lock l( m_mut );
m_msgs++;
}
void
results::connection( )
{
Lock l( m_mut );
m_connections++;
}
#ifdef USE_SSL
void
results::connect_ssl( )
{
Lock l( m_mut );
m_ssl_connections++;
}
#endif
void
results::print( )
{
Lock l( m_mut );
m_print( );
}
void
results::clear( )
{
Lock l( m_mut );
m_clear( );
}
void
results::childPrint( )
{
}
void
results::m_print( )
{
time_t now = time( NULL );
tm *t = localtime( &now );
printf( "%02d:%02d,%u,%u,%u", t->tm_hour, t->tm_min, m_msgs
, (unsigned int)m_bytes / 1024, m_errors );
#ifdef USE_SSL
printf( ",%d,%d", m_connections, m_ssl_connections );
m_ssl_connections = 0;
#else
printf( ",%d", m_connections );
#endif
childPrint( );
printf( "\n" );
fflush( NULL );
m_clear( );
}
void
results::m_clear( )
{
m_msgs = 0;
m_connections = 0;
m_bytes = m_bytes % 1024;
m_errors = 0;
}