Project

General

Profile

Bug #15798 ยป fix-pthread-timer.patch

jeremyevans0 (Jeremy Evans), 04/26/2019 11:31 PM

View differences:

thread_pthread.c
2187 2187
    pthread_t main_thread_id = vm->main_thread->thread_id;
2188 2188
    struct pollfd pfd;
2189 2189
    int timeout = -1;
2190
    int ccp;
2190 2191

  
2191 2192
    pfd.fd = timer_pthread.low[0];
2192 2193
    pfd.events = POLLIN;
2193 2194

  
2194 2195
    while (system_working > 0) {
2195 2196
        (void)poll(&pfd, 1, timeout);
2196
        (void)consume_communication_pipe(pfd.fd);
2197
        ccp = consume_communication_pipe(pfd.fd);
2197 2198

  
2198
        if (system_working > 0 && ATOMIC_CAS(timer_pthread.armed, 1, 1)) {
2199
            pthread_kill(main_thread_id, SIGVTALRM);
2200

  
2201
            if (rb_signal_buff_size() || !ubf_threads_empty()) {
2202
                timeout = TIME_QUANTUM_MSEC;
2203
            }
2204
            else {
2205
                ATOMIC_SET(timer_pthread.armed, 0);
2206
                timeout = -1;
2207
            }
2208
        }
2199
        if (system_working > 0) {
2200
	    if (ATOMIC_CAS(timer_pthread.armed, 1, 1)) {
2201
		pthread_kill(main_thread_id, SIGVTALRM);
2202

  
2203
		if (rb_signal_buff_size() || !ubf_threads_empty()) {
2204
		    timeout = TIME_QUANTUM_MSEC;
2205
		}
2206
		else {
2207
		    ATOMIC_SET(timer_pthread.armed, 0);
2208
		    timeout = -1;
2209
		}
2210
	    }
2211
	    else if (ccp) {
2212
		pthread_kill(main_thread_id, SIGVTALRM);
2213
		ATOMIC_SET(timer_pthread.armed, 0);
2214
		timeout = -1;
2215
	    }
2216
	}
2209 2217
    }
2210 2218

  
2211 2219
    return 0;
2212
-