[sheepdog] [PATCH 2/7] net: clean up clear_client()

Yunkai Zhang yunkai.me at gmail.com
Wed Jul 18 12:53:26 CEST 2012


On Wed, Jul 18, 2012 at 5:35 PM, Liu Yuan <namei.unix at gmail.com> wrote:
> From: Liu Yuan <tailai.ly at taobao.com>
>
> - rename it to clear_client_info()
> - move dprintf in it instead of call dprintf every time after clear_client()
> - we don't need call free_request(req), because clear_client() already does it.
>
> Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
> ---
>  sheep/sdnet.c |   18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/sheep/sdnet.c b/sheep/sdnet.c
> index 00ec065..a43a04f 100644
> --- a/sheep/sdnet.c
> +++ b/sheep/sdnet.c
> @@ -391,7 +391,7 @@ static void requeue_request(struct request *req)
>         queue_request(req);
>  }
>
> -static void clear_client(struct client_info *ci);
> +static void clear_client_info(struct client_info *ci);
>
>  static struct request *alloc_local_request(void *data, int data_length)
>  {
> @@ -491,13 +491,10 @@ void put_request(struct request *req)
>                 req->done = 1;
>                 eventfd_write(req->wait_efd, value);
>         } else {
> -               if (conn_tx_on(&ci->conn)) {
> -                       dprintf("connection seems to be dead\n");
> -                       free_request(req);

This free_request is necessary, because req is inflight: not in
rx_req/tx_req/ci->done_reqs.

> -                       clear_client(ci);
> -               } else {
> +               if (conn_tx_on(&ci->conn))
> +                       clear_client_info(ci);
> +               else
>                         list_add(&req->request_list, &ci->done_reqs);
> -               }
>         }
>  }
>
> @@ -662,10 +659,12 @@ static void destroy_client(struct client_info *ci)
>         free(ci);
>  }
>
> -static void clear_client(struct client_info *ci)
> +static void clear_client_info(struct client_info *ci)
>  {
>         struct request *req, *t;
>
> +       dprintf("connection seems to be dead\n");
> +
>         if (ci->rx_req) {
>                 free_request(ci->rx_req);
>                 ci->rx_req = NULL;
> @@ -745,8 +744,7 @@ static void client_handler(int fd, int events, void *data)
>
>         if (is_conn_dead(&ci->conn)) {
>  err:
> -               dprintf("connection seems to be dead\n");
> -               clear_client(ci);
> +               clear_client_info(ci);
>         }
>  }
>
> --
> 1.7.10.2
>
> --
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog



-- 
Yunkai Zhang
Work at Taobao



More information about the sheepdog mailing list