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

(-)common/jk_shm.c (-6 / +18 lines)
Lines 88-93 Link Here
88
#endif
88
#endif
89
static int jk_shm_inited_cs = 0;
89
static int jk_shm_inited_cs = 0;
90
/* Used if shared memory fails, fall back ro process local memory */
91
static volatile unsigned int maintain_checking;
92
static volatile time_t maintain_time;
93
90
static size_t jk_shm_calculate_slot_size()
94
static size_t jk_shm_calculate_slot_size()
91
{
95
{
92
    int align = 64;
96
    int align = 64;
Lines 872-888 Link Here
872
int jk_shm_check_maintain(time_t trigger)
876
int jk_shm_check_maintain(time_t trigger)
873
{
877
{
874
    int rv = JK_FALSE;
878
    int rv = JK_FALSE;
875
    int maintain_checking = JK_ATOMIC_INCREMENT(&(jk_shmem.hdr->h.data.maintain_checking));
879
    volatile unsigned int *maintain_checking_ptr;
880
    volatile time_t *maintain_time_ptr;
881
    if (jk_shmem.hdr) {
882
        maintain_checking_ptr = &(jk_shmem.hdr->h.data.maintain_checking);
883
        maintain_time_ptr = &(jk_shmem.hdr->h.data.maintain_time);
884
    } else {
885
        maintain_checking_ptr = &maintain_checking;
886
        maintain_time_ptr = &maintain_time;
887
    }
876
    /* Another process (or thread) is already checking */
888
    /* Another process (or thread) is already checking */
877
    if (maintain_checking > 1) {
889
    if (JK_ATOMIC_INCREMENT(maintain_checking_ptr) > 1) {
878
        JK_ATOMIC_DECREMENT(&(jk_shmem.hdr->h.data.maintain_checking));
890
        JK_ATOMIC_DECREMENT(maintain_checking_ptr);
879
        return rv;
891
        return rv;
880
    }
892
    }
881
    if (jk_shmem.hdr->h.data.maintain_time < trigger) {
893
    if (*maintain_time_ptr < trigger) {
882
        jk_shmem.hdr->h.data.maintain_time = time(NULL);
894
        *maintain_time_ptr = time(NULL);
883
        rv = JK_TRUE;
895
        rv = JK_TRUE;
884
    }
896
    }
885
    JK_ATOMIC_DECREMENT(&(jk_shmem.hdr->h.data.maintain_checking));
897
    JK_ATOMIC_DECREMENT(maintain_checking_ptr);
886
    return rv;
898
    return rv;
887
}
899
}

Return to bug 59184