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

(-)openrc-orig/src/includes/rc-misc.h (+1 lines)
Lines 32-37 Link Here
32
#define RC_LEVEL_DEFAULT        "default"
32
#define RC_LEVEL_DEFAULT        "default"
33
33
34
#define RC_DEPTREE_CACHE        RC_SVCDIR "/deptree"
34
#define RC_DEPTREE_CACHE        RC_SVCDIR "/deptree"
35
#define RC_DEPTREE_CACHE_BOOT   RC_SYSCONFDIR "/rc_deptree_boot"
35
#define RC_DEPTREE_SKEWED	RC_SVCDIR "/clock-skewed"
36
#define RC_DEPTREE_SKEWED	RC_SVCDIR "/clock-skewed"
36
#define RC_KRUNLEVEL            RC_SVCDIR "/krunlevel"
37
#define RC_KRUNLEVEL            RC_SVCDIR "/krunlevel"
37
#define RC_STARTING             RC_SVCDIR "/rc.starting"
38
#define RC_STARTING             RC_SVCDIR "/rc.starting"
(-)openrc-orig/src/rc/rc-misc.c (-8 / +37 lines)
Lines 354-359 Link Here
354
RC_DEPTREE * _rc_deptree_load(int force, int *regen)
354
RC_DEPTREE * _rc_deptree_load(int force, int *regen)
355
{
355
{
356
	int fd;
356
	int fd;
357
	int fd_boot;
358
	char ch;
357
	int retval;
359
	int retval;
358
	int serrno = errno;
360
	int serrno = errno;
359
	int merrno;
361
	int merrno;
Lines 362-377 Link Here
362
	struct stat st;
364
	struct stat st;
363
	struct utimbuf ut;
365
	struct utimbuf ut;
364
	FILE *fp;
366
	FILE *fp;
367
	
368
	struct timeval t_b, t_a, t_r;
365
369
370
	/* Test if we have permission to update the deptree */
371
	fd = open(RC_DEPTREE_CACHE, O_WRONLY | O_NOFOLLOW);
372
	merrno = errno;
373
	errno = serrno;
374
	if (fd == -1 && merrno == EACCES)
375
		return rc_deptree_load();
376
	close(fd);
377
378
	/* bench */
379
	gettimeofday(&t_b, NULL);
380
	
381
        /* If RC_DEPTREE_CACHE_BOOT exists and RC_DEPTREE_CACHE doesn't exists, we're booting and we will reuse RC_DEPTREE_CACHE_BOOT */
382
	if (!exists(RC_DEPTREE_CACHE) && exists(RC_DEPTREE_CACHE_BOOT)) {
383
		fd_boot = fopen(RC_DEPTREE_CACHE_BOOT, "r");
384
		if (fd_boot != NULL) {
385
			fd = fopen(RC_DEPTREE_CACHE, "w");
386
			if (fd != NULL) {
387
				ebegin("Reusing service dependencies cache");
388
				while( ( ch = fgetc(fd_boot) ) != EOF )
389
					fputc(ch, fd);
390
				fclose(fd);
391
				}
392
			fclose(fd_boot);
393
		}
394
	}
395
	
366
	t = 0;
396
	t = 0;
367
	if (rc_deptree_update_needed(&t, file) || force != 0) {
397
	if (rc_deptree_update_needed(&t, file) || force != 0) {
368
		/* Test if we have permission to update the deptree */
369
		fd = open(RC_DEPTREE_CACHE, O_WRONLY);
370
		merrno = errno;
371
		errno = serrno;
372
		if (fd == -1 && merrno == EACCES)
373
			return rc_deptree_load();
374
		close(fd);
375
398
376
		if (regen)
399
		if (regen)
377
			*regen = 1;
400
			*regen = 1;
Lines 380-386 Link Here
380
		eend (retval, "Failed to update the dependency tree");
403
		eend (retval, "Failed to update the dependency tree");
381
404
382
		if (retval == 0) {
405
		if (retval == 0) {
383
			stat(RC_DEPTREE_CACHE, &st);
406
			if (stat(RC_DEPTREE_CACHE, &st) != 0) {
407
				eerror("stat(%s): %s", RC_DEPTREE_CACHE, strerror(errno));
408
				return NULL;
409
			}
384
			if (st.st_mtime < t) {
410
			if (st.st_mtime < t) {
385
				eerror("Clock skew detected with `%s'", file);
411
				eerror("Clock skew detected with `%s'", file);
386
				eerrorn("Adjusting mtime of `" RC_DEPTREE_CACHE
412
				eerrorn("Adjusting mtime of `" RC_DEPTREE_CACHE
Lines 401-406 Link Here
401
		if (force == -1 && regen != NULL)
427
		if (force == -1 && regen != NULL)
402
			*regen = retval;
428
			*regen = retval;
403
	}
429
	}
430
	gettimeofday(&t_a, NULL);
431
	timersub(&t_a, &t_b, &t_r);
432
	ebegin("Time elapsed: %ld.%06ld\n", (long int)t_r.tv_sec, (long int)t_r.tv_usec);
404
	return rc_deptree_load();
433
	return rc_deptree_load();
405
}
434
}
406
435

Return to bug 651246