Skip to content

Commit 089c9fd

Browse files
committed
needs more is specific to reading
1 parent b2885de commit 089c9fd

6 files changed

Lines changed: 37 additions & 37 deletions

File tree

src/core/connection_structures.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ union utarget {
2323
};
2424

2525
typedef enum {
26-
close_connection, registered_write, needs_more, continue_processing
26+
close_connection, registered_write, needs_more_read, continue_processing
2727
} state_action;
2828

2929
typedef enum {

src/core/http.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ state_action http_read_handle(scache_connection* connection) {
6464
}
6565

6666
DEBUG("[#%d] Needs more bytes, got errno %d\n", fd, num);
67-
return needs_more;
67+
return needs_more_read;
6868
}
6969

7070
DEBUG("[#%d] Reading %d bytes from socket (write pos: %d, read pos: %d)\n", fd, num, connection->input.write_position, connection->input.read_position);
@@ -79,7 +79,7 @@ state_action http_read_handle(scache_connection* connection) {
7979
run = http_read_handle_state(connection);
8080
to_end_old = to_end;
8181
to_end = rbuf_read_remaining(&connection->input);
82-
} while (run == needs_more && to_end != 0 && to_end != to_end_old);
82+
} while (run == needs_more_read && to_end != 0 && to_end != to_end_old);
8383

