From 572834efe3fe1928ccec2172afa9a51b0da6be0c Mon Sep 17 00:00:00 2001 From: Razvan Deaconescu Date: Sat, 21 May 2011 17:32:59 +0300 Subject: [PATCH] raw: Remove sw_shutdown "syscall". Shutdown is meaningless on connectionless sockets such as swift sockets. --- src/raw/swift_list.c | 1 + src/raw/swift_list.h | 8 ---- src/raw/swift_raw.c | 66 --------------------------------- src/raw/swift_raw.h | 10 ----- src/raw/test/Makefile | 7 ++-- src/raw/test/test.c | 1 - src/raw/test/test_sw.h | 3 -- src/raw/test/test_sw_shutdown.c | 19 ---------- 8 files changed, 5 insertions(+), 110 deletions(-) delete mode 100644 src/raw/test/test_sw_shutdown.c diff --git a/src/raw/swift_list.c b/src/raw/swift_list.c index c177366..1a46e6f 100644 --- a/src/raw/swift_list.c +++ b/src/raw/swift_list.c @@ -24,6 +24,7 @@ #include "swift_types.h" #include "swift_list.h" + /* * Add new socket to list. Called by sw_socket "syscall". */ diff --git a/src/raw/swift_list.h b/src/raw/swift_list.h index c6da104..62d547c 100644 --- a/src/raw/swift_list.h +++ b/src/raw/swift_list.h @@ -2,13 +2,6 @@ #define __SOCK_LIST -enum sock_rw_state { - STATE_NO_SHUT, - STATE_SHUT_RD, - STATE_SHUT_WR, - STATE_SHUT_RDWR -}; - enum sock_bind_state { STATE_NOTBOUND, STATE_BOUND @@ -18,7 +11,6 @@ enum sock_bind_state { struct sock_list { int s; struct sockaddr_sw addr; - enum sock_rw_state rw_state; enum sock_bind_state bind_state; struct sock_list *next; struct sock_list *prev; diff --git a/src/raw/swift_raw.c b/src/raw/swift_raw.c index def68bb..937c62d 100644 --- a/src/raw/swift_raw.c +++ b/src/raw/swift_raw.c @@ -54,9 +54,6 @@ int sw_socket(int __domain, int __type, int __protocol) goto list_add_err; } - /* Socket is fully open. */ - list->rw_state = STATE_NO_SHUT; - /* Socket is not bound. */ list->bind_state = STATE_NOTBOUND; @@ -150,10 +147,6 @@ ssize_t sw_sendto(int __fd, __const void *__buf, size_t __n, goto sock_err; } - if (list->rw_state == STATE_SHUT_WR || list->rw_state == STATE_SHUT_RDWR) { - errno = ENOTCONN; - goto sock_err; - } /* if (list->state == STATE_NOBOUND) { errno = EDESTADDRREQ; @@ -248,7 +241,6 @@ int sw_getsockopt(int __fd, int __level, int __optname, * to *OPTVAL (which is OPTLEN bytes long). * Returns 0 on success, -1 for errors. */ - int sw_setsockopt(int __fd, int __level, int __optname, __const void *__optval, socklen_t __optlen) { @@ -256,64 +248,6 @@ int sw_setsockopt(int __fd, int __level, int __optname, return setsockopt(__fd, __level, __optname, __optval, __optlen); } -/* - * Shut down all or part of the connection open on socket FD. - * HOW determines what to shut down: - * SHUT_RD = No more receptions; - * SHUT_WR = No more transmissions; - * SHUT_RDWR = No more receptions or transmissions. - * Returns 0 on success, -1 for errors. - */ -int sw_shutdown(int __fd, int __how) -{ - struct sock_list *list; - int rc; - - /* Find socket in management structure. */ - list = list_elem_from_socket(__fd); - if (list == NULL) { - errno = EBADF; - goto list_elem_err; - } - - /* Check and update socket state. */ - if (__how == STATE_SHUT_RDWR) - list->rw_state = STATE_SHUT_RDWR; - else if (__how == STATE_SHUT_WR) { - if (list->rw_state == STATE_SHUT_RD) - list->rw_state = STATE_SHUT_RDWR; - else if (list->rw_state == STATE_SHUT_WR) { - errno = ENOTCONN; - goto not_conn_err; - } - } - else if (__how == STATE_SHUT_RD) { - if (list->rw_state == STATE_SHUT_WR) - list->rw_state = STATE_SHUT_RDWR; - else if (list->rw_state == STATE_SHUT_RD) { - errno = ENOTCONN; - goto not_conn_err; - } - } - - /* Remove socket from socket management structure. */ - if (list->rw_state == STATE_SHUT_RDWR) { - rc = list_remove_socket(__fd); - if (rc < 0) { - errno = EBADF; - goto list_unlink_err; - } - } - - /* Call classical interface of shutdown(2). */ - return shutdown(__fd, __how); - -not_conn_err: -list_elem_err: -list_unlink_err: - return -1; -} - /* * Close file descriptor for socket FD. * Returns 0 on success, -1 for errors. diff --git a/src/raw/swift_raw.h b/src/raw/swift_raw.h index fd83ac2..7dd4b6f 100644 --- a/src/raw/swift_raw.h +++ b/src/raw/swift_raw.h @@ -106,16 +106,6 @@ extern int sw_getsockopt (int __fd, int __level, int __optname, extern int sw_setsockopt (int __fd, int __level, int __optname, __const void *__optval, socklen_t __optlen) __THROW; -/* - * Shut down all or part of the connection open on socket FD. - * HOW determines what to shut down: - * SHUT_RD = No more receptions; - * SHUT_WR = No more transmissions; - * SHUT_RDWR = No more receptions or transmissions. - * Returns 0 on success, -1 for errors. - */ -extern int sw_shutdown (int __fd, int __how) __THROW; - /* * Close file descriptor for socket FD. * Returns 0 on success, -1 for errors. diff --git a/src/raw/test/Makefile b/src/raw/test/Makefile index 6137f0a..03657b0 100644 --- a/src/raw/test/Makefile +++ b/src/raw/test/Makefile @@ -6,9 +6,10 @@ CFLAGS = -Wall -g all: test test: test.o test_sw_socket.o test_sw_bind.o test_sw_getsockname.o \ - test_sw_getsockopt.o test_sw_sendto.o test_sw_recvfrom.o test_sw_sendmsg.o \ - test_sw_recvmsg.o test_sw_setsockopt.o test_sw_getsockopt.o \ - test_sw_shutdown.o test_sw_close.o test_dummy.o + test_sw_sendto.o test_sw_recvfrom.o \ + test_sw_sendmsg.o test_sw_recvmsg.o \ + test_sw_setsockopt.o test_sw_getsockopt.o \ + test_sw_close.o test_dummy.o clean: -rm -f *~ *.o diff --git a/src/raw/test/test.c b/src/raw/test/test.c index df5bafb..5676b23 100644 --- a/src/raw/test/test.c +++ b/src/raw/test/test.c @@ -22,7 +22,6 @@ static void (*test_fun_array[])(void) = { recvfrom_test_suite, sendmsg_test_suite, recvmsg_test_suite, - shutdown_test_suite, close_test_suite, }; diff --git a/src/raw/test/test_sw.h b/src/raw/test/test_sw.h index c47f278..4ce1fb1 100644 --- a/src/raw/test/test_sw.h +++ b/src/raw/test/test_sw.h @@ -18,11 +18,8 @@ void sendto_test_suite(void); void recvfrom_test_suite(void); void sendmsg_test_suite(void); void recvmsg_test_suite(void); -void shutdown_test_suite(void); void close_test_suite(void); -/* TODO: fill with test function headers. */ - #ifdef __cplusplus } #endif diff --git a/src/raw/test/test_sw_shutdown.c b/src/raw/test/test_sw_shutdown.c deleted file mode 100644 index 93df05a..0000000 --- a/src/raw/test/test_sw_shutdown.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Test sw_shutdown "syscall". - */ - -#include "test_sw.h" -#include "test.h" - -static void shutdown_dummy(void); - -void shutdown_test_suite(void) -{ - start_suite(); - shutdown_dummy(); -} - -static void shutdown_dummy(void) -{ - test(1 == 1); -} -- 2.20.1