Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 692092
Collapse All | Expand All

(-)a/base/events.c (-6 / +6 lines)
Lines 351-363 void init_timing_loop(void) { Link Here
351
			 */
351
			 */
352
			check_delay =
352
			check_delay =
353
					mult_factor * scheduling_info.service_inter_check_delay;
353
					mult_factor * scheduling_info.service_inter_check_delay;
354
			time_t check_window = reschedule_within_timeperiod(next_valid_time, temp_service->check_period_ptr, check_window(temp_service)) - current_time;
354
			if(check_delay > check_window(temp_service)) {
355
			if(check_delay > check_window) {
356
				log_debug_info(DEBUGL_EVENTS, 0,
355
				log_debug_info(DEBUGL_EVENTS, 0,
357
						"  Fixing check time %lu secs too far away\n",
356
						"  Fixing check time %lu secs too far away\n",
358
						check_delay - check_window);
357
						check_delay - check_window(temp_service));
359
				fixed_services++;
358
				fixed_services++;
360
				check_delay = check_window;
359
				check_delay = check_window(temp_service);
361
				log_debug_info(DEBUGL_EVENTS, 0, "  New check offset: %d\n",
360
				log_debug_info(DEBUGL_EVENTS, 0, "  New check offset: %d\n",
362
						check_delay);
361
						check_delay);
363
			}
362
			}
Lines 370-376 void init_timing_loop(void) { Link Here
370
			if(is_valid_time == ERROR) {
369
			if(is_valid_time == ERROR) {
371
				log_debug_info(DEBUGL_EVENTS, 2, "Preferred Time is Invalid In Timeperiod '%s': %lu --> %s\n", temp_service->check_period_ptr->name, (unsigned long)temp_service->next_check, ctime(&temp_service->next_check));
370
				log_debug_info(DEBUGL_EVENTS, 2, "Preferred Time is Invalid In Timeperiod '%s': %lu --> %s\n", temp_service->check_period_ptr->name, (unsigned long)temp_service->next_check, ctime(&temp_service->next_check));
372
				get_next_valid_time(temp_service->next_check, &next_valid_time, temp_service->check_period_ptr);
371
				get_next_valid_time(temp_service->next_check, &next_valid_time, temp_service->check_period_ptr);
373
				temp_service->next_check = reschedule_within_timeperiod(next_valid_time, temp_service->check_period_ptr, check_window(temp_service));
372
				temp_service->next_check = 
373
					(time_t)(next_valid_time + check_delay);
374
				}
374
				}
375
375
376
			log_debug_info(DEBUGL_EVENTS, 2, "Actual Check Time: %lu --> %s\n", (unsigned long)temp_service->next_check, ctime(&temp_service->next_check));
376
			log_debug_info(DEBUGL_EVENTS, 2, "Actual Check Time: %lu --> %s\n", (unsigned long)temp_service->next_check, ctime(&temp_service->next_check));
Lines 508-514 void init_timing_loop(void) { Link Here
508
			log_debug_info(DEBUGL_EVENTS, 1, "Fixing check time (off by %lu)\n",
508
			log_debug_info(DEBUGL_EVENTS, 1, "Fixing check time (off by %lu)\n",
509
					check_delay - check_window(temp_host));
509
					check_delay - check_window(temp_host));
510
			fixed_hosts++;
510
			fixed_hosts++;
511
			check_delay = reschedule_within_timeperiod(next_valid_time, temp_host->check_period_ptr, check_window(temp_host));
511
			check_delay = ranged_urand(0, check_window(temp_host));
512
			}
512
			}
513
		temp_host->next_check = (time_t)(current_time + check_delay);
513
		temp_host->next_check = (time_t)(current_time + check_delay);
514
514
(-)a/cgi/status.c (-3 / +21 lines)
Lines 221-228 int main(void) { Link Here
221
	document_header(TRUE);
221
	document_header(TRUE);
222
222
223
	/* if a navbar search was performed, find the host by name, address or partial name */
223
	/* if a navbar search was performed, find the host by name, address or partial name */
224
	if(navbar_search == TRUE) {
224
	if(navbar_search == TRUE && host_name != NULL) {
225
		if(host_name != NULL && NULL != strstr(host_name, "*")) {
225
226
		/* Remove trailing spaces from host_name */
227
		len = strlen(host_name);
228
		for (i = len - 1; i >= 0; i--) {
229
			if (!isspace(host_name[i])) {
230
				host_name[i+1] = '\0';
231
				break;
232
			}
233
		}
234
235
		/* Remove leading spaces from host_name */
236
		for (i = 0; i < len; i++) {
237
			if (!isspace(host_name[i])) {
238
				break;
239
			}
240
		}
241
		strcpy(host_name, host_name + i);
242
243
		if(NULL != strstr(host_name, "*")) {
226
			/* allocate for 3 extra chars, ^, $ and \0 */
244
			/* allocate for 3 extra chars, ^, $ and \0 */
227
			host_filter = malloc(sizeof(char) * (strlen(host_name) * 2 + 3));
245
			host_filter = malloc(sizeof(char) * (strlen(host_name) * 2 + 3));
228
			len = strlen(host_name);
246
			len = strlen(host_name);
Lines 238-244 int main(void) { Link Here
238
			host_filter[regex_i++] = '$';
256
			host_filter[regex_i++] = '$';
239
			host_filter[regex_i] = '\0';
257
			host_filter[regex_i] = '\0';
240
			}
258
			}
241
		else if (host_name != NULL) {
259
		else {
242
			if((temp_host = find_host(host_name)) == NULL) {
260
			if((temp_host = find_host(host_name)) == NULL) {
243
				for(temp_host = host_list; temp_host != NULL; temp_host = temp_host->next) {
261
				for(temp_host = host_list; temp_host != NULL; temp_host = temp_host->next) {
244
					if(is_authorized_for_host(temp_host, &current_authdata) == FALSE)
262
					if(is_authorized_for_host(temp_host, &current_authdata) == FALSE)
(-)a/lib/worker.c (-16 / +8 lines)
Lines 215-221 int worker_buf2kvvec_prealloc(struct kvvec *kvv, char *buf, unsigned long len, i Link Here
215
	} while (0)
215
	} while (0)
216
216
217
/* forward declaration */
217
/* forward declaration */
218
static int gather_output(child_process *cp, iobuf *io, int final);
218
static void gather_output(child_process *cp, iobuf *io, int final);
219
219
220
static void destroy_job(child_process *cp)
220
static void destroy_job(child_process *cp)
221
{
221
{
Lines 258-280 static void destroy_job(child_process *cp) Link Here
258
int finish_job(child_process *cp, int reason)
258
int finish_job(child_process *cp, int reason)
259
{
259
{
260
	static struct kvvec resp = KVVEC_INITIALIZER;
260
	static struct kvvec resp = KVVEC_INITIALIZER;
261
	int i, ret, rd;
261
	int i, ret;
262
262
263
	/* get rid of still open filedescriptors */
263
	/* get rid of still open filedescriptors */
264
	if (cp->outstd.fd != -1) {
264
	if (cp->outstd.fd != -1) {
265
265
		gather_output(cp, &cp->outstd, 1);
266
		rd = 1;
267
		while(rd > 0) {
268
			rd = gather_output(cp, &cp->outstd, 0);
269
		}
270
		iobroker_close(iobs, cp->outstd.fd);
266
		iobroker_close(iobs, cp->outstd.fd);
271
	}
267
	}
272
	if (cp->outerr.fd != -1) {
268
	if (cp->outerr.fd != -1) {
273
269
		gather_output(cp, &cp->outerr, 1);
274
		rd = 1;
275
		while(rd > 0) {
276
			rd = gather_output(cp, &cp->outerr, 0);
277
		}
278
		iobroker_close(iobs, cp->outerr.fd);
270
		iobroker_close(iobs, cp->outerr.fd);
279
	}
271
	}
280
272
Lines 450-462 static void kill_job(child_process *cp, int reason) Link Here
450
	destroy_job(cp);
442
	destroy_job(cp);
451
}
443
}
452
444
453
static int gather_output(child_process *cp, iobuf *io, int final)
445
static void gather_output(child_process *cp, iobuf *io, int final)
454
{
446
{
455
	int retry = 5;
447
	int retry = 5;
456
	int rd;
457
448
458
	for (;;) {
449
	for (;;) {
459
		char buf[4096];
450
		char buf[4096];
451
		int rd;
460
452
461
		rd = read(io->fd, buf, sizeof(buf));
453
		rd = read(io->fd, buf, sizeof(buf));
462
		if (rd < 0) {
454
		if (rd < 0) {
Lines 492-504 static int gather_output(child_process *cp, iobuf *io, int final) Link Here
492
		if (rd <= 0 || final) {
484
		if (rd <= 0 || final) {
493
			iobroker_close(iobs, io->fd);
485
			iobroker_close(iobs, io->fd);
494
			io->fd = -1;
486
			io->fd = -1;
487
			if (!final)
488
				check_completion(cp, WNOHANG);
495
			break;
489
			break;
496
		}
490
		}
497
491
498
		break;
492
		break;
499
	}
493
	}
500
501
	return rd;
502
}
494
}

Return to bug 692092