commit - 5d6c2088a3eb3f06195f5ac576f9c4fd673fae3b
commit + f62430128523de1dae839509ac85e28fa4fa464d
blob - 64512510844f0c1de085546ef2e52d3731b501b2
blob + 06045f111b22cb336a414b93ebc84d74c367ccd0
--- telescope.c
+++ telescope.c
}
static struct tab *
-tab_by_id_try(uint32_t id)
+tab_by_id(uint32_t id)
{
struct tab *t;
return NULL;
}
-static struct tab *
-tab_by_id(uint32_t id)
-{
- struct tab *t;
-
- if ((t = tab_by_id_try(id)) == NULL)
- die();
- return t;
-}
-
static void
handle_imsg_err(struct imsg *imsg, size_t datalen)
{
struct tab *tab;
char *page;
- tab = tab_by_id(imsg->hdr.peerid);
+ if ((tab = tab_by_id(imsg->hdr.peerid)) == NULL)
+ return;
page = imsg->data;
page[datalen-1] = '\0';
if (hash[datalen-1] != '\0')
abort();
- tab = tab_by_id(imsg->hdr.peerid);
+ if ((tab = tab_by_id(imsg->hdr.peerid)) == NULL)
+ return;
if (tab->proxy != NULL) {
host = tab->proxy->host;
{
struct tab *tab;
- tab = tab_by_id(imsg->hdr.peerid);
+ if ((tab = tab_by_id(imsg->hdr.peerid)) == NULL)
+ return;
if (sizeof(tab->code) != datalen)
die();
{
struct tab *tab;
- tab = tab_by_id(imsg->hdr.peerid);
+ if ((tab = tab_by_id(imsg->hdr.peerid)) == NULL)
+ return;
if (sizeof(tab->meta) <= datalen)
die();
const char *e;
int l;
- tab = tab_by_id(imsg->hdr.peerid);
+ if ((tab = tab_by_id(imsg->hdr.peerid)) == NULL) {
+ if (imsg->fd != -1)
+ close(imsg->fd);
+ return;
+ }
if (imsg->fd == -1) {
stop_tab(tab);
int l;
char *page, buf[FMT_SCALED_STRSIZE] = {0};
- if ((tab = tab_by_id(imsg->hdr.peerid)) == NULL) {
- /*
- * Since messages between ui and net are asynchronous,
- * we could be in a case where we sent a tab_stop
- * command, but still receive data for the old id. My
- * initial idea of crashing on invalid tab ids just
- * doesn't scale well in an asynchronous world.
- */
+ if ((tab = tab_by_id(imsg->hdr.peerid)) == NULL)
return;
- }
tab->bytes += datalen;
if (tab->fd == -1) {
int l;
char *page, buf[FMT_SCALED_STRSIZE] = {0};
- tab = tab_by_id(imsg->hdr.peerid);
+ if ((tab = tab_by_id(imsg->hdr.peerid)) == NULL)
+ return;
if (tab->fd == -1) {
if (!tab->buffer.page.free(&tab->buffer.page))