Skip to content

Commit

Permalink
fix thread conflict when passing arg as pointer
Browse files Browse the repository at this point in the history
fix thread conflict when passing arg as pointer
  • Loading branch information
EZLippi authored May 15, 2017
1 parent 7c55024 commit 647e8c7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions httpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void unimplemented(int);
/**********************************************************************/
void accept_request(void *arg)
{
int client = *(int*)arg;
int client = (intptr_t)arg;
char buf[1024];
size_t numchars;
char method[255];
Expand Down Expand Up @@ -506,7 +506,7 @@ int main(void)
if (client_sock == -1)
error_die("accept");
/* accept_request(&client_sock); */
if (pthread_create(&newthread , NULL, (void *)accept_request, (void *)&client_sock) != 0)
if (pthread_create(&newthread , NULL, (void *)accept_request, (void *)(intptr_t)client_sock) != 0)
perror("pthread_create");
}

Expand Down

0 comments on commit 647e8c7

Please sign in to comment.