]> xenbits.xensource.com Git - unikraft/libs/lwip.git/commitdiff
Implement closing of sockets descriptor with libvfscore
authorSharan Santhanam <sharan.santhanam@neclab.eu>
Wed, 13 Jun 2018 00:24:57 +0000 (02:24 +0200)
committerSimon Kuenzer <simon.kuenzer@neclab.eu>
Fri, 15 Jun 2018 01:21:07 +0000 (03:21 +0200)
Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
socket_glue.c

index 5fdfb7e98ac1ac8025f32424a04afffdf70aabad..77cc34ea8242cc54a70d29eff1a8588a415c9a35 100644 (file)
@@ -74,6 +74,18 @@ UK_MEM_ALLOC_ERR:
 static int sock_net_close(struct vfscore_file *vfscore_file)
 {
        int    ret = 0;
+       struct sock_net_file *file = NULL;
+       file = __containerof(vfscore_file, struct sock_net_file, vfscore_file);
+
+       uk_printd(DLVL_EXTRA, NET_LIB_NAME": close() %d (%x)\n",
+                       file->vfscore_file.fd, file->sock_fd);
+
+       /* Close and release the lwip socket */
+       ret = lwip_close(file->sock_fd);
+       /* Release the file descriptor */
+       vfscore_put_fd(file->vfscore_file.fd);
+       /* Free the sock net structure */
+       uk_free(uk_alloc_get_default(), file);
        return ret;
 }
 
@@ -210,6 +222,18 @@ EXIT:
 int shutdown(int s, int how)
 {
        int ret = 0;
+       struct sock_net_file *file = NULL;
+       file = sock_net_file_get(s);
+       if(PTRISERR(file)) {
+               uk_printd(DLVL_ERR, "failed to identify the socket descriptor \n");
+               ret = -1;
+               /* Setting the errno */
+               SOCK_NET_SET_ERRNO(PTR2ERR(file));
+               goto EXIT;
+       }
+       /* Shutdown of the descriptor */
+       ret = lwip_shutdown(file->sock_fd, how);
+EXIT:
        return ret;
 }