8484
//Handle buffer is full, not being processed
8585
if (num == 0 && rbuf_write_remaining(&connection->input) == 0) {
@@ -129,9 +129,9 @@ state_action http_write_handle(scache_connection* connection) {
129129

130130
state_action run = continue_processing;
131131
if (connection->output_buffer == NULL) {
132-
do {
133-
run = http_write_handle_state(connection);
134-
} while (run == needs_more);
132+
// do {
133+
run = http_write_handle_state(connection);
134+
// } while (run == needs_more_write);
135135
}
136136

137137
return run;

src/core/http_parse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ state_action http_handle_eolwritetoend(scache_connection* connection) {
105105
DEBUG("[#%d] Handling HTTP EOL Search, then writing state\n", connection->client_sock);
106106

107107
RBUF_ITERATE(connection->input, n, buffer, end, ret, http_read_eoltoend(connection, buffer, n, connection->state));
108-
if (n != 0 && ret == needs_more) {
108+
if (n != 0 && ret == needs_more_read) {
109109
RBUF_READMOVE(connection->input, n);
110110
}
111111

src/core/http_parse_cache.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ extern int epfd;
3030
static state_action http_stats_after_eol(scache_connection* connection) {
3131
connection->state = 0;
3232
CONNECTION_HANDLER(connection, http_cache_handle_eolstats);
33-
return needs_more;
33+
return needs_more_read;
3434
}
3535

3636
static state_action http_write_response_after_eol(scache_connection* connection, int http_template) {
3737
CONNECTION_HANDLER(connection, http_handle_eolwritetoend);
3838
connection->output_buffer = http_templates[http_template];
3939
connection->output_length = http_templates_length[http_template];
4040
connection->state = 1;
41-
return needs_more;
41+
return needs_more_read;
4242
}
4343

4444
static state_action http_write_response(scache_connection* connection, int http_template) {
@@ -55,7 +55,7 @@ static state_action http_headers_response_after_eol(scache_connection* connectio
5555
connection->output_buffer = http_templates[http_template];
5656
connection->output_length = http_templates_length[http_template];
5757
connection->state = 2;
58-
return needs_more;
58+
return needs_more_read;
5959
}
6060

6161
static bool http_key_lookup(scache_connection* connection, int n) {
@@ -141,47 +141,47 @@ static inline state_action http_read_requeststartmethod(scache_connection* conne
141141
assert(REQUEST_IS(connection->type, connection->type));
142142
RBUF_READMOVE(connection->input, n + 1);
143143
DEBUG("[#%d] HTTP GET Request\n", connection->client_sock);
144-
return needs_more;
144+
return needs_more_read;
145145
}
146146
else if (n == 3 && rbuf_cmpn(&connection->input, "PUT", 3) == 0) {
147147
//This is a PUT request
148148
connection->type = REQUEST_HTTPPUT;
149149
assert(REQUEST_IS(connection->type, connection->type));
150150
RBUF_READMOVE(connection->input, n + 1);
151151
DEBUG("[#%d] HTTP PUT Request\n", connection->client_sock);
152-
return needs_more;
152+
return needs_more_read;
153153
}
154154
else if (n == 4 && rbuf_cmpn(&connection->input, "HEAD", 4) == 0) {
155155
//This is a HEAD request
156156
connection->type = REQUEST_HTTPHEAD;
157157
assert(REQUEST_IS(connection->type, connection->type));
158158
RBUF_READMOVE(connection->input, n + 1);
159159
DEBUG("[#%d] HTTP HEAD Request\n", connection->client_sock);
160-
return needs_more;
160+
return needs_more_read;
161161
}
162162
else if (n == 6 && rbuf_cmpn(&connection->input, "DELETE", 6) == 0) {
163163
DEBUG("[#%d] HTTP DELETE Request\n", connection->client_sock);
164164
//This is a DELETE request
165165
connection->type = REQUEST_HTTPDELETE;
166166
assert(REQUEST_IS(connection->type, connection->type));
167167
RBUF_READMOVE(connection->input, n + 1);
168-
return needs_more;
168+
return needs_more_read;
169169
}
170170
else if ((n == 4 && rbuf_cmpn(&connection->input, "BULK", 4) == 0) || (n == 5 && rbuf_cmpn(&connection->input, "PURGE", 5) == 0)) {
171171
//This is a BULK request
172172
connection->type = REQUEST_HTTPPURGE;
173173
assert(REQUEST_IS(connection->type, connection->type));
174174
RBUF_READMOVE(connection->input, n + 1);
175175
DEBUG("[#%d] HTTP BULK Request\n", connection->client_sock);
176-
return needs_more;
176+
return needs_more_read;
177177
}
178178
else if (n == 5 && rbuf_cmpn(&connection->input, "ADMIN", 5) == 0) {
179179
//This is a BULK request
180180
connection->type = REQUEST_HTTPADMIN;
181181
assert(REQUEST_IS(connection->type, connection->type));
182182
RBUF_READMOVE(connection->input, n + 1);
183183
DEBUG("[#%d] HTTP ADMIN Request\n", connection->client_sock);
184-
return needs_more;
184+
return needs_more_read;
185185
}
186186

187187
//Else: This is an INVALID request
@@ -238,7 +238,7 @@ static inline state_action http_read_requeststarturl1(scache_connection* connect
238238
}
239239

240240
RBUF_READMOVE(connection->input, n);
241-
return needs_more;
241+
return needs_more_read;
242242
}
243243
else if (*buffer == ' ') {
244244
if (REQUEST_IS(connection->type, REQUEST_HTTPGET) || REQUEST_IS(connection->type, REQUEST_HTTPDELETE) || REQUEST_IS(connection->type, REQUEST_HTTPPURGE)) {
@@ -262,7 +262,7 @@ static inline state_action http_read_requeststarturl1(scache_connection* connect
262262
//Else request for table/key
263263
CONNECTION_HANDLER(connection, http_cache_handle_headers);
264264
connection->state = 0;
265-
return needs_more;
265+
return needs_more_read;
266266
}
267267

268268
if(REQUEST_IS(connection->type, REQUEST_HTTPADMIN)){
@@ -293,7 +293,7 @@ static state_action http_read_requeststarturl2(scache_connection* connection, ch
293293
RBUF_READMOVE(connection->input, n + 1);
294294
connection->state = 0;
295295

296-
return temporary ? needs_more : registered_write;
296+
return temporary ? needs_more_read : registered_write;
297297
}
298298

299299
return continue_processing;
@@ -313,14 +313,14 @@ static state_action http_read_headers(scache_connection* connection, char* buffe
313313
RBUF_READMOVE(connection->input, bytes + 1);
314314
connection->state = HEADER_CONTENTLENGTH;
315315
CONNECTION_HANDLER(connection, http_cache_handle_headers_extract);
316-
return needs_more;
316+
return needs_more_read;
317317
}
318318
if (bytes == 5 && rbuf_cmpn(&connection->input, "X-Ttl", 5) == 0) {
319319
DEBUG("[#%d] Found X-Ttl header\n", connection->client_sock);
320320
RBUF_READMOVE(connection->input, bytes + 1);
321321
connection->state = HEADER_XTTL;
322322
CONNECTION_HANDLER(connection, http_cache_handle_headers_extract);
323-
return needs_more;
323+
return needs_more_read;
324324
}
325325
}
326326
else if (REQUEST_IS(connection->type, REQUEST_HTTPGET | REQUEST_CACHE_LEVELTABLE)) {
@@ -329,14 +329,14 @@ static state_action http_read_headers(scache_connection* connection, char* buffe
329329
RBUF_READMOVE(connection->input, bytes + 1);
330330
connection->state = HEADER_XSTART;
331331
CONNECTION_HANDLER(connection, http_cache_handle_headers_extract);
332-
return needs_more;
332+
return needs_more_read;
333333
}
334334
if (bytes == 7 && rbuf_cmpn(&connection->input, "X-Limit", 7) == 0) {
335335
DEBUG("[#%d] Found X-Limit header\n", connection->client_sock);
336336
RBUF_READMOVE(connection->input, bytes + 1);
337337
connection->state = HEADER_XLIMIT;
338338
CONNECTION_HANDLER(connection, http_cache_handle_headers_extract);
339-
return needs_more;
339+
return needs_more_read;
340340
}
341341
}
342342
else if (REQUEST_IS(connection->type, REQUEST_HTTPPURGE | REQUEST_CACHE_LEVELTABLE)) {
@@ -345,7 +345,7 @@ static state_action http_read_headers(scache_connection* connection, char* buffe
345345
RBUF_READMOVE(connection->input, bytes + 1);
346346
connection->state = HEADER_XDELETE;
347347
CONNECTION_HANDLER(connection, http_cache_handle_headers_extract);
348-
return needs_more;
348+
return needs_more_read;
349349
}
350350
}
351351
}
@@ -364,7 +364,7 @@ static state_action http_read_headers(scache_connection* connection, char* buffe
364364
}
365365

366366
CONNECTION_HANDLER(connection, http_cache_handle_request_body);
367-
return needs_more;
367+
return needs_more_read;
368368
}
369369
if (connection->cache.target.key.entry != NULL) {
370370
if (REQUEST_IS(connection->type, REQUEST_HTTPGET) || REQUEST_IS(connection->type, REQUEST_HTTPHEAD)) {
@@ -419,7 +419,7 @@ static state_action http_read_headers(scache_connection* connection, char* buffe
419419

420420
//Move pointers to next record
421421
RBUF_READMOVE(connection->input, n + 1);
422-
return needs_more;
422+
return needs_more_read;
423423
}
424424
else if (*buffer != '\r') {
425425
temporary = 0;
@@ -558,7 +558,7 @@ static state_action http_read_header_extraction(scache_connection* connection, c
558558
connection->state = 1;
559559
CONNECTION_HANDLER(connection, http_cache_handle_headers);
560560
RBUF_READMOVE(connection->input, length + temporary);
561-
return needs_more;
561+
return needs_more_read;
562562
}
563563
else{
564564
temporary = 1;
@@ -575,7 +575,7 @@ static state_action http_read_version(scache_connection* connection, char* buffe
575575

576576
RBUF_READMOVE(connection->input, n + 1);
577577
n = -1;
578-
return needs_more;
578+
return needs_more_read;
579579
}
580580
return continue_processing;
581581
}
@@ -632,7 +632,7 @@ state_action http_cache_handle_eolstats(scache_connection* connection) {
632632
DEBUG("[#%d] Handling HTTP EOL Search, then writing stats\n", connection->client_sock);
633633

634634
RBUF_ITERATE(connection->input, n, buffer, end, ret, http_read_eoltoend(connection, buffer, n, connection->state));
635-
if (n != 0 && ret == needs_more) {
635+
if (n != 0 && ret == needs_more_read) {
636636
RBUF_READMOVE(connection->input, n);
637637
}
638638
if (ret == registered_write) {

src/core/http_parse_mon.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static state_action http_write_response_after_eol(scache_connection* connection,
3737
connection->output_buffer = http_templates[http_template];
3838
connection->output_length = http_templates_length[http_template];
3939
connection->state = 0;
40-
return needs_more;
40+
return needs_more_read;
4141
}
4242

4343
static state_action http_write_response(scache_connection* connection, int http_template) {
@@ -55,7 +55,7 @@ static state_action http_headers_response_after_eol(scache_connection* connectio
5555
connection->output_buffer = http_templates[http_template];
5656
connection->output_length = http_templates_length[http_template];
5757
connection->state = 2;
58-
return needs_more;
58+
return needs_more_read;
5959
}
6060

6161

@@ -127,7 +127,7 @@ state_action http_handle_mon_eolwrite_initial(scache_connection* connection) {
127127
DEBUG("[#%d] Handling HTTP EOL Search, then writing header text\n", connection->client_sock);
128128

129129
RBUF_ITERATE(connection->input, n, buffer, end, ret, http_mon_read_eol_inital(connection, buffer, n, connection->state));
130-
if (n != 0 && ret == needs_more) {
130+
if (n != 0 && ret == needs_more_read) {
131131
RBUF_READMOVE(connection->input, n);
132132
}
133133

@@ -142,7 +142,7 @@ static state_action http_headers_response_count(scache_connection* connection, i
142142
CONNECTION_HANDLER(connection, http_handle_mon_eolwrite_initial);
143143
connection->output_buffer = http_templates[http_template];
144144
connection->output_length = http_templates_length[http_template];
145-
return needs_more;
145+
return needs_more_read;
146146
}
147147

148148
static inline state_action http_read_requeststartmethod_mon(scache_connection* connection, char* buffer, int n) {
@@ -168,15 +168,15 @@ static inline state_action http_read_requeststartmethod_mon(scache_connection* c
168168
assert(REQUEST_IS(connection->type, connection->type));
169169
RBUF_READMOVE(connection->input, n + 1);
170170
DEBUG("[#%d] HTTP GET Request\n", connection->client_sock);
171-
return needs_more;
171+
return needs_more_read;
172172
}
173173
else if (n == 4 && rbuf_cmpn(&connection->input, "HEAD", 4) == 0) {
174174
//This is a HEAD request
175175
connection->type = REQUEST_HTTPHEAD;
176176
assert(REQUEST_IS(connection->type, connection->type));
177177
RBUF_READMOVE(connection->input, n + 1);
178178
DEBUG("[#%d] HTTP HEAD Request\n", connection->client_sock);
179-
return needs_more;
179+
return needs_more_read;
180180
}
181181

182182
//Else: This is an INVALID request
@@ -273,7 +273,7 @@ state_action http_mon_handle_start(scache_connection* connection) {
273273
DEBUG("[#%d] Handling new HTTP connection\n", connection->client_sock);
274274
enable_keepalive(connection->client_sock);
275275
CONNECTION_HANDLER(connection, http_mon_handle_method);
276-
return needs_more;
276+
return needs_more_read;
277277
}
278278

279279
static scache_connection* mon_head = NULL; // next -> tail, prev = null

src/core/read_buffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,6 @@ Helper to Iterate over circular buffer
143143
} \
144144
} \
145145
if (ret == continue_processing) { \
146-
ret = needs_more; \
146+
ret = needs_more_read; \
147147
} \
148148
} while (0);

0 commit comments

Comments
 (0)