Changeset 3f7e1f24 in mainline for uspace/srv/sysman/main.c
- Timestamp:
- 2019-08-03T08:28:26Z (6 years ago)
- Children:
- 095d03c
- Parents:
- d7c5fc0
- git-author:
- Michal Koutný <xm.koutny+hos@…> (2015-04-22 17:54:08)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2019-08-03 08:28:26)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/sysman/main.c
rd7c5fc0 r3f7e1f24 37 37 #include "dep.h" 38 38 #include "job.h" 39 #include "log.h" 39 40 #include "sysman.h" 40 41 #include "unit.h" … … 47 48 } 48 49 49 static int sysman_entry_point(void *arg) { 50 /* 51 * Build hard coded configuration. 52 * 53 * Strings are allocated on heap, so that they can be free'd by an 54 * owning unit. 55 */ 50 /** Build hard coded configuration */ 51 static job_t *create_entry_configuration(void) { 56 52 int result = EOK; 57 53 unit_t *mnt_initrd = NULL; … … 107 103 configuration_commit(); 108 104 109 result = sysman_unit_start(tgt_default); 110 111 return result; 105 job_t *first_job = job_create(tgt_default, STATE_STARTED); 106 if (first_job == NULL) { 107 goto fail; 108 } 109 return first_job; 112 110 113 111 fail: 112 // TODO cannot destroy units after they're added to configuration 114 113 unit_destroy(&tgt_default); 115 114 unit_destroy(&cfg_init); 116 115 unit_destroy(&mnt_initrd); 117 return result; 116 return NULL; 117 } 118 119 static void first_job_handler(void *object, void *unused) 120 { 121 job_t *job = object; 122 sysman_log(LVL_DEBUG, "First job retval: %i.", job->retval); 123 job_del_ref(&job); 118 124 } 119 125 … … 122 128 printf(NAME ": HelenOS system daemon\n"); 123 129 130 /* 131 * Initialize global structures 132 */ 124 133 configuration_init(); 134 sysman_events_init(); 125 135 job_queue_init(); 126 136 127 137 /* 128 * Create and start initial configuration asynchronously 129 * so that we can start server's fibril that may be used 130 * when executing the start. 138 * Create initial configuration while we are in a single fibril, keep 139 * the job and run it when event loop is running. 131 140 */ 132 fid_t entry_fibril = fibril_create(sysman_entry_point, NULL); 133 fibril_add_ready(entry_fibril); 141 job_t *first_job = create_entry_configuration(); 134 142 135 /* Prepare and start sysman server */ 143 /* 144 * Event loop runs in separate fibril, all consequent access to global 145 * structure is made from this fibril only. 146 */ 147 fid_t event_loop_fibril = fibril_create(sysman_events_loop, NULL); 148 fibril_add_ready(event_loop_fibril); 149 150 /* Queue first job for processing */ 151 sysman_object_observer(first_job, &first_job_handler, NULL); 152 sysman_raise_event(&sysman_event_job_process, first_job); 153 154 /* Start sysman server */ 136 155 async_set_client_connection(sysman_connection); 137 156 … … 139 158 async_manager(); 140 159 160 /* not reached */ 141 161 return 0; 142 162 }
Note:
See TracChangeset
for help on using the changeset viewer.