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

(-)a/modules/aaa/mod_auth_digest.c (-14 / +28 lines)
Lines 80-91 Link Here
80
80
81
#include "mod_auth.h"
81
#include "mod_auth.h"
82
82
83
/* Disable shmem until pools/init gets sorted out
84
 * remove following two lines when fixed
85
 */
86
#undef APR_HAS_SHARED_MEMORY
87
#define APR_HAS_SHARED_MEMORY 0
88
89
/* struct to hold the configuration info */
83
/* struct to hold the configuration info */
90
84
91
typedef struct digest_config_struct {
85
typedef struct digest_config_struct {
Lines 204-209 static apr_status_t cleanup_tables(void Link Here
204
                  "Digest: cleaning up shared memory");
198
                  "Digest: cleaning up shared memory");
205
    fflush(stderr);
199
    fflush(stderr);
206
200
201
    if (client_rmm) {
202
        apr_rmm_destroy(client_rmm);
203
        client_rmm = NULL;
204
    }
205
207
    if (client_shm) {
206
    if (client_shm) {
208
        apr_shm_destroy(client_shm);
207
        apr_shm_destroy(client_shm);
209
        client_shm = NULL;
208
        client_shm = NULL;
Lines 257-262 static void log_error_and_cleanup(char * Link Here
257
    cleanup_tables(NULL);
256
    cleanup_tables(NULL);
258
}
257
}
259
258
259
static void *apr_rmm_malloc_(apr_rmm_t *rmm, apr_size_t reqsize)
260
{
261
	return apr_rmm_addr_get(rmm, apr_rmm_malloc(rmm, reqsize));
262
}
263
260
#if APR_HAS_SHARED_MEMORY
264
#if APR_HAS_SHARED_MEMORY
261
265
262
static void initialize_tables(server_rec *s, apr_pool_t *ctx)
266
static void initialize_tables(server_rec *s, apr_pool_t *ctx)
Lines 266-278 static void initialize_tables(server_rec Link Here
266
270
267
    /* set up client list */
271
    /* set up client list */
268
272
269
    sts = apr_shm_create(&client_shm, shmem_size, tmpnam(NULL), ctx);
273
    sts = apr_shm_create(&client_shm, APR_ALIGN_DEFAULT(shmem_size), tmpnam(NULL), ctx);
270
    if (sts != APR_SUCCESS) {
274
    if (sts != APR_SUCCESS) {
271
        log_error_and_cleanup("failed to create shared memory segments", sts, s);
275
        log_error_and_cleanup("failed to create shared memory segments", sts, s);
272
        return;
276
        return;
273
    }
277
    }
274
278
275
    client_list = apr_rmm_malloc(client_rmm, sizeof(*client_list) +
279
    sts = apr_rmm_init(&client_rmm, NULL, apr_shm_baseaddr_get(client_shm),
280
                       apr_shm_size_get(client_shm), ctx);
281
    if (sts != APR_SUCCESS) {
282
        log_error_and_cleanup("failed to init RMM", sts, s);
283
        return;
284
    }
285
286
    client_list = apr_rmm_malloc_(client_rmm, sizeof(*client_list) +
276
                                            sizeof(client_entry*)*num_buckets);
287
                                            sizeof(client_entry*)*num_buckets);
277
    if (!client_list) {
288
    if (!client_list) {
278
        log_error_and_cleanup("failed to allocate shared memory", -1, s);
289
        log_error_and_cleanup("failed to allocate shared memory", -1, s);
Lines 298-304 static void initialize_tables(server_rec Link Here
298
309
299
    /* setup opaque */
310
    /* setup opaque */
300
311
301
    opaque_cntr = apr_rmm_malloc(client_rmm, sizeof(*opaque_cntr));
312
    opaque_cntr = apr_rmm_malloc_(client_rmm, sizeof(*opaque_cntr));
302
    if (opaque_cntr == NULL) {
313
    if (opaque_cntr == NULL) {
303
        log_error_and_cleanup("failed to allocate shared memory", -1, s);
314
        log_error_and_cleanup("failed to allocate shared memory", -1, s);
304
        return;
315
        return;
Lines 318-324 static void initialize_tables(server_rec Link Here
318
329
319
    /* setup one-time-nonce counter */
330
    /* setup one-time-nonce counter */
320
331
321
    otn_counter = apr_rmm_malloc(client_rmm, sizeof(*otn_counter));
332
    otn_counter = apr_rmm_malloc_(client_rmm, sizeof(*otn_counter));
322
    if (otn_counter == NULL) {
333
    if (otn_counter == NULL) {
323
        log_error_and_cleanup("failed to allocate shared memory", -1, s);
334
        log_error_and_cleanup("failed to allocate shared memory", -1, s);
324
        return;
335
        return;
Lines 547-557 static const char *set_nonce_format(cmd_ Link Here
547
558
548
static const char *set_nc_check(cmd_parms *cmd, void *config, int flag)
559
static const char *set_nc_check(cmd_parms *cmd, void *config, int flag)
549
{
560
{
550
    if (flag && !client_shm)
561
#if !APR_HAS_SHARED_MEMORY
562
    /* client_shm init later */
563
    /* if (flag && !client_shm) */
551
        ap_log_error(APLOG_MARK, APLOG_WARNING, 0,
564
        ap_log_error(APLOG_MARK, APLOG_WARNING, 0,
552
                     cmd->server, "Digest: WARNING: nonce-count checking "
565
                     cmd->server, "Digest: WARNING: nonce-count checking "
553
                     "is not supported on platforms without shared-memory "
566
                     "is not supported on platforms without shared-memory "
554
                     "support - disabling check");
567
                     "support - disabling check");
568
#endif
555
569
556
    ((digest_config_rec *) config)->check_nc = flag;
570
    ((digest_config_rec *) config)->check_nc = flag;
557
    return NULL;
571
    return NULL;
Lines 810-816 static client_entry *add_client(unsigned Link Here
810
824
811
    /* try to allocate a new entry */
825
    /* try to allocate a new entry */
812
826
813
    entry = (client_entry *)apr_rmm_malloc(client_rmm, sizeof(client_entry));
827
    entry = (client_entry *)apr_rmm_malloc_(client_rmm, sizeof(client_entry));
814
    if (!entry) {
828
    if (!entry) {
815
        long num_removed = gc();
829
        long num_removed = gc();
816
        ap_log_error(APLOG_MARK, APLOG_INFO, 0, s,
830
        ap_log_error(APLOG_MARK, APLOG_INFO, 0, s,
Lines 819-825 static client_entry *add_client(unsigned Link Here
819
                     "%ld", num_removed,
833
                     "%ld", num_removed,
820
                     client_list->num_created - client_list->num_renewed,
834
                     client_list->num_created - client_list->num_renewed,
821
                     client_list->num_removed, client_list->num_renewed);
835
                     client_list->num_removed, client_list->num_renewed);
822
        entry = (client_entry *)apr_rmm_malloc(client_rmm, sizeof(client_entry));
836
        entry = (client_entry *)apr_rmm_malloc_(client_rmm, sizeof(client_entry));
823
        if (!entry) {
837
        if (!entry) {
824
            return NULL;       /* give up */
838
            return NULL;       /* give up */
825
        }
839
        }
Lines 1092-1098 static client_entry *gen_client(const re Link Here
1092
1106
1093
    apr_global_mutex_lock(opaque_lock);
1107
    apr_global_mutex_lock(opaque_lock);
1094
    op = (*opaque_cntr)++;
1108
    op = (*opaque_cntr)++;
1095
    apr_global_mutex_lock(opaque_lock);
1109
    apr_global_mutex_unlock(opaque_lock);
1096
1110
1097
    if (!(entry = add_client(op, &new_entry, r->server))) {
1111
    if (!(entry = add_client(op, &new_entry, r->server))) {
1098
        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
1112
        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,

Return to bug 51711