@@ -680,14 +680,18 @@ mk_ptr_t mk_http_index_file(char *pathfile, char *file_aux,
680
680
#if defined (__linux__ )
681
681
static inline void mk_http_cb_file_on_consume (struct mk_stream * stream , long bytes )
682
682
{
683
+ int ret ;
683
684
(void ) bytes ;
684
685
685
686
/*
686
687
* This callback is invoked just once as we want to turn off
687
688
* the TCP Cork. We do this just overriding the callback for
688
689
* the file stream.
689
690
*/
690
- mk_server_cork_flag (stream -> channel -> fd , TCP_CORK_OFF );
691
+ ret = mk_server_cork_flag (stream -> channel -> fd , TCP_CORK_OFF );
692
+ if (ret == -1 ) {
693
+ mk_warn ("Could not set TCP_CORK/TCP_NOPUSH off" );
694
+ }
691
695
stream -> cb_bytes_consumed = NULL ;
692
696
}
693
697
#endif
@@ -1043,6 +1047,19 @@ int mk_http_keepalive_check(struct mk_http_session *cs,
1043
1047
return 0 ;
1044
1048
}
1045
1049
1050
+ static inline void mk_http_request_ka_next (struct mk_http_session * cs )
1051
+ {
1052
+ cs -> body_length = 0 ;
1053
+ cs -> counter_connections ++ ;
1054
+
1055
+ /* Update data for scheduler */
1056
+ cs -> init_time = log_current_utime ;
1057
+ cs -> status = MK_REQUEST_STATUS_INCOMPLETE ;
1058
+
1059
+ /* Initialize parser */
1060
+ mk_http_parser_init (& cs -> parser );
1061
+ }
1062
+
1046
1063
static inline int mk_http_request_end (struct mk_sched_conn * conn ,
1047
1064
struct mk_sched_worker * sched )
1048
1065
{
@@ -1089,6 +1106,7 @@ static inline int mk_http_request_end(struct mk_sched_conn *conn,
1089
1106
else {
1090
1107
mk_http_request_free_list (cs );
1091
1108
mk_http_request_ka_next (cs );
1109
+ mk_sched_conn_timeout_add (conn , sched );
1092
1110
return 0 ;
1093
1111
}
1094
1112
@@ -1257,9 +1275,6 @@ void mk_http_session_remove(struct mk_http_session *cs)
1257
1275
if (cs -> body != cs -> body_fixed ) {
1258
1276
mk_mem_free (cs -> body );
1259
1277
}
1260
- if (cs -> status == MK_REQUEST_STATUS_INCOMPLETE ) {
1261
- mk_list_del (& cs -> request_incomplete );
1262
- }
1263
1278
mk_http_request_free_list (cs );
1264
1279
mk_list_del (& cs -> request_list );
1265
1280
@@ -1296,7 +1311,6 @@ int mk_http_session_init(struct mk_http_session *cs, struct mk_sched_conn *conn)
1296
1311
cs -> close_now = MK_FALSE ;
1297
1312
cs -> socket = conn -> event .fd ;
1298
1313
cs -> status = MK_REQUEST_STATUS_INCOMPLETE ;
1299
- mk_list_add (& cs -> request_incomplete , cs_incomplete );
1300
1314
1301
1315
/* Map the channel, just for protocol-handler internal stuff */
1302
1316
cs -> channel = & conn -> channel ;
@@ -1365,18 +1379,6 @@ void mk_http_request_free_list(struct mk_http_session *cs)
1365
1379
}
1366
1380
}
1367
1381
1368
- void mk_http_request_ka_next (struct mk_http_session * cs )
1369
- {
1370
- cs -> body_length = 0 ;
1371
- cs -> counter_connections ++ ;
1372
-
1373
- /* Update data for scheduler */
1374
- cs -> init_time = log_current_utime ;
1375
- cs -> status = MK_REQUEST_STATUS_INCOMPLETE ;
1376
- mk_list_add (& cs -> request_incomplete , cs_incomplete );
1377
- mk_http_parser_init (& cs -> parser );
1378
- }
1379
-
1380
1382
/*
1381
1383
* Lookup a known header or a non-known header. For unknown headers
1382
1384
* set the 'key' value wth a lowercase string
@@ -1415,7 +1417,6 @@ struct mk_http_header *mk_http_header_get(int name, struct mk_http_request *req,
1415
1417
/*
1416
1418
* Main callbacks for the Scheduler
1417
1419
*/
1418
-
1419
1420
int mk_http_sched_read (struct mk_sched_conn * conn ,
1420
1421
struct mk_sched_worker * worker )
1421
1422
{
@@ -1453,7 +1454,7 @@ int mk_http_sched_read(struct mk_sched_conn *conn,
1453
1454
cs -> body , cs -> body_length );
1454
1455
if (status == MK_HTTP_PARSER_OK ) {
1455
1456
MK_TRACE ("[FD %i] HTTP_PARSER_OK" , socket );
1456
- mk_http_status_completed (cs );
1457
+ mk_http_status_completed (cs , conn );
1457
1458
mk_http_request_prepare (cs , sr );
1458
1459
}
1459
1460
else if (status == MK_HTTP_PARSER_ERROR ) {
@@ -1474,20 +1475,20 @@ int mk_http_sched_read(struct mk_sched_conn *conn,
1474
1475
}
1475
1476
1476
1477
int mk_http_sched_close (struct mk_sched_conn * conn ,
1477
- struct mk_sched_worker * worker ,
1478
+ struct mk_sched_worker * sched ,
1478
1479
int type )
1479
1480
{
1480
1481
struct mk_http_session * cs ;
1481
- (void ) worker ;
1482
+ (void ) sched ;
1482
1483
1483
1484
#ifdef TRACE
1484
1485
MK_TRACE ("[FD %i] HTTP sched close (type=%i)" , conn -> event .fd , type );
1485
1486
#else
1486
1487
(void ) type ;
1487
1488
#endif
1488
-
1489
1489
cs = mk_http_session_get (conn );
1490
1490
mk_http_session_remove (cs );
1491
+
1491
1492
return 0 ;
1492
1493
}
1493
1494
0 commit comments