MCPcopy Create free account
hub / github.com/dillo-browser/dillo / main

Function main

dpid/main.c:227–422  ·  view source on GitHub ↗

! \todo * \li Add a dpid_idle_timeout variable to dpidrc * \bug Infinite loop if plugin crashes before it accepts a connection */

Source from the content-addressed store, hash-verified

225 * \bug Infinite loop if plugin crashes before it accepts a connection
226 */
227int main(void)
228{
229 int i, n = 0, open_max;
230 int dpid_idle_timeout = 60 * 60; /* default, in seconds */
231 struct timeval select_timeout;
232 sigset_t mask_none;
233 fd_set selected_set;
234
235 dpi_attr_list = NULL;
236 services_list = NULL;
237 //daemon(0,0); /* Use 0,1 for feedback */
238 /* TODO: call setsid() ?? */
239
240 /* Allow read and write access, but only for the user.
241 * TODO: can this cause trouble with umount? */
242 umask(0077);
243 /* TODO: make dpid work on any directory. */
244 // chdir("/");
245
246 /* close inherited file descriptors */
247 open_max = get_open_max();
248 for (i = 3; i < open_max; i++)
249 dClose(i);
250
251 /* this sleep used to unmask a race condition */
252 // sleep(2);
253
254 dpi_errno = no_errors;
255
256 /* Get list of available dpis */
257 numdpis = register_all(&dpi_attr_list);
258
259#if 0
260 /* Get name of socket directory */
261 dirname = a_Dpi_sockdir_file();
262 if ((sockdir = init_sockdir(dirname)) == NULL) {
263 ERRMSG("main", "init_sockdir", 0);
264 MSG_ERR("Failed to create socket directory\n");
265 exit(1);
266 }
267#endif
268
269 /* Init and get services list */
270 fill_services_list(dpi_attr_list, numdpis, &services_list);
271
272 /* Remove any sockets that may have been leftover from a crash */
273 //cleanup();
274
275 /* Initialise sockets */
276 if ((numsocks = init_ids_srs_socket()) == -1) {
277 switch (dpi_errno) {
278 case dpid_srs_addrinuse:
279 MSG_ERR("dpid refuses to start, possibly because:\n");
280 MSG_ERR("\t1) An instance of dpid is already running.\n");
281 MSG_ERR("\t2) A previous dpid didn't clean up on exit.\n");
282 exit(1);
283 default:
284 //ERRMSG("main", "init_srs_socket failed", 0);

Callers

nothing calls this directly

Calls 15

get_open_maxFunction · 0.85
dCloseFunction · 0.85
register_allFunction · 0.85
a_Dpi_sockdir_fileFunction · 0.85
init_sockdirFunction · 0.85
fill_services_listFunction · 0.85
init_ids_srs_socketFunction · 0.85
init_all_dpi_socketsFunction · 0.85
est_dpi_terminatorFunction · 0.85
est_dpi_sigchldFunction · 0.85
handle_sigchldFunction · 0.85
server_is_runningFunction · 0.85

Tested by

no test coverage detected