Andreas Schneider [Wed, 24 Oct 2018 06:44:19 +0000 (08:44 +0200)]
cmake: Don't use string PREPEND
This is only supported in cmake >= 3.10.
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Anoop C S [Fri, 26 Oct 2018 10:14:53 +0000 (15:44 +0530)]
swrap: Fix coverity issues
CID 184220
CID 184221
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Andreas Schneider [Tue, 2 Oct 2018 14:40:16 +0000 (16:40 +0200)]
gitlab-ci: Disable the FreeBSD runner
There is a threading race condition in FreeBSD.
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Thu, 27 Sep 2018 19:10:45 +0000 (21:10 +0200)]
gitlab-ci: Add helgrind tests
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Thu, 27 Sep 2018 15:56:11 +0000 (17:56 +0200)]
gitlab-ci: Add runners and toolchain files
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Mon, 1 Oct 2018 19:34:44 +0000 (21:34 +0200)]
tests: Init in_addr only once in test_tcp_socket_overwrite
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Mon, 1 Oct 2018 19:28:27 +0000 (21:28 +0200)]
tests: Return an error if setenv() fails in test_max_sockets
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Mon, 1 Oct 2018 19:28:06 +0000 (21:28 +0200)]
tests: Check the correct return code in test_thread_echo_tcp_write_read
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Mon, 1 Oct 2018 19:27:40 +0000 (21:27 +0200)]
tests: Check return code of connect in test_thread_echo_tcp_sendmsg_recvmsg
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Mon, 1 Oct 2018 19:31:19 +0000 (21:31 +0200)]
tests: Check the return code of connect in test_echo_udp_sendmsg_recvmsg
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Mon, 1 Oct 2018 19:27:14 +0000 (21:27 +0200)]
tests: Check return code of connnect in test_echo_tcp_sendmsg_recvmsg
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Mon, 1 Oct 2018 19:23:31 +0000 (21:23 +0200)]
echo_srv: Check for a valid pidfile pointer
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Mon, 1 Oct 2018 08:54:53 +0000 (10:54 +0200)]
echo_srv: Only use 128K as buffer size instead of 4MB
This produced errors built with clang.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Thu, 27 Sep 2018 16:19:42 +0000 (18:19 +0200)]
torture: Wait longer for echo_srv startup
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Fri, 28 Sep 2018 10:55:49 +0000 (12:55 +0200)]
echo_srv: Do not close bogus file descriptors
==1564== Warning: invalid file descriptor
1048564 in syscall close()
==1564== at 0x4D18534: close (in /lib64/libc-2.27.so)
==1564== by 0x4046A74: libc_close (socket_wrapper.c:760)
==1564== by 0x405105C: swrap_close (socket_wrapper.c:5933)
==1564== by 0x40511F5: close (socket_wrapper.c:5979)
==1564== by 0x401679: become_daemon (echo_srv.c:202)
==1564== by 0x402D44: main (echo_srv.c:896)
==1563==
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Sat, 1 Sep 2018 17:36:19 +0000 (19:36 +0200)]
swrap: Don't do a deep bind if we run with libasan
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Fri, 28 Sep 2018 10:46:30 +0000 (12:46 +0200)]
swrap: Add a mutex for resetting socket index
Fixes a helgrind error.
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Anoop C S [Wed, 19 Sep 2018 08:11:49 +0000 (13:41 +0530)]
swrap: Fix helgrind errors
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Fri, 28 Sep 2018 06:11:57 +0000 (08:11 +0200)]
tests: Use assert_return_code() to get errno
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Anoop C S [Wed, 29 Aug 2018 23:18:30 +0000 (04:48 +0530)]
tests: Avoid -Wcast-align warning
warning: cast from 'struct sockaddr *' to 'struct sockaddr_in *'
increases required alignment from 2 to 4 [-Wcast-align]
struct sockaddr_in *sinp = (struct sockaddr_in *)to; ^~~~~~~~~~~~~~~~~~~~~~~~
Above warning can be avoided by making use of sockaddr_in available
within torture_address from the caller of echo_udp_recv_from_to().
Following that sa_socklen from torture_address can be used instead of
passing sa_socklen explicitly to echo_udp_recv_from_to().
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Anoop C S [Tue, 28 Aug 2018 16:41:31 +0000 (22:11 +0530)]
tests: Fix -Wformat gcc warning
test_fork_thread_deadlock.c:48:25: warning: format ‘%d’ expects argument
of type ‘int’, but argument 3 has type ‘pid_t {aka long int}’ [-Wformat=]
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Thu, 27 Sep 2018 16:31:26 +0000 (18:31 +0200)]
cmake: Fix checking for required system libraries
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Thu, 27 Sep 2018 15:52:19 +0000 (17:52 +0200)]
cmake: Use target_include_directories()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Mon, 10 Sep 2018 06:34:03 +0000 (08:34 +0200)]
cmake: Require modern cmake version
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Thu, 27 Sep 2018 15:22:57 +0000 (17:22 +0200)]
cmake: Update AddCMockaTest
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Thu, 27 Sep 2018 15:50:02 +0000 (17:50 +0200)]
cmake: Update cmocka requirement
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Sat, 1 Sep 2018 18:46:52 +0000 (20:46 +0200)]
cmake: Support running the tests with AddressSanitizer
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Wed, 5 Sep 2018 13:39:35 +0000 (15:39 +0200)]
cmake: Add CFLAGS for AddressSanitizer and UndefinedSanitizer
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Wed, 5 Sep 2018 13:38:37 +0000 (15:38 +0200)]
cmake: Move Compiler flags to new file
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Sun, 2 Sep 2018 09:18:45 +0000 (11:18 +0200)]
cmake: Remove obsolete DefineCompilerFlags.cmake
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Sun, 2 Sep 2018 09:18:09 +0000 (11:18 +0200)]
cmake: Improve checks for compiler flags
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Tue, 2 Oct 2018 14:37:43 +0000 (16:37 +0200)]
cmake: Update CMake defaults
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Fri, 28 Sep 2018 09:01:15 +0000 (11:01 +0200)]
cmake: Suppress helgrind race condition warning we created on purpose
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Thu, 27 Sep 2018 19:08:23 +0000 (21:08 +0200)]
cmake: Create an error if helgrind finds a bug
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Thu, 6 Sep 2018 16:40:17 +0000 (18:40 +0200)]
cmake: Write helgrind logs to stderr so we can see them
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Sat, 1 Sep 2018 18:32:04 +0000 (20:32 +0200)]
cmake: Don't misuse CMAKE_REQUIRED_LIBRARIES
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Tue, 14 Aug 2018 09:42:38 +0000 (11:42 +0200)]
tests: Update valgrind suppression file
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Andreas Schneider [Thu, 9 Aug 2018 09:16:29 +0000 (11:16 +0200)]
cmake: Require at least cmake 3.2.0
This allows us to modernize the CMakeLists.txt
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Andreas Schneider [Thu, 5 Jul 2018 08:14:14 +0000 (10:14 +0200)]
ctest: Move to new dashboard
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Anoop C S [Tue, 12 Jun 2018 14:49:34 +0000 (20:19 +0530)]
swrap: Add error check around pthread mutex locks
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Anoop C S [Wed, 27 Jun 2018 18:05:28 +0000 (23:35 +0530)]
tests: Prevent child process falling to defunct state
Parent process does not wait for child process(which gets forked after
accepting a client connection) to exit inside echo server which in turn
puts child into defunct state. Even though those defunct childs are
cleaned up during parent exit it is better to wait from parent process
itself.
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Anoop C S [Mon, 25 Jun 2018 13:45:44 +0000 (19:15 +0530)]
doc: Add SOCKET_WRAPPER_MAX_SOCKETS to manual page
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Anoop C S [Fri, 15 Jun 2018 07:06:54 +0000 (12:36 +0530)]
swrap: Fix thread deadlock found by Coverity scan
CID 175897
CID 175898
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Andreas Schneider [Fri, 29 Jun 2018 13:17:10 +0000 (15:17 +0200)]
tests: Add missing header for IPPROTO_TCP
This fixes the build on FreeBSD.
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Andreas Schneider [Fri, 22 Jun 2018 06:47:08 +0000 (08:47 +0200)]
swrap: Update header
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Andreas Schneider [Fri, 22 Jun 2018 06:42:06 +0000 (08:42 +0200)]
Update LICENSE
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Andreas Schneider [Fri, 22 Jun 2018 06:38:04 +0000 (08:38 +0200)]
Rename COPYING to LICENSE
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Andreas Schneider [Fri, 22 Jun 2018 07:01:19 +0000 (09:01 +0200)]
cpack: Do not package build dirs in source tarball
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Anoop C S [Sun, 10 Jun 2018 07:49:14 +0000 (13:19 +0530)]
swrap: Replace socket_fds linked list with an array
This fixes the following bug:
As we are using a doubly linked list, we need a mutex which needs to be
locked when we are reading it that we do not end up with invalid
pointers.
The following can happen:
We are in swrap_close() which calls find_socket_info_fd() this locks the
mutex for the linked list. Now we get a singal SIGCHILD and the signal
handler is called. The signal handler calls swrap_write() and we try to
find out if the socket is managed by socket_wrapper calling
find_socket_info_fd() again -> DEADLOCK!
By moving to an array to handle the socket fds and using the fd as the
array access, we do not need a mutex for reading anymore. All we need is
a memory barrier.
This change also improves the performance as we move from the a linked
list to a hash table!
Pair-Programmed-With: Andreas Schneider <asn@samba.org>
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Andreas Schneider [Fri, 4 May 2018 06:01:29 +0000 (08:01 +0200)]
tests: Fix resouce leak in echo_srv tcp handling
CID 175587
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Andreas Schneider [Wed, 2 May 2018 15:05:21 +0000 (17:05 +0200)]
cmake: Run threaded tests with helgrind
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Anoop C S [Wed, 31 Jan 2018 17:13:21 +0000 (22:43 +0530)]
tests: Add test case to validate free-list indexes
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Anoop C S [Wed, 31 Jan 2018 17:16:23 +0000 (22:46 +0530)]
swrap: Update free-list only when refcount is zero
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Michael Adam [Wed, 12 Jul 2017 23:25:19 +0000 (01:25 +0200)]
swrap: Move metadata into socket_info_meta structure
Separating out the metadata related information to another
sub-structure to make it more clean and structured.
Pair-Programmed-With: Anoop C S <anoopcs@redhat.com>
Signed-off-by: Michael Adam <obnox@samba.org>
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Anoop C S [Thu, 2 Mar 2017 07:26:20 +0000 (07:26 +0000)]
tests: New threaded test cases
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Anoop C S [Thu, 2 Mar 2017 07:12:50 +0000 (07:12 +0000)]
tests: Modify echo server to accept multiple connections
In context of multiple threads, echo server must be capable of
accepting connections in a loop rather than be satisfied with
one incoming connection.
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Michael Adam [Thu, 22 Sep 2016 01:53:27 +0000 (03:53 +0200)]
tests: Add new test to check mutex lock contention
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Anoop C S [Tue, 28 Mar 2017 07:13:47 +0000 (07:13 +0000)]
swrap: Implement thread safety using pthread mutexes
Added a new mutex variable to socket_info structure along with
new macros for locking and unlocking mutex corresponding to
each socket_info entry. Apart from individual mutex defined in
socket_info structure, 4 new mutexes are added to protect the
concurrent access of globally used swrap parameters from different
threads.
All other individual wrappers and helper routines are also made
capable of acquiring relevant mutex locks before operating on such
global parameters.
Pair-Programmed-With: Michael Adam <obnox@samba.org>
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Anoop C S [Thu, 13 Jul 2017 09:43:07 +0000 (15:13 +0530)]
swrap: Rearrange swrap_remove_stale
In preparation to implement thread safety, re-ordering lines
of code to properly align to lockign calls
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Anoop C S [Thu, 13 Jul 2017 09:50:15 +0000 (15:20 +0530)]
swrap: Rearrange swrap_close
In preparation to implement thread safety, re-ordering lines
of code to properly align to locking calls.
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Anoop C S [Tue, 29 Aug 2017 08:59:16 +0000 (14:29 +0530)]
swrap: Remove swrap_first_free_index
swrap_first_free_index is no longer used as the whole logic now
implemented within swrap_create_socket.
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Anoop C S [Tue, 29 Aug 2017 09:04:58 +0000 (14:34 +0530)]
swrap: Use swrap_create_socket within swrap_accept
Replace the current logic of socket creation within swrap_accept
with more cleaner version using swrap_create_socket.
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Anoop C S [Tue, 29 Aug 2017 09:04:28 +0000 (14:34 +0530)]
swrap: Use swrap_create_socket within swrap_socket
Replace the current logic of socket creation within swrap_socket
with more cleaner version using swrap_create_socket.
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Anoop C S [Tue, 29 Aug 2017 07:10:35 +0000 (12:40 +0530)]
swrap: Add new routines to handle socket creation
A new function named swrap_create_socket is introduced which
cleanly performs all stuff related to creation of new socket
file descriptors and updation of relevant metadata including
the free-list and reference counter.
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Michael Adam [Sat, 15 Jul 2017 09:10:07 +0000 (14:40 +0530)]
swrap: Internal reorganization of core socket_info structures
The change basically splits socket_info structure into
two structures, namely,
- socket_info: to store the core information
corresponding to a socket entry.
- socket_info_container: wrapping structure to hold
the socket_info data as well as metadata(currently
refcount and next_free).
Pair-Programmed-With: Anoop C S <anoopcs@redhat.com>
Signed-off-by: Michael Adam <obnox@samba.org>
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Michael Adam [Wed, 2 Aug 2017 11:56:09 +0000 (13:56 +0200)]
swrap: Reorder code inside swrap_socket
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Michael Adam [Tue, 18 Jul 2017 10:53:03 +0000 (12:53 +0200)]
swrap: Use swrap_get_socket_info inside socket_wrapper_first_free_index
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Michael Adam [Tue, 18 Jul 2017 10:50:15 +0000 (12:50 +0200)]
swrap: set errno to ENFILE if there is no more free socket_info
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Michael Adam [Wed, 12 Jul 2017 23:01:57 +0000 (01:01 +0200)]
swrap: New helper functions to treat next_free
- swrap_get_next_free
- swrap_set_next_free
to avoid accessing socket_info.next_free directly
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Anoop C S [Thu, 1 Mar 2018 05:09:20 +0000 (10:39 +0530)]
swrap: Use helper functions to manage refcount
- swrap_get_refcount
- swrap_alter_refcount
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Anoop C S [Thu, 1 Mar 2018 05:04:54 +0000 (10:34 +0530)]
swrap: Use helper function swrap_get_socket_info
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Michael Adam [Thu, 13 Jul 2017 00:40:11 +0000 (02:40 +0200)]
swrap: Make early-libc-out more obvious by removing else
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Andreas Schneider [Wed, 2 May 2018 10:23:50 +0000 (12:23 +0200)]
tests: Increase wait time for setup and teardown to 5ms
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Anoop C S [Fri, 23 Mar 2018 11:42:49 +0000 (17:12 +0530)]
tests: Remove extra test by moving getsockname() to another
test_echo_tcp_socket currently tests socket() and getsockname() network
calls. The test name was misleading as it does not require echo server
to be setup. Moreover it failed to create socket_wrapper directory which
is the pre-requisite for testing with libsocket_wrapper.
Therefore it is better to integrate getsockname() test into existing
test_tcp_listen test and remove useless test_echo_tcp_socket
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlet <abartlet@samba.org>
Andreas Schneider [Wed, 28 Feb 2018 06:36:58 +0000 (07:36 +0100)]
cmake: Fix configure check for fall-through attribute
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Thu, 22 Feb 2018 08:37:40 +0000 (09:37 +0100)]
cmake: Fix checks for attributes
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Tue, 20 Feb 2018 16:52:00 +0000 (17:52 +0100)]
swrap: Avoid double semicolons in the code
Compilers that don't support fallthrough will end up with an empty
FALL_THROUGH define and just see a semicolon. The probably will warn
that there are double semicolons in the code.
Signed-off-by: Andreas Schneider <asn@samba.org>
Andreas Schneider [Mon, 4 Dec 2017 09:19:38 +0000 (10:19 +0100)]
Bump version to 1.1.9
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Andreas Schneider [Tue, 28 Nov 2017 14:41:05 +0000 (15:41 +0100)]
tests: Add a thread deadlock reproducer
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Andreas Schneider [Mon, 27 Nov 2017 10:00:54 +0000 (11:00 +0100)]
swrap: Avoid symbol binding deadlocks during fork
If there is a signal handler defined, e.g. for SIGCHILD and this signal
handler is called during pthread_atfork() has just locked all mutexes
and we want to check if a symbol is bound, we end up in a deadlock.
(gdb) bt
0 __lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
1 0x00007fe48837aef5 in __GI___pthread_mutex_lock (mutex=0x7fe4889a71c0 <libc_symbol_binding_mutex>) at ../nptl/pthread_mutex_lock.c:80
2 0x00007fe48879b2f1 in libc_write (fd=14, buf=0x7ffdad6436e8, count=8) at /home/asn/workspace/projects/socket_wrapper/src/socket_wrapper.c:1070
3 0x00007fe4887a21cb in swrap_write (s=14, buf=0x7ffdad6436e8, len=8) at /home/asn/workspace/projects/socket_wrapper/src/socket_wrapper.c:5137
4 0x00007fe4887a2359 in write (s=14, buf=0x7ffdad6436e8, len=8) at /home/asn/workspace/projects/socket_wrapper/src/socket_wrapper.c:5171
5 0x00007fe48713e5f2 in tevent_common_wakeup_fd (fd=14) at ../lib/tevent/tevent.c:959
6 0x00007fe48713e61f in tevent_common_wakeup (ev=ev@entry=0x55d04922e280) at ../lib/tevent/tevent.c:975
7 0x00007fe487141d38 in tevent_common_signal_handler (signum=<optimized out>) at ../lib/tevent/tevent_signal.c:109
8 <signal handler called>
9 0x00007fe4844de081 in __libc_fork () at ../sysdeps/nptl/fork.c:135
10 0x000055d047e8ddb3 in smbd_accept_connection (ev=0x55d04922e280, fde=<optimized out>, flags=<optimized out>, private_data=<optimized out>)
at ../source3/smbd/server.c:992
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Andreas Schneider [Fri, 1 Dec 2017 15:05:07 +0000 (16:05 +0100)]
swrap: Bind all symbols during prepare
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Andreas Schneider [Tue, 28 Nov 2017 09:15:07 +0000 (10:15 +0100)]
tests: Fix sa_socklen for sockaddr_in
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Andreas Schneider [Tue, 14 Nov 2017 08:03:24 +0000 (09:03 +0100)]
swrap: Whitespace fixes
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Andreas Schneider [Thu, 12 Oct 2017 14:47:49 +0000 (16:47 +0200)]
Bump version to 1.1.8
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Andreas Schneider [Wed, 2 Aug 2017 11:21:59 +0000 (13:21 +0200)]
swrap: Fix prototype of open[64] to prevent segfault on ppc64le
The calling conventions for vaarg are different on ppc64le. The patch
fixes segfaults on that platform.
Thanks to Florian Weimer who helped debugging it!
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Andreas Schneider [Tue, 1 Aug 2017 08:58:50 +0000 (10:58 +0200)]
swrap: Improve argument handling for libc_vopen*()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Andreas Schneider [Tue, 1 Aug 2017 08:48:47 +0000 (10:48 +0200)]
swrap: Improve argument handling for libc_vioctl()
The ioctl() only takes one or no argument.
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Andreas Schneider [Tue, 1 Aug 2017 08:20:46 +0000 (10:20 +0200)]
swrap: Improve argument handling for libc_fcntl()
fcntl() has either one or no argument.
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Andreas Schneider [Mon, 31 Jul 2017 17:25:41 +0000 (19:25 +0200)]
tests: Add a simple fnctl() test
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Andreas Schneider [Mon, 31 Jul 2017 16:25:42 +0000 (18:25 +0200)]
swrap: Simplify printing different log prefixes
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Andreas Schneider [Mon, 31 Jul 2017 16:25:30 +0000 (18:25 +0200)]
swrap: Do an early return if log level doesn't match
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Andreas Schneider [Mon, 31 Jul 2017 16:21:53 +0000 (18:21 +0200)]
swrap: Always enable logging
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Andreas Schneider [Thu, 27 Jul 2017 11:18:12 +0000 (13:18 +0200)]
swrap: Protect the FALL_THROUGH define
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Andreas Schneider [Thu, 27 Jul 2017 09:30:23 +0000 (11:30 +0200)]
cmake: Replace deprecated get_target_property()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Anoop C S [Thu, 13 Jul 2017 00:43:47 +0000 (02:43 +0200)]
swrap: Add common exit point to swrap_setsockopt
In preparation of thread safety.
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Anoop C S [Thu, 13 Jul 2017 00:36:20 +0000 (02:36 +0200)]
swrap: Add common exit point to swrap_getsockopt
In preparation of thread safety.
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Anoop C S [Thu, 13 Jul 2017 00:30:14 +0000 (02:30 +0200)]
swrap: Add common exit point to swrap_connect
In preparation of thread safety.
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Anoop C S [Thu, 13 Jul 2017 00:26:10 +0000 (02:26 +0200)]
swrap: Add common exit point to swrap_auto_bind
In preparation for thread safety.
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Michael Adam [Thu, 13 Jul 2017 00:22:14 +0000 (02:22 +0200)]
swrap: Fix tab vs space in swrap_auto_bind
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Anoop C S [Sat, 15 Jul 2017 15:24:06 +0000 (20:54 +0530)]
swrap: Suppress intentional fall through warning
-Wimplicit-fallthrough compiler flag introduced with gcc v7
results in the following warning during compilation:
[ 7%] Building C object src/CMakeFiles/socket_wrapper.dir/socket_wrapper.c.o
src/socket_wrapper.c: In function ‘sockaddr_convert_to_un’:
src/socket_wrapper.c:1846:18: warning: this statement may fall through [-Wimplicit-fallthrough=]
case AF_UNSPEC: {
^
/src/socket_wrapper.c:1866:2: note: here
case AF_INET:
^~~~
Default level for -Wimplicit-fallthrough(which is 3) allows
us to get rid of the above warning using specific comments
made within switch cases matching the regular expressions
outlined in gcc docs[1].
But for us the presence of preprocessor directives in the
vicinity of such comments nullifies its effect[2]. So our
best bet would be to make use of the reliable fallthrough
attribute and supress such warnings in future.
[1] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wimplicit-fallthrough
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77817
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>