File tree Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -256,7 +256,7 @@ void ConnectionState::SendWrite() {
256
256
257
257
int ConnectionState::singleRead (struct ev_loop * loop, ev_io* w, int revents) {
258
258
io_Verbose (this , " I/O ready on read path: %i\n " , revents);
259
- const size_t len = readBufSize - readBufPos_;
259
+ const size_t len = kReadBufSize - readBufPos_;
260
260
assert (len > 0 );
261
261
262
262
size_t readCount;
Original file line number Diff line number Diff line change @@ -34,16 +34,15 @@ namespace apib {
34
34
http_parser_settings IOThread::parserSettings_;
35
35
static std::once_flag parserInitalized;
36
36
37
- ConnectionState::ConnectionState (int index, IOThread* t) {
38
- index_ = index;
37
+ ConnectionState::ConnectionState (int index, IOThread* t) : index_(index) {
39
38
keepRunning_ = 1 ;
40
39
t_ = t;
41
- readBuf_ = ( char *) malloc (readBufSize) ;
40
+ readBuf_ = new char [ kReadBufSize ] ;
42
41
}
43
42
44
43
// TODO memory leak -- COnnectionStates are freed when threads exit but not
45
44
// when they just close. Think of a way to handle this...
46
- ConnectionState::~ConnectionState () { free ( readBuf_) ; }
45
+ ConnectionState::~ConnectionState () { delete[] readBuf_; }
47
46
48
47
int ConnectionState::httpComplete (http_parser* p) {
49
48
ConnectionState* c = (ConnectionState*)p->data ;
Original file line number Diff line number Diff line change @@ -173,8 +173,13 @@ class ConnectionState {
173
173
static int httpComplete (http_parser* p);
174
174
175
175
private:
176
- static constexpr int readBufSize = 512 ;
177
- static constexpr int writeBufSize = 1024 ;
176
+ // The size of the buffer to read from when calling read()
177
+ // or SSL_read()
178
+ static constexpr int kReadBufSize = 8192 ;
179
+ // In the event that connecting a socket fails, we will wait
180
+ // for this time, in seconds, before trying again.
181
+ // Nevertheless, if this ever gets used then the benchmark
182
+ // is pretty much ruined anyway...
178
183
static constexpr double kConnectFailureDelay = 0.25 ;
179
184
180
185
void addThinkTime ();
@@ -195,7 +200,7 @@ class ConnectionState {
195
200
static void writeReady (struct ev_loop * loop, ev_io* w, int revents);
196
201
static void thinkingDone (struct ev_loop * loop, ev_timer* t, int revents);
197
202
198
- int index_ = 0 ;
203
+ const int index_ = 0 ;
199
204
bool keepRunning_ = 0 ;
200
205
IOThread* t_ = nullptr ;
201
206
int fd_ = 0 ;
You can’t perform that action at this time.
0 commit comments