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

(-)flood_report_relative_times.c (-2 / +20 lines)
Lines 27-36 Link Here
27
extern apr_file_t *local_stdout;
27
extern apr_file_t *local_stdout;
28
extern apr_file_t *local_stderr;
28
extern apr_file_t *local_stderr;
29
29
30
struct relative_times {
31
    apr_thread_mutex_t *mutex;
32
};
33
30
apr_status_t relative_times_report_init(report_t **report, config_t *config, 
34
apr_status_t relative_times_report_init(report_t **report, config_t *config, 
31
                              const char *profile_name, apr_pool_t *pool)
35
                              const char *profile_name, apr_pool_t *pool)
32
{
36
{
33
    return APR_SUCCESS;
37
    struct relative_times *me;
38
    me = apr_palloc(pool, sizeof(struct relative_times));
39
    if (me == NULL) {
40
        return APR_ENOMEM;
41
    }
42
    *report = me;
43
    return apr_thread_mutex_create(&me->mutex, APR_THREAD_MUTEX_DEFAULT, pool);
34
}
44
}
35
45
36
apr_status_t relative_times_process_stats(report_t *report, int verified, request_t *req, response_t *resp, flood_timer_t *timer)
46
apr_status_t relative_times_process_stats(report_t *report, int verified, request_t *req, response_t *resp, flood_timer_t *timer)
Lines 38-43 Link Here
38
#define FLOOD_PRINT_BUF 256
48
#define FLOOD_PRINT_BUF 256
39
    apr_size_t buflen;
49
    apr_size_t buflen;
40
    char buf[FLOOD_PRINT_BUF];
50
    char buf[FLOOD_PRINT_BUF];
51
    struct relative_times *me = report;
41
52
42
    buflen = apr_snprintf(buf, FLOOD_PRINT_BUF,
53
    buflen = apr_snprintf(buf, FLOOD_PRINT_BUF,
43
                          "%" APR_INT64_T_FMT " %" APR_INT64_T_FMT
54
                          "%" APR_INT64_T_FMT " %" APR_INT64_T_FMT
Lines 60-69 Link Here
60
        apr_snprintf(buf+buflen, FLOOD_PRINT_BUF-buflen, " %d ", verified);
71
        apr_snprintf(buf+buflen, FLOOD_PRINT_BUF-buflen, " %d ", verified);
61
    }
72
    }
62
73
63
    /* FIXME: this call may need to be in a critical section */
64
#if APR_HAS_THREADS
74
#if APR_HAS_THREADS
75
    apr_thread_mutex_lock(me->mutex);
76
    apr_file_lock(local_stdout, APR_FLOCK_EXCLUSIVE);
65
    apr_file_printf(local_stdout, "%s %ld %s\n", buf, apr_os_thread_current(), req->uri);
77
    apr_file_printf(local_stdout, "%s %ld %s\n", buf, apr_os_thread_current(), req->uri);
78
    apr_file_flush(local_stdout);
79
    apr_file_unlock(local_stdout);
80
    apr_thread_mutex_unlock(me->mutex);
66
#else
81
#else
82
#error no threads?
67
    apr_file_printf(local_stdout, "%s %d %s\n", buf, getpid(), req->uri);
83
    apr_file_printf(local_stdout, "%s %d %s\n", buf, getpid(), req->uri);
68
#endif
84
#endif
69
85
Lines 77-81 Link Here
77
93
78
apr_status_t relative_times_destroy_report(report_t *report)
94
apr_status_t relative_times_destroy_report(report_t *report)
79
{
95
{
96
    struct relative_times *me = report;
97
    apr_thread_mutex_destroy(me->mutex);
80
    return APR_SUCCESS;
98
    return APR_SUCCESS;
81
}
99
}

Return to bug 40592