Skip to content

Commit

Permalink
quick fix to keep tab address in thread
Browse files Browse the repository at this point in the history
  • Loading branch information
RealMelkor committed Jun 14, 2022
1 parent fda0f05 commit 74ac922
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/gemini.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ struct gmi_tab* gmi_newtab() {
}

struct gmi_tab* gmi_newtab_url(const char* url) {
int index = client.tabs_count;
size_t index = client.tabs_count;
client.tabs_count++;
if (client.tabs)
client.tabs = realloc(client.tabs, sizeof(struct gmi_tab) * client.tabs_count);
Expand All @@ -793,7 +793,8 @@ struct gmi_tab* gmi_newtab_url(const char* url) {

if (socketpair(AF_UNIX, SOCK_STREAM, 0, tab->thread.pair))
return NULL;
pthread_create(&tab->thread.thread, NULL, (void *(*)(void *))gmi_request_thread, tab);
pthread_create(&tab->thread.thread, NULL,
(void *(*)(void *))gmi_request_thread, (void*)index);
tab->thread.started = 1;
if (url)
gmi_request(tab, url, 1);
Expand Down Expand Up @@ -1368,7 +1369,8 @@ int gmi_request_body(struct gmi_tab* tab) {
}

void* gmi_request_thread(void* ptr) {
struct gmi_tab* tab = ptr;
size_t index = (size_t)ptr;
#define tab (&client.tabs[index])
unsigned int signal = 0;
while (!client.shutdown) {
tab->selected = 0;
Expand Down Expand Up @@ -1609,6 +1611,7 @@ void* gmi_request_thread(void* ptr) {
tab->request.recv = tab->page.data_len;
}
}
#undef tab
return NULL;
}

Expand Down

0 comments on commit 74ac922

Please sign in to comment.