/[baselayout]/trunk/src/rc.c
Gentoo

Diff of /trunk/src/rc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 3039 Revision 3040
70static char **newenv = NULL; 70static char **newenv = NULL;
71static char **coldplugged_services = NULL; 71static char **coldplugged_services = NULL;
72static char **stop_services = NULL; 72static char **stop_services = NULL;
73static char **start_services = NULL; 73static char **start_services = NULL;
74static rc_depinfo_t *deptree = NULL; 74static rc_depinfo_t *deptree = NULL;
75static char **types = NULL;
76static char *tmp = NULL; 75static char *tmp = NULL;
77 76
78struct termios *termios_orig = NULL; 77struct termios *termios_orig = NULL;
79 78
80typedef struct pidlist 79typedef struct pidlist
81{ 80{
82 pid_t pid; 81 pid_t pid;
83 struct pidlist *next; 82 struct pidlist *next;
84} pidlist_t; 83} pidlist_t;
85static pidlist_t *service_pids = NULL; 84static pidlist_t *service_pids = NULL;
85
86static const char *types_n[] = { "needsme", NULL };
87static const char *types_nua[] = { "ineed", "iuse", "iafter", NULL };
86 88
87static void cleanup (void) 89static void cleanup (void)
88{ 90{
89 if (applet && strcmp (applet, "rc") == 0) { 91 if (applet && strcmp (applet, "rc") == 0) {
90 pidlist_t *pl = service_pids; 92 pidlist_t *pl = service_pids;
106 rc_strlist_free (newenv); 108 rc_strlist_free (newenv);
107 rc_strlist_free (coldplugged_services); 109 rc_strlist_free (coldplugged_services);
108 rc_strlist_free (stop_services); 110 rc_strlist_free (stop_services);
109 rc_strlist_free (start_services); 111 rc_strlist_free (start_services);
110 rc_deptree_free (deptree); 112 rc_deptree_free (deptree);
111 rc_strlist_free (types);
112 113
113 /* Clean runlevel start, stop markers */ 114 /* Clean runlevel start, stop markers */
114 if (! rc_in_plugin) { 115 if (! rc_in_plugin) {
115 rmdir (RC_STARTING); 116 rmdir (RC_STARTING);
116 rmdir (RC_STOPPING); 117 rmdir (RC_STOPPING);
1151 1152
1152 tmplist = rc_services_in_state (RC_SERVICE_STARTED); 1153 tmplist = rc_services_in_state (RC_SERVICE_STARTED);
1153 rc_strlist_join (&stop_services, tmplist); 1154 rc_strlist_join (&stop_services, tmplist);
1154 rc_strlist_free (tmplist); 1155 rc_strlist_free (tmplist);
1155 1156
1156 types = NULL;
1157 rc_strlist_add (&types, "ineed");
1158 rc_strlist_add (&types, "iuse");
1159 rc_strlist_add (&types, "iafter");
1160
1161 deporder = rc_deptree_depends (deptree, types, stop_services, 1157 deporder = rc_deptree_depends (deptree, types_nua,
1158 (const char **) stop_services,
1162 runlevel, depoptions | RC_DEP_STOP); 1159 runlevel, depoptions | RC_DEP_STOP);
1163 1160
1164 rc_strlist_free (stop_services); 1161 rc_strlist_free (stop_services);
1165 rc_strlist_free (types);
1166 types = NULL;
1167 stop_services = deporder; 1162 stop_services = deporder;
1168 deporder = NULL; 1163 deporder = NULL;
1169 rc_strlist_reverse (stop_services); 1164 rc_strlist_reverse (stop_services);
1170 1165
1171 /* Load our list of coldplugged services */ 1166 /* Load our list of coldplugged services */
1210 1205
1211 /* Save out softlevel now */ 1206 /* Save out softlevel now */
1212 if (going_down) 1207 if (going_down)
1213 rc_runlevel_set (newlevel); 1208 rc_runlevel_set (newlevel);
1214 1209
1215 types = NULL;
1216 rc_strlist_add (&types, "needsme");
1217 /* Now stop the services that shouldn't be running */ 1210 /* Now stop the services that shouldn't be running */
1218 STRLIST_FOREACH (stop_services, service, i) { 1211 STRLIST_FOREACH (stop_services, service, i) {
1219 bool found = false; 1212 bool found = false;
1220 char *conf = NULL; 1213 char *conf = NULL;
1221 char **stopdeps = NULL; 1214 char **stopdeps = NULL;
1272 } 1265 }
1273 1266
1274 /* We got this far! Or last check is to see if any any service that 1267 /* We got this far! Or last check is to see if any any service that
1275 going to be started depends on us */ 1268 going to be started depends on us */
1276 rc_strlist_add (&stopdeps, service); 1269 rc_strlist_add (&stopdeps, service);
1277 deporder = rc_deptree_depends (deptree, types, stopdeps, 1270 deporder = rc_deptree_depends (deptree, types_n,
1271 (const char **) stopdeps,
1278 runlevel, RC_DEP_STRICT); 1272 runlevel, RC_DEP_STRICT);
1279 rc_strlist_free (stopdeps); 1273 rc_strlist_free (stopdeps);
1280 stopdeps = NULL; 1274 stopdeps = NULL;
1281 found = false; 1275 found = false;
1282 STRLIST_FOREACH (deporder, svc1, j) { 1276 STRLIST_FOREACH (deporder, svc1, j) {
1296 pid_t pid = rc_service_stop (service); 1290 pid_t pid = rc_service_stop (service);
1297 if (pid > 0 && ! rc_env_bool ("RC_PARALLEL")) 1291 if (pid > 0 && ! rc_env_bool ("RC_PARALLEL"))
1298 wait_pid (pid); 1292 wait_pid (pid);
1299 } 1293 }
1300 } 1294 }
1301 rc_strlist_free (types);
1302 types = NULL;
1303 1295
1304 /* Wait for our services to finish */ 1296 /* Wait for our services to finish */
1305 wait_for_services (); 1297 wait_for_services ();
1306 1298
1307 /* Notify the plugins we have finished */ 1299 /* Notify the plugins we have finished */
1339 /* Re-add our coldplugged services if they stopped */ 1331 /* Re-add our coldplugged services if they stopped */
1340 STRLIST_FOREACH (coldplugged_services, service, i) 1332 STRLIST_FOREACH (coldplugged_services, service, i)
1341 rc_service_mark (service, RC_SERVICE_COLDPLUGGED); 1333 rc_service_mark (service, RC_SERVICE_COLDPLUGGED);
1342 1334
1343 /* Order the services to start */ 1335 /* Order the services to start */
1344 rc_strlist_add (&types, "ineed");
1345 rc_strlist_add (&types, "iuse");
1346 rc_strlist_add (&types, "iafter");
1347 deporder = rc_deptree_depends (deptree, types, start_services, 1336 deporder = rc_deptree_depends (deptree, types_nua,
1337 (const char **) start_services,
1348 runlevel, depoptions | RC_DEP_START); 1338 runlevel, depoptions | RC_DEP_START);
1349 rc_strlist_free (types);
1350 types = NULL;
1351 rc_strlist_free (start_services); 1339 rc_strlist_free (start_services);
1352 start_services = deporder; 1340 start_services = deporder;
1353 deporder = NULL; 1341 deporder = NULL;
1354 1342
1355#ifdef __linux__ 1343#ifdef __linux__

Legend:
Removed from v.3039  
changed lines
  Added in v.3040

  ViewVC Help
Powered by ViewVC 1.1.20