View | Details | Raw Unified | Return to bug 59333
Collapse All | Expand All

(-)include/httpd.h (+7 lines)
Lines 1083-1088 typedef enum { Link Here
1083
    AP_CONN_KEEPALIVE
1083
    AP_CONN_KEEPALIVE
1084
} ap_conn_keepalive_e;
1084
} ap_conn_keepalive_e;
1085
1085
1086
/* AP_SB_*_SIZE needed by conn_rec */
1087
#include "scoreboard.h"
1088
1086
/**
1089
/**
1087
 * @brief Structure to store things which are per connection
1090
 * @brief Structure to store things which are per connection
1088
 */
1091
 */
Lines 1183-1188 struct conn_rec { Link Here
1183
1186
1184
    /** The "real" master connection. NULL if I am the master. */
1187
    /** The "real" master connection. NULL if I am the master. */
1185
    conn_rec *master;
1188
    conn_rec *master;
1189
1190
    /** Preserve scoreboard's worker last request infos */
1191
    char sb_lastrline[AP_SB_RLINE_SIZE];
1192
    char sb_lastvhost[AP_SB_VHOST_SIZE];
1186
};
1193
};
1187
1194
1188
/**
1195
/**
(-)include/scoreboard.h (-2 / +5 lines)
Lines 85-90 typedef enum { Link Here
85
    SB_SHARED = 2
85
    SB_SHARED = 2
86
} ap_scoreboard_e;
86
} ap_scoreboard_e;
87
87
88
#define AP_SB_RLINE_SIZE 64
89
#define AP_SB_VHOST_SIZE 32
90
88
/* stuff which is worker specific */
91
/* stuff which is worker specific */
89
typedef struct worker_score worker_score;
92
typedef struct worker_score worker_score;
90
struct worker_score {
93
struct worker_score {
Lines 113-120 struct worker_score { Link Here
113
    struct tms times;
116
    struct tms times;
114
#endif
117
#endif
115
    char client[32];            /* Keep 'em small... */
118
    char client[32];            /* Keep 'em small... */
116
    char request[64];           /* We just want an idea... */
119
    char request[AP_SB_RLINE_SIZE]; /* We just want an idea... */
117
    char vhost[32];             /* What virtual host is being accessed? */
120
    char vhost[AP_SB_VHOST_SIZE];   /* What virtual host is being accessed? */
118
    char protocol[16];          /* What protocol is used on the connection? */
121
    char protocol[16];          /* What protocol is used on the connection? */
119
};
122
};
120
123
(-)modules/http/http_core.c (-2 / +4 lines)
Lines 148-154 static int ap_process_http_async_connection(conn_r Link Here
148
            c->keepalive = AP_CONN_UNKNOWN;
148
            c->keepalive = AP_CONN_UNKNOWN;
149
            /* process the request if it was read without error */
149
            /* process the request if it was read without error */
150
150
151
            ap_update_child_status(c->sbh, SERVER_BUSY_WRITE, r);
151
            ap_update_child_status(c->sbh, SERVER_BUSY_WRITE,
152
                                   r->the_request ? r : NULL);
152
            if (r->status == HTTP_OK) {
153
            if (r->status == HTTP_OK) {
153
                cs->state = CONN_STATE_HANDLER;
154
                cs->state = CONN_STATE_HANDLER;
154
                ap_process_async_request(r);
155
                ap_process_async_request(r);
Lines 203-209 static int ap_process_http_sync_connection(conn_re Link Here
203
        c->keepalive = AP_CONN_UNKNOWN;
204
        c->keepalive = AP_CONN_UNKNOWN;
204
        /* process the request if it was read without error */
205
        /* process the request if it was read without error */
205
206
206
        ap_update_child_status(c->sbh, SERVER_BUSY_WRITE, r);
207
        ap_update_child_status(c->sbh, SERVER_BUSY_WRITE,
208
                               r->the_request ? r : NULL);
207
        if (r->status == HTTP_OK) {
209
        if (r->status == HTTP_OK) {
208
            if (cs)
210
            if (cs)
209
                cs->state = CONN_STATE_HANDLER;
211
                cs->state = CONN_STATE_HANDLER;
(-)modules/http2/h2_conn_io.c (-1 / +1 lines)
Lines 191-197 static apr_status_t pass_out(apr_bucket_brigade *b Link Here
191
        return APR_SUCCESS;
191
        return APR_SUCCESS;
192
    }
192
    }
193
    
193
    
194
    ap_update_child_status_from_conn(c->sbh, SERVER_BUSY_WRITE, c);
194
    ap_update_child_status(c->sbh, SERVER_BUSY_WRITE, NULL);
195
    apr_brigade_length(bb, 0, &bblen);
195
    apr_brigade_length(bb, 0, &bblen);
196
    h2_conn_io_bb_log(c, 0, APLOG_TRACE2, "master conn pass", bb);
196
    h2_conn_io_bb_log(c, 0, APLOG_TRACE2, "master conn pass", bb);
197
    status = ap_pass_brigade(c->output_filters, bb);
197
    status = ap_pass_brigade(c->output_filters, bb);
(-)modules/http2/h2_task.c (-1 / +1 lines)
Lines 235-241 static apr_status_t h2_task_process_request(h2_tas Link Here
235
                  "h2_task(%s): create request_rec", task->id);
235
                  "h2_task(%s): create request_rec", task->id);
236
    r = h2_request_create_rec(req, c);
236
    r = h2_request_create_rec(req, c);
237
    if (r && (r->status == HTTP_OK)) {
237
    if (r && (r->status == HTTP_OK)) {
238
        ap_update_child_status(c->sbh, SERVER_BUSY_READ, r);
238
        ap_update_child_status(c->sbh, SERVER_BUSY_WRITE, r);
239
        
239
        
240
        if (cs) {
240
        if (cs) {
241
            cs->state = CONN_STATE_HANDLER;
241
            cs->state = CONN_STATE_HANDLER;
(-)server/connection.c (-1 / +1 lines)
Lines 101-107 AP_DECLARE(int) ap_prep_lingering_close(conn_rec * Link Here
101
    ap_run_pre_close_connection(c);
101
    ap_run_pre_close_connection(c);
102
    
102
    
103
    if (c->sbh) {
103
    if (c->sbh) {
104
        ap_update_child_status(c->sbh, SERVER_CLOSING, NULL);
104
        ap_update_child_status_from_conn(c->sbh, SERVER_CLOSING, c);
105
    }
105
    }
106
    return 0;
106
    return 0;
107
}
107
}
(-)server/core.c (-1 / +1 lines)
Lines 4841-4847 static conn_rec *core_create_conn(apr_pool_t *ptra Link Here
4841
    conn_rec *c = (conn_rec *) apr_pcalloc(ptrans, sizeof(conn_rec));
4841
    conn_rec *c = (conn_rec *) apr_pcalloc(ptrans, sizeof(conn_rec));
4842
4842
4843
    c->sbh = sbh;
4843
    c->sbh = sbh;
4844
    (void)ap_update_child_status(c->sbh, SERVER_BUSY_READ, (request_rec *)NULL);
4844
    ap_update_child_status(c->sbh, SERVER_BUSY_READ, NULL);
4845
4845
4846
    /* Got a connection structure, so initialize what fields we can
4846
    /* Got a connection structure, so initialize what fields we can
4847
     * (the rest are zeroed out by pcalloc).
4847
     * (the rest are zeroed out by pcalloc).
(-)server/mpm/event/event.c (-7 / +6 lines)
Lines 1114-1120 read_request: Link Here
1114
    if (cs->pub.state == CONN_STATE_WRITE_COMPLETION) {
1114
    if (cs->pub.state == CONN_STATE_WRITE_COMPLETION) {
1115
        ap_filter_t *output_filter = c->output_filters;
1115
        ap_filter_t *output_filter = c->output_filters;
1116
        apr_status_t rv;
1116
        apr_status_t rv;
1117
        ap_update_child_status_from_conn(sbh, SERVER_BUSY_WRITE, c);
1117
        ap_update_child_status(sbh, SERVER_BUSY_WRITE, NULL);
1118
        while (output_filter->next != NULL) {
1118
        while (output_filter->next != NULL) {
1119
            output_filter = output_filter->next;
1119
            output_filter = output_filter->next;
1120
        }
1120
        }
Lines 1910-1916 static void *APR_THREAD_FUNC worker_thread(apr_thr Link Here
1910
        }
1910
        }
1911
1911
1912
        ap_update_child_status_from_indexes(process_slot, thread_slot,
1912
        ap_update_child_status_from_indexes(process_slot, thread_slot,
1913
                                            dying ? SERVER_GRACEFUL : SERVER_READY, NULL);
1913
                                            dying ? SERVER_GRACEFUL
1914
                                                  : SERVER_READY, NULL);
1914
      worker_pop:
1915
      worker_pop:
1915
        if (workers_may_exit) {
1916
        if (workers_may_exit) {
1916
            break;
1917
            break;
Lines 1965-1973 static void *APR_THREAD_FUNC worker_thread(apr_thr Link Here
1965
    }
1966
    }
1966
1967
1967
    ap_update_child_status_from_indexes(process_slot, thread_slot,
1968
    ap_update_child_status_from_indexes(process_slot, thread_slot,
1968
                                        dying ? SERVER_DEAD :
1969
                                        dying ? SERVER_DEAD
1969
                                        SERVER_GRACEFUL,
1970
                                              : SERVER_GRACEFUL, NULL);
1970
                                        (request_rec *) NULL);
1971
1971
1972
    apr_thread_exit(thd, APR_SUCCESS);
1972
    apr_thread_exit(thd, APR_SUCCESS);
1973
    return NULL;
1973
    return NULL;
Lines 2728-2735 static void server_main_loop(int remaining_childre Link Here
2728
2728
2729
                for (i = 0; i < threads_per_child; i++)
2729
                for (i = 0; i < threads_per_child; i++)
2730
                    ap_update_child_status_from_indexes(child_slot, i,
2730
                    ap_update_child_status_from_indexes(child_slot, i,
2731
                                                        SERVER_DEAD,
2731
                                                        SERVER_DEAD, NULL);
2732
                                                        (request_rec *) NULL);
2733
2732
2734
                event_note_child_killed(child_slot, 0, 0);
2733
                event_note_child_killed(child_slot, 0, 0);
2735
                ps = &ap_scoreboard_image->parent[child_slot];
2734
                ps = &ap_scoreboard_image->parent[child_slot];
(-)server/mpm/winnt/child.c (-6 / +5 lines)
Lines 894-901 static DWORD __stdcall worker_main(void *thread_nu Link Here
894
        }
894
        }
895
    }
895
    }
896
896
897
    ap_update_child_status_from_indexes(0, thread_num, SERVER_DEAD,
897
    ap_update_child_status_from_indexes(0, thread_num, SERVER_DEAD, NULL);
898
                                        (request_rec *) NULL);
899
898
900
    return 0;
899
    return 0;
901
}
900
}
Lines 1314-1326 void child_main(apr_pool_t *pconf, DWORD parent_pi Link Here
1314
                     threads_created);
1313
                     threads_created);
1315
    }
1314
    }
1316
    for (i = 0; i < threads_created; i++) {
1315
    for (i = 0; i < threads_created; i++) {
1317
        int *score_idx;
1316
        int *idx;
1318
        TerminateThread(child_handles[i], 1);
1317
        TerminateThread(child_handles[i], 1);
1319
        CloseHandle(child_handles[i]);
1318
        CloseHandle(child_handles[i]);
1320
        /* Reset the scoreboard entry for the thread we just whacked */
1319
        /* Reset the scoreboard entry for the thread we just whacked */
1321
        score_idx = apr_hash_get(ht, &child_handles[i], sizeof(HANDLE));
1320
        idx = apr_hash_get(ht, &child_handles[i], sizeof(HANDLE));
1322
        if (score_idx) {
1321
        if (idx) {
1323
            ap_update_child_status_from_indexes(0, *score_idx, SERVER_DEAD, NULL);
1322
            ap_update_child_status_from_indexes(0, *idx, SERVER_DEAD, NULL);
1324
        }
1323
        }
1325
    }
1324
    }
1326
    ap_log_error(APLOG_MARK, APLOG_NOTICE, APR_SUCCESS, ap_server_conf, APLOGNO(00364)
1325
    ap_log_error(APLOG_MARK, APLOG_NOTICE, APR_SUCCESS, ap_server_conf, APLOGNO(00364)
(-)server/mpm/worker/worker.c (-5 / +8 lines)
Lines 928-934 static void * APR_THREAD_FUNC worker_thread(apr_th Link Here
928
    ap_scoreboard_image->servers[process_slot][thread_slot].pid = ap_my_pid;
928
    ap_scoreboard_image->servers[process_slot][thread_slot].pid = ap_my_pid;
929
    ap_scoreboard_image->servers[process_slot][thread_slot].tid = apr_os_thread_current();
929
    ap_scoreboard_image->servers[process_slot][thread_slot].tid = apr_os_thread_current();
930
    ap_scoreboard_image->servers[process_slot][thread_slot].generation = retained->my_generation;
930
    ap_scoreboard_image->servers[process_slot][thread_slot].generation = retained->my_generation;
931
    ap_update_child_status_from_indexes(process_slot, thread_slot, SERVER_STARTING, NULL);
931
    ap_update_child_status_from_indexes(process_slot, thread_slot,
932
                                        SERVER_STARTING, NULL);
932
933
933
#ifdef HAVE_PTHREAD_KILL
934
#ifdef HAVE_PTHREAD_KILL
934
    unblock_signal(WORKER_SIGNAL);
935
    unblock_signal(WORKER_SIGNAL);
Lines 949-955 static void * APR_THREAD_FUNC worker_thread(apr_th Link Here
949
            is_idle = 1;
950
            is_idle = 1;
950
        }
951
        }
951
952
952
        ap_update_child_status_from_indexes(process_slot, thread_slot, SERVER_READY, NULL);
953
        ap_update_child_status_from_indexes(process_slot, thread_slot,
954
                                            SERVER_READY, NULL);
953
worker_pop:
955
worker_pop:
954
        if (workers_may_exit) {
956
        if (workers_may_exit) {
955
            break;
957
            break;
Lines 995-1001 worker_pop: Link Here
995
    }
997
    }
996
998
997
    ap_update_child_status_from_indexes(process_slot, thread_slot,
999
    ap_update_child_status_from_indexes(process_slot, thread_slot,
998
        (dying) ? SERVER_DEAD : SERVER_GRACEFUL, (request_rec *) NULL);
1000
                                        dying ? SERVER_DEAD
1001
                                              : SERVER_GRACEFUL, NULL);
999
1002
1000
    apr_thread_exit(thd, APR_SUCCESS);
1003
    apr_thread_exit(thd, APR_SUCCESS);
1001
    return NULL;
1004
    return NULL;
Lines 1730-1737 static void server_main_loop(int remaining_childre Link Here
1730
                process_score *ps;
1733
                process_score *ps;
1731
1734
1732
                for (i = 0; i < threads_per_child; i++)
1735
                for (i = 0; i < threads_per_child; i++)
1733
                    ap_update_child_status_from_indexes(child_slot, i, SERVER_DEAD,
1736
                    ap_update_child_status_from_indexes(child_slot, i,
1734
                                                        (request_rec *) NULL);
1737
                                                        SERVER_DEAD, NULL);
1735
1738
1736
                worker_note_child_killed(child_slot, 0, 0);
1739
                worker_note_child_killed(child_slot, 0, 0);
1737
                ps = &ap_scoreboard_image->parent[child_slot];
1740
                ps = &ap_scoreboard_image->parent[child_slot];
(-)server/protocol.c (-1 / +1 lines)
Lines 992-998 request_rec *ap_read_request(conn_rec *conn) Link Here
992
            goto traceout;
992
            goto traceout;
993
        }
993
        }
994
        else if (r->status == HTTP_REQUEST_TIME_OUT) {
994
        else if (r->status == HTTP_REQUEST_TIME_OUT) {
995
            ap_update_child_status(conn->sbh, SERVER_BUSY_LOG, r);
995
            ap_update_child_status(conn->sbh, SERVER_BUSY_LOG, NULL);
996
            if (!r->connection->keepalives) {
996
            if (!r->connection->keepalives) {
997
                ap_run_log_transaction(r);
997
                ap_run_log_transaction(r);
998
            }
998
            }
(-)server/scoreboard.c (-48 / +49 lines)
Lines 464-485 static int update_child_status_internal(int child_ Link Here
464
{
464
{
465
    int old_status;
465
    int old_status;
466
    worker_score *ws;
466
    worker_score *ws;
467
    process_score *ps;
468
    int mpm_generation;
467
    int mpm_generation;
469
468
470
    ws = &ap_scoreboard_image->servers[child_num][thread_num];
469
    ws = &ap_scoreboard_image->servers[child_num][thread_num];
471
    old_status = ws->status;
470
    old_status = ws->status;
472
    if (status >= 0) {
471
    ws->status = status;
473
        ws->status = status;
472
    
474
        
473
    if (status == SERVER_READY
475
        ps = &ap_scoreboard_image->parent[child_num];
474
        && old_status == SERVER_STARTING) {
476
        
475
        process_score *ps = &ap_scoreboard_image->parent[child_num];
477
        if (status == SERVER_READY
476
        ws->thread_num = child_num * thread_limit + thread_num;
478
            && old_status == SERVER_STARTING) {
477
        ap_mpm_query(AP_MPMQ_GENERATION, &mpm_generation);
479
            ws->thread_num = child_num * thread_limit + thread_num;
478
        ps->generation = mpm_generation;
480
            ap_mpm_query(AP_MPMQ_GENERATION, &mpm_generation);
481
            ps->generation = mpm_generation;
482
        }
483
    }
479
    }
484
480
485
    if (ap_extended_status) {
481
    if (ap_extended_status) {
Lines 497-542 static int update_child_status_internal(int child_ Link Here
497
            ws->conn_bytes = 0;
493
            ws->conn_bytes = 0;
498
            ws->last_used = apr_time_now();
494
            ws->last_used = apr_time_now();
499
        }
495
        }
500
        if (status == SERVER_READY) {
496
501
            ws->client[0]='\0';
497
        if (descr) {
502
            ws->vhost[0]='\0';
498
            apr_cpystrn(ws->request, descr, sizeof(ws->request));
503
            ws->request[0]='\0';
504
            ws->protocol[0]='\0';
505
        }
499
        }
506
        else {
500
        else if (r) {
507
            if (descr) {
501
            copy_request(ws->request, sizeof(ws->request), r);
508
                apr_cpystrn(ws->request, descr, sizeof(ws->request));
502
            apr_cpystrn(c->sb_lastrline, ws->request, sizeof(c->sb_lastrline));
503
        }
504
        else if (c) {
505
            apr_cpystrn(ws->request, c->sb_lastrline, sizeof(ws->request));
506
        }
507
508
        if (r && r->useragent_ip) {
509
            if (!(val = ap_get_useragent_host(r, REMOTE_NOLOOKUP, NULL)))
510
                apr_cpystrn(ws->client, r->useragent_ip, sizeof(ws->client));
511
            else
512
                apr_cpystrn(ws->client, val, sizeof(ws->client));
513
        }
514
        else if (c) {
515
            if (!(val = ap_get_remote_host(c, c->base_server->lookup_defaults,
516
                                           REMOTE_NOLOOKUP, NULL)))
517
                apr_cpystrn(ws->client, c->client_ip, sizeof(ws->client));
518
            else
519
                apr_cpystrn(ws->client, val, sizeof(ws->client));
520
        }
521
522
        if (s) {
523
            if (c) {
524
                apr_snprintf(ws->vhost, sizeof(ws->vhost), "%s:%d",
525
                             s->server_hostname, c->local_addr->port);
526
                apr_cpystrn(c->sb_lastvhost, ws->vhost,
527
                            sizeof(c->sb_lastvhost));
509
            }
528
            }
510
            else if (r) {
529
            else {
511
                copy_request(ws->request, sizeof(ws->request), r);
530
                apr_cpystrn(ws->vhost, s->server_hostname, sizeof(ws->vhost));
512
            }
531
            }
513
            if (r) {
514
                if (!(val = ap_get_useragent_host(r, REMOTE_NOLOOKUP, NULL)))
515
                    apr_cpystrn(ws->client, r->useragent_ip, sizeof(ws->client));
516
                else
517
                    apr_cpystrn(ws->client, val, sizeof(ws->client));
518
            }
519
            else if (c) {
520
                if (!(val = ap_get_remote_host(c, c->base_server->lookup_defaults,
521
                                               REMOTE_NOLOOKUP, NULL)))
522
                    apr_cpystrn(ws->client, c->client_ip, sizeof(ws->client));
523
                else
524
                    apr_cpystrn(ws->client, val, sizeof(ws->client));
525
            }
526
            if (s) {
527
                if (c) {
528
                    apr_snprintf(ws->vhost, sizeof(ws->vhost), "%s:%d",
529
                                 s->server_hostname, c->local_addr->port);
530
                }
531
                else {
532
                    apr_cpystrn(ws->vhost, s->server_hostname, sizeof(ws->vhost));
533
                }
534
            }
535
            if (c) {
536
                val = ap_get_protocol(c);
537
                apr_cpystrn(ws->protocol, val, sizeof(ws->protocol));
538
            }
539
        }
532
        }
533
        else if (c) {
534
            apr_cpystrn(ws->vhost, c->sb_lastvhost, sizeof(ws->vhost));
535
        }
536
537
        if (c) {
538
            val = ap_get_protocol(c);
539
            apr_cpystrn(ws->protocol, val, sizeof(ws->protocol));
540
        }
540
    }
541
    }
541
542
542
    return old_status;
543
    return old_status;

Return to bug 59333