Commit Diff


commit - a0f7ab52b6f2063f302189e825fe5cd83bc7f4c3
commit + 50f036824c2c9c860754f608c478c909642bdab1
blob - 626acdd09c64f839c2167ded50fb825bc3689705
blob + 5e8a17493f800dd8c5af5c9850a5bfbcd2655d9d
--- fs.c
+++ fs.c
@@ -43,7 +43,7 @@ static void		 handle_get(struct imsg*, size_t);
 static int		 select_non_dot(const struct dirent *);
 static int		 select_non_dotdot(const struct dirent *);
 static void		 handle_get_file(struct imsg*, size_t);
-static void		 handle_quit(struct imsg*, size_t);
+static void		 handle_misc(struct imsg *, size_t);
 static void		 handle_bookmark_page(struct imsg*, size_t);
 static void		 handle_save_cert(struct imsg*, size_t);
 static void		 handle_update_cert(struct imsg*, size_t);
@@ -58,6 +58,7 @@ static size_t		 join_path(char*, const char*, const ch
 static void		 getenv_default(char*, const char*, const char*, size_t);
 static void		 mkdirs(const char*, mode_t);
 static void		 xdg_init(void);
+static void		 load_last_session(void);
 
 static struct imsgev		*iev_ui;
 static FILE			*session;
@@ -88,7 +89,8 @@ char		session_file[PATH_MAX];
 static imsg_handlerfn *handlers[] = {
 	[IMSG_GET] = handle_get,
 	[IMSG_GET_FILE] = handle_get_file,
-	[IMSG_QUIT] = handle_quit,
+	[IMSG_QUIT] = handle_misc,
+	[IMSG_INIT] = handle_misc,
 	[IMSG_BOOKMARK_PAGE] = handle_bookmark_page,
 	[IMSG_SAVE_CERT] = handle_save_cert,
 	[IMSG_UPDATE_CERT] = handle_update_cert,
@@ -333,12 +335,22 @@ handle_get_file(struct imsg *imsg, size_t datalen)
 }
 
 static void
-handle_quit(struct imsg *imsg, size_t datalen)
-{
-	if (!safe_mode)
-		unlink(crashed_file);
+handle_misc(struct imsg *imsg, size_t datalen)
+{
+	switch (imsg->hdr.type) {
+	case IMSG_INIT:
+		load_last_session();
+		break;
 
-	event_loopbreak();
+	case IMSG_QUIT:
+		if (!safe_mode)
+			unlink(crashed_file);
+		event_loopbreak();
+		break;
+
+	default:
+		die();
+	}
 }
 
 static void
@@ -738,7 +750,7 @@ sendhist(const char *uri, int future)
 }
 
 static void
-load_last_session(int fd, short event, void *d)
+load_last_session(void)
 {
 	FILE		*session;
 	uint32_t	 flags;
@@ -784,9 +796,6 @@ end:
 int
 fs_main(void)
 {
-	struct event ev;
-	struct timeval t = {0, 0};
-
 	setproctitle("fs");
 
 	fs_init();
@@ -805,14 +814,6 @@ fs_main(void)
 
 	sandbox_fs_process();
 
-	/*
-	 * Run load_last_session during the event loop, as soon as
-	 * possible; it uses fs_send_ui so it can't be ran outside
-	 * of event_dispatch.
-	 */
-	evtimer_set(&ev, load_last_session, NULL);
-	evtimer_add(&ev, &t);
-
 	event_dispatch();
 	return 0;
 }
blob - eed4139686565bc6aa1457e6ca0f8cb5feee90c2
blob + 0d06700ce88a704696aab7f7a764ba1ac8ff670b
--- telescope.c
+++ telescope.c
@@ -1241,6 +1241,7 @@ main(int argc, char * const *argv)
 
 	if (ui_init()) {
 		sandbox_ui_process();
+		ui_send_fs(IMSG_INIT, 0, NULL, 0);
 		event_dispatch();
 		ui_end();
 	}
blob - 8fda4e4d9bd99b892d3cc5a29d9a629e15bdc0db
blob + 1755f633562bf7c0c8bfeeea22085afc9ce45b1c
--- telescope.h
+++ telescope.h
@@ -57,6 +57,7 @@ enum imsg_type {
 	IMSG_QUIT,
 
 	/* ui <-> fs */
+	IMSG_INIT,
 	IMSG_BOOKMARK_PAGE,
 	IMSG_BOOKMARK_OK,
 	IMSG_SAVE_CERT,