Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 391945 | Differences between
and this patch

Collapse All | Expand All

(-)a/src/librc/librc-depend.c (+59 lines)
Lines 442-447 visit_service(const RC_DEPTREE *deptree, Link Here
442
	}
442
	}
443
}
443
}
444
444
445
static void
446
remove_wrong_depends(RC_DEPTREE *deptree, const char *type)
447
{
448
	/* Remove wrong dependencies:
449
	 *    svc1 > svc2 > svc3 > svc1
450
	 *    svc1 < svc2 < svc3 < svc1
451
	 * '>' means 'ibefore', '<' means 'iafter'.
452
	 */
453
454
	RC_DEPINFO *depinfo = NULL, *di, *di2;
455
	RC_DEPTYPE *deptype = NULL, *dt, *dt2;
456
	RC_STRING *s, *s_np, *s2, *s2_np, *s3, *s3_np;
457
	char *svc1, *svc2, *svc3;
458
459
	TAILQ_FOREACH(depinfo, deptree, entries) {
460
		if ((deptype = get_deptype(depinfo, type))) {
461
			svc1 = depinfo->service;
462
			TAILQ_FOREACH_SAFE(s, deptype->services, entries, s_np) {
463
				svc2 = s->value; // svc2 != svc1
464
				if ((di = get_depinfo(deptree, svc2)) &&
465
					(dt = get_deptype(di, type))) {
466
					TAILQ_FOREACH_SAFE(s2, dt->services, entries, s2_np) {
467
						svc3 = s2->value; // svc3 != svc2 && svc3 != svc1
468
						if (strcmp(svc3, svc1) &&
469
							(di2 = get_depinfo(deptree, svc3)) &&
470
							(dt2 = get_deptype(di2, type))) {
471
							TAILQ_FOREACH_SAFE(s3, dt2->services, entries, s3_np) {
472
								if (!strcmp(s3->value, svc1)) {
473
									/* svc1 > svc2 > svc3 > (s3->value) = svc1 */
474
									// printf("Wrong deps: %s %s %s\n", svc1, svc2, svc3);
475
476
									/* Remove svc3 > svc1, svc2 > svc3 and svc1 > svc2. */
477
									rc_stringlist_delete(dt2->services, svc1);
478
									rc_stringlist_delete(dt->services, svc3);
479
									rc_stringlist_delete(deptype->services, svc2);
480
								}
481
							}
482
						}
483
					}
484
				}
485
			}
486
		}
487
	}
488
489
	/* 1. svc1 > svc2 > svc1 doesn't hang, so we check svc3 != svc1.
490
	 * 2. Assume we have three wrong dependencies:
491
	 *		crypto-loop	>	localmount	>	migrate-run
492
	 *		hwclock		>	localmount	>	migrate-run
493
	 *		localmount	>	migrate-run	>	modules
494
	 *    Remove first one, second and third ones will not be wrong dependencies.
495
	 * 3. We could remove wrong dependencies ( svc1 > svc2 > svc3 > svc4 > svc1 )
496
	 *    in a similar way.
497
	 */
498
}
499
445
RC_STRINGLIST *
500
RC_STRINGLIST *
446
rc_deptree_depend(const RC_DEPTREE *deptree,
501
rc_deptree_depend(const RC_DEPTREE *deptree,
447
		  const char *service, const char *type)
502
		  const char *service, const char *type)
Lines 998-1003 rc_deptree_update(void) Link Here
998
	}
1053
	}
999
	rc_stringlist_free(types);
1054
	rc_stringlist_free(types);
1000
1055
1056
	/* Phase 5.5 - wrong dependencies cause a hang in parallel mode */
1057
	remove_wrong_depends(deptree, "ibefore");
1058
	remove_wrong_depends(deptree, "iafter");
1059
1001
	/* Phase 6 - save to disk
1060
	/* Phase 6 - save to disk
1002
	   Now that we're purely in C, do we need to keep a shell parseable file?
1061
	   Now that we're purely in C, do we need to keep a shell parseable file?
1003
	   I think yes as then it stays human readable
1062
	   I think yes as then it stays human readable

Return to bug 391945