Skip to content

Commit dce1a8e

Browse files
author
Sumeet
committed
Fixed content type for te benchmark
1 parent 5754d9b commit dce1a8e

File tree

2 files changed

+51
-15
lines changed

2 files changed

+51
-15
lines changed

src/modules/common/Timer.cpp

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ void Timer::start()
3939
{
4040
m->lock();
4141
clock_gettime(CLOCK_MONOTONIC, &st);
42-
m->unlock();
4342
started = true;
43+
m->unlock();
4444
}
4545

4646
long long Timer::getCurrentTime()
@@ -65,7 +65,12 @@ void Timer::end()
6565
}
6666
long long Timer::elapsedMicroSeconds()
6767
{
68-
if(!started)return 0;
68+
m->lock();
69+
if(!started) {
70+
m->unlock();
71+
return 0;
72+
}
73+
m->unlock();
6974
timespec en;
7075
clock_gettime(CLOCK_MONOTONIC, &en);
7176
m->lock();
@@ -75,7 +80,12 @@ long long Timer::elapsedMicroSeconds()
7580
}
7681
long long Timer::elapsedMilliSeconds()
7782
{
78-
if(!started)return 0;
83+
m->lock();
84+
if(!started) {
85+
m->unlock();
86+
return 0;
87+
}
88+
m->unlock();
7989
timespec en;
8090
clock_gettime(CLOCK_MONOTONIC, &en);
8191
m->lock();
@@ -85,7 +95,12 @@ long long Timer::elapsedMilliSeconds()
8595
}
8696
long long Timer::elapsedNanoSeconds()
8797
{
88-
if(!started)return 0;
98+
m->lock();
99+
if(!started) {
100+
m->unlock();
101+
return 0;
102+
}
103+
m->unlock();
89104
timespec en;
90105
clock_gettime(CLOCK_MONOTONIC, &en);
91106
m->lock();
@@ -95,7 +110,12 @@ long long Timer::elapsedNanoSeconds()
95110
}
96111
long long Timer::elapsedSeconds()
97112
{
98-
if(!started)return 0;
113+
m->lock();
114+
if(!started) {
115+
m->unlock();
116+
return 0;
117+
}
118+
m->unlock();
99119
timespec en;
100120
clock_gettime(CLOCK_MONOTONIC, &en);
101121
m->lock();
@@ -104,33 +124,49 @@ long long Timer::elapsedSeconds()
104124
return v;
105125
}
106126

107-
long long Timer::timerMicroSeconds() {
108-
if(!started)return 0;
127+
long long Timer::timerMicroSeconds()
128+
{
109129
m->lock();
130+
if(!started) {
131+
m->unlock();
132+
return 0;
133+
}
110134
long long v = (((en.tv_sec - st.tv_sec) * 1E9) + (en.tv_nsec - st.tv_nsec))/1E3;
111135
m->unlock();
112136
return v;
113137
}
114138

115-
long long Timer::timerMilliSeconds() {
116-
if(!started)return 0;
139+
long long Timer::timerMilliSeconds()
140+
{
117141
m->lock();
142+
if(!started) {
143+
m->unlock();
144+
return 0;
145+
}
118146
long long v = (((en.tv_sec - st.tv_sec) * 1E9) + (en.tv_nsec - st.tv_nsec))/1E6;
119147
m->unlock();
120148
return v;
121149
}
122150

123-
long long Timer::timerNanoSeconds() {
124-
if(!started)return 0;
151+
long long Timer::timerNanoSeconds()
152+
{
125153
m->lock();
154+
if(!started) {
155+
m->unlock();
156+
return 0;
157+
}
126158
long long v = (((en.tv_sec - st.tv_sec) * 1E9) + (en.tv_nsec - st.tv_nsec));
127159
m->unlock();
128160
return v;
129161
}
130162

131-
long long Timer::timerSeconds() {
132-
if(!started)return 0;
163+
long long Timer::timerSeconds()
164+
{
133165
m->lock();
166+
if(!started) {
167+
m->unlock();
168+
return 0;
169+
}
134170
long long v = (en.tv_sec - st.tv_sec);
135171
m->unlock();
136172
return v;

src/modules/http/ContentTypes.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include "ContentTypes.h"
2424

25-
string ContentTypes::CONTENT_TYPE_TEXT_PLAIN = "text/plain";
26-
string ContentTypes::CONTENT_TYPE_TEXT_SHTML = "text/html";
25+
string ContentTypes::CONTENT_TYPE_TEXT_PLAIN = "text/plain; charset=UTF-8";
26+
string ContentTypes::CONTENT_TYPE_TEXT_SHTML = "text/html; charset=UTF-8";
2727
string ContentTypes::CONTENT_TYPE_APPLICATION_JSON = "application/json";
2828
string ContentTypes::CONTENT_TYPE_APPLICATION_XML = "application/xml";

0 commit comments

Comments
 (0)