Skip to content

Commit

Permalink
Fix bug #34: wrong remote_addr reported
Browse files Browse the repository at this point in the history
  • Loading branch information
william-os4y committed Mar 3, 2012
1 parent 573908d commit d468475
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fapws/mainloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ void close_connection(struct client *cli)
{
if (debug)
printf("host=%s,port=%i close_connection:cli:%p, input_header:%p***\n",cli->remote_addr, cli->remote_port, cli, cli->input_header);
free(cli->remote_addr);
free(cli->input_header);
free(cli->cmd);
free(cli->uri);
Expand Down Expand Up @@ -777,8 +778,8 @@ void accept_cb(struct ev_loop *loop, struct ev_io *w, int revents)
cli->input_pos=0;
cli->retry=0;
cli->response_iter_sent=-2;
cli->remote_addr=inet_ntoa (client_addr.sin_addr);
cli->remote_port=ntohs(client_addr.sin_port);
cli->remote_addr = strdup(inet_ntoa(client_addr.sin_addr));
cli->remote_port = ntohs(client_addr.sin_port);
if (setnonblock(cli->fd) < 0)
fprintf(stderr, "failed to set client socket to non-blocking");
ev_io_init(&cli->ev_read,connection_cb,cli->fd,EV_READ);
Expand Down

0 comments on commit d468475

Please sign in to comment.