[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Minios-devel] [UNIKRAFT LWIP PATCH v2 4/6] sockets.c: Change error handling to match vfs expectations



Reviewed-by: Costin Lupu <costin.lupu@xxxxxxxxx>

On 6/29/19 4:54 PM, Mihai Pogonaru wrote:
> vfs expects file system functions (vnops) to return 0 on success
> (and update the uio structure) or a positive error number
> in case of an error.
> 
> Signed-off-by: Mihai Pogonaru <pogonarumihai@xxxxxxxxx>
> ---
>  sockets.c | 23 +++++++++++++++++++----
>  1 file changed, 19 insertions(+), 4 deletions(-)
> 
> diff --git a/sockets.c b/sockets.c
> index 1a3ddfd..38639f8 100644
> --- a/sockets.c
> +++ b/sockets.c
> @@ -237,9 +237,18 @@ static int sock_net_close(struct vnode *s_vnode,
>       /*
>        * Free socket file
>        * The rest of the resources will be freed by vfs
> +      *
> +      * TODO: vfs ignores close errors right now, so free our file
>        */
>       uk_free(uk_alloc_get_default(), file);
>  
> +     /*
> +      * lwip sets errno and returns -1 in case of error, but
> +      * vfs expects us to return a positive errno
> +      */
> +     if (ret < 0)
> +             return errno;
> +
>       return ret;
>  }
>  
> @@ -255,9 +264,12 @@ static int sock_net_write(struct vnode *s_vnode,
>                                   file->vfscore_file->fd,
>                                   file->sock_fd));
>       ret = lwip_writev(file->sock_fd, buf->uio_iov, buf->uio_iovcnt);
> -     /* lwip sets errno and returns -1 in case of error */
> +     /*
> +      * lwip sets errno and returns -1 in case of error, but
> +      * vfs expects us to return a positive errno
> +      */
>       if (ret < 0)
> -             return ret;
> +             return errno;
>  
>       buf->uio_resid -= ret;
>       return 0;
> @@ -276,9 +288,12 @@ static int sock_net_read(struct vnode *s_vnode,
>                                   file->vfscore_file->fd,
>                                   file->sock_fd));
>       ret = lwip_readv(file->sock_fd, buf->uio_iov, buf->uio_iovcnt);
> -     /* lwip sets errno and returns -1 in case of error */
> +     /*
> +      * lwip sets errno and returns -1 in case of error, but
> +      * vfs expects us to return a positive errno
> +      */
>       if (ret < 0)
> -             return ret;
> +             return errno;
>  
>       buf->uio_resid -= ret;
>       return 0;
> 

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.