1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00
Commit Graph

140 Commits

Author SHA1 Message Date
Stefan Metzmacher
d2c653629c tsocket: ask the kernel for the specific local address after a tcp connect
metze
2010-10-23 08:49:29 +02:00
Stefan Metzmacher
4423aa59ab tsocket: make sure we delete the fd event before calling close()
We got random double free errors, when getting events from
epoll_wait() and try to dereference the private talloc pointer
attached to it.

Before doing the close() in the tstream_disconnect_send() function
we need to delete the fd event.

commit 38f505530b only fixed it for
tdgram sockets.

metze
2010-10-04 14:05:15 +00:00
Stefan Metzmacher
38f505530b tsocket: make sure we delete the fd event before calling close()
We got random double free errors, when getting events from
epoll_wait() and try to dereference the private talloc pointer
attached to it.

Before doing the close() in the tstream_disconnect_send() function
we need to delete the fd event.

metze

Autobuild-User: Stefan Metzmacher <metze@samba.org>
Autobuild-Date: Tue Sep 28 01:02:55 UTC 2010 on sn-devel-104
2010-09-28 01:02:55 +00:00
Andrew Tridgell
0212800de8 tsocket: we return -1 on error, not fd
the code used this pattent:

 if (fd < 0) {
   ...various cleanups...
   return fd;
 } 

it is much clearer to do this:

 if (fd < 0) {
   ...various cleanups...
   return -1;
 } 

as otherwise when reading the code you think this function may return
a fd.

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
2010-09-15 15:39:36 +10:00
Stefan Metzmacher
8494d09b89 Revert "lib/tsocket: sa_socklen is a macro on irix, so better use sasocklen"
This reverts commit 3d4fb698660381e650d7caeb5b7cff12847c0fb8.

This was wrong... The problem was in the caller, sa_len is a macro on irix

metze
2010-08-28 08:28:01 +02:00
Stefan Metzmacher
44b2a7941c lib/tsocket: sa_socklen is a macro on irix, so better use sasocklen
metze
2010-08-27 13:00:26 +02:00
Volker Lendecke
f94039a8ea s3: Fix a typo 2010-08-15 09:45:30 +02:00
Volker Lendecke
77a3858f2f tsocket: Fix some unreachable code 2010-07-11 18:14:33 +02:00
Volker Lendecke
4b64555d75 tsocket: Fix some type-punned warnings 2010-06-21 15:03:59 +02:00
Simo Sorce
ae02691200 tsocket: Improve the language in some parts of the guide. 2010-05-19 17:04:45 -04:00
Andreas Schneider
04327e2809 tsocket: Added the warning again to tsocket_address_bsd_sockaddr. 2010-05-05 09:25:21 +02:00
Andreas Schneider
fcb53828df tsocket: Fixed the documentation of tsocket_address_bsd_sockaddr. 2010-05-03 15:55:34 +02:00
Stefan Metzmacher
2436ec2928 lib/tsocket: add tsocket_address_is_unix() function
metze
2010-04-27 13:00:24 +02:00
Stefan Metzmacher
e1596bbf27 lib/tsocket: add tsocket_address_is_inet() function
metze
2010-04-27 13:00:24 +02:00
Stefan Metzmacher
b29f3f497b Revert "tsocket: not all systems have IPV6_V6ONLY"
This reverts commit 63fc397808.

We now don't support IPv6 when IPV6_V6ONLY isn't available,
as we rely on the behavior.

metze
2010-04-24 20:30:25 +02:00
Stefan Metzmacher
33bb334e80 s4-waf: inline LIBREPLACE_NETWORK into 'replace'
metze
2010-04-12 09:13:43 +02:00
Andrew Bartlett
f1aa4c34bf tsocket_bsd: Always use a real length for the sa_socklen, and keep it around
The previous code assumed the OS would happily accept sizeof(struct
sockaddr_storage).  It seems some versions of Solaris do not like
this.

Andrew Bartlett
2010-04-08 08:34:40 +02:00
Andrew Tridgell
b690fedef5 s4-waf: removed the AUTOGENERATED markers
we won't be using the mk -> wscript generator again
2010-04-06 20:27:16 +10:00
Andrew Tridgell
f9eae32f4b s4-waf: mark the wscript files as python so vim/emacs knows how to highlight them 2010-04-06 20:27:11 +10:00
Andrew Tridgell
845e0cbe6f build: commit all the waf build files in the tree 2010-04-06 20:26:48 +10:00
Andrew Tridgell
63fc397808 tsocket: not all systems have IPV6_V6ONLY 2010-03-26 16:50:48 +11:00
Andreas Schneider
1983256c70 tsocket: Improve the tsocket_address_bsd_sockaddr documentation.
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2010-02-26 08:57:30 +01:00
Brad Hards
319d3bf9d9 Spelling fixes for tsocket API documentation.
Signed-off-by: Matthias Dieter Wallnöfer <mwallnoefer@yahoo.de>
2010-02-22 21:45:33 +01:00
Stefan Metzmacher
c42d9c4ec4 tsocket/bsd: fix comment in tdgram_bsd_recvfrom_handler()
metze
2010-02-18 09:38:00 +01:00
Jeremy Allison
936828de71 Fix commit d07cd37b99
Which was:

    tsocket/bsd: fix bug #7115 FreeBSD includes the UDP header in FIONREAD

Metze, this has to have been wrong - you are throwing away the talloc_realloc
pointer returned. Also no error checking. Please review.

Thank goodness for gcc warnings :-).

Jeremy.
2010-02-17 09:24:34 -08:00
Stefan Metzmacher
d07cd37b99 tsocket/bsd: fix bug #7115 FreeBSD includes the UDP header in FIONREAD
metze
2010-02-17 14:46:39 +01:00
Stefan Metzmacher
1ffcb991a9 tsocket/bsd: set IPV6_V6ONLY on AF_INET6 sockets
Some system already have this as default. It's easier
to behave the same way on all systems and handle ipv6
and ipv4 sockets separate.

metze
2010-02-17 14:46:39 +01:00
Stefan Metzmacher
8a0949dfc8 tsocket/bsd: fix bug #7140 autodetect ipv4 and ipv6 based on the remote address if the local address is any
metze
2010-02-17 14:46:08 +01:00
Stefan Metzmacher
6637b2f4b0 tsocket/bsd: fix bug #7140 use calculated sa_socklen for bind() in tstream_bsd_connect_send()
This is needed because, we can't use sizeof(sockaddr_storage) for AF_UNIX
sockets. Also some platforms require exact values for AF_INET and AF_INET6.

metze
2010-02-17 14:45:34 +01:00
Stefan Metzmacher
135543b4c3 tsocket/bsd: fix do_bind logic for AF_INET
We want the explicit bind() when we don't use the any address.

metze
2010-02-17 14:13:57 +01:00
Kai Blin
88099bcc93 tsocket: Fix the description of tstream_writev_queue_send/recv 2010-01-28 11:16:24 +01:00
Kai Blin
9184f524f0 tsocket: Fix description for tstream_readv_pdu_queue_send/recv 2010-01-28 11:11:33 +01:00
Andreas Schneider
04f3f27f7e tsocket: Added doxygen config file.
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2010-01-11 11:23:04 +01:00
Andreas Schneider
574f77f89e tsocket: Added complete doxygen documentation.
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2010-01-11 11:22:59 +01:00
Stefan Metzmacher
17c804a675 tsocket: only copy the specific part of sockaddr*
This makes sure we fill the unspefic bytes with 0
and have zero termination for sockaddr_un.

metze
2009-12-24 17:38:29 +01:00
Stefan Metzmacher
4784c8c3be tsocket: allow AF_UNIX sockaddrs smaller than sizeof(sockaddr_un)
This is needed as getpeername() truncates the length to 2 if the
peer socket has no name.

metze
2009-12-24 17:38:04 +01:00
Andreas Schneider
a5bdab8b32 tsocket: Fixed tsocket_guide.txt asciidoc syntax. 2009-12-15 23:34:23 +01:00
Andreas Schneider
e33ae22b87 tsocket: Fixed documentation for tsocket_address_bsd_sockaddr(). 2009-12-15 23:34:22 +01:00
Andreas Schneider
ab04dd3be7 tsocket: Fixed typo in LGPL header. 2009-12-15 23:34:22 +01:00
Stefan Metzmacher
edbf2caa6f tsocket: add tsocket_address_bsd_sockaddr() and tsocket_address_bsd_from_sockaddr()
metze
2009-12-15 23:34:22 +01:00
Stefan Metzmacher
97a32035be tsocket: rewrite tsocket_guide.txt to reflect the current APIs
metze
2009-11-03 18:26:30 +01:00
Stefan Metzmacher
eb39f66940 tsocket_bsd: return -1 and set errno to ENAMETOOLONG if the unix path is too long
metze
2009-11-03 18:24:44 +01:00
Stefan Metzmacher
9b5d1e9e35 tsocket: remove prototype of non-existing tsocket_address_inet_set_broadcast()
metze
2009-11-03 18:14:23 +01:00
Stefan Metzmacher
1f12dc4409 tsocket: rename sa_len => sa_socklen, because sa_len is a macro on some platforms
metze
2009-07-16 08:21:08 +02:00
Stefan Metzmacher
857ed9ca5a tsocket/bsd: also ask for TEVENT_FD_READ when we want to write into a stream socket
Otherwise we would not notice a broken connection.

metze
2009-06-29 16:03:57 +02:00
Stefan Metzmacher
b1d5e515b2 tsocket/bsd: more correctly check if the cached tevent_fd is still valid
I some cases the pointer value of tevent_context is the same again,
if we do something like:

	ev1 = tevent_context_init();
	...
	fde = tevent_add_fd(ev1, fd, TEVENT_FD_READ...);
	...
	talloc_free(ev1);
	...
	ev2 = tevent_context_init();

	if (ev1 == ev2) {
		/* this can happen! */
	}

	if (tevent_fd_get_flags(fde) == 0) {
		/* this is always true */
	}

But the "talloc_free(ev1)" will set fde->event_ctx to NULL
and tevent_fd_get_flags() will always return 0.

metze
2009-06-29 16:03:57 +02:00
Volker Lendecke
c687eb15d9 Properly free a downlevel readv request. Metze, please check 2009-06-27 23:17:49 +02:00
Andrew Tridgell
c0965e0eec It seems that IRIX doesn't have IOV_MAX 2009-06-09 14:54:15 +10:00
Stefan Metzmacher
edd9bd9b16 tsocket: allow empty vectors at the end for tstream_writev()/readv()
metze
2009-05-22 14:01:22 +02:00
Volker Lendecke
ac65ae9b1d Set errno=ENOMEM if tevent_add_fd fails
tevent_add_fd does not properly set that. At least in epoll and select this is
the only error condition.

Metze, please check!
2009-05-19 23:51:22 +02:00
Volker Lendecke
f9d00fb58e Simplify the logic of tsocket_bsd_pending
Remove two indentation levels by returning early on error.

Metze, please check!
2009-05-19 23:35:16 +02:00
Volker Lendecke
6ca4d727c4 Attempt to the build on NetBSD5 and a few others 2009-05-01 23:26:22 +02:00
Stefan Metzmacher
6ac61e6707 tsocket: add tstream_readv_pdu_queue_send/recv()
metze
2009-05-01 17:42:01 +02:00
Stefan Metzmacher
eb723c2061 tsocket: add tstream_writev_queue_send/recv()
metze
2009-05-01 17:42:00 +02:00
Stefan Metzmacher
a0830f4cb9 tsocket: add tstream_readv_pdu_send/recv()
metze
2009-05-01 17:41:56 +02:00
Stefan Metzmacher
ee6d796c19 tsocket: add tstream implementation for bsd sockets (inet and unix)
metze
2009-05-01 17:41:55 +02:00
Stefan Metzmacher
8a090c4b8b tsocket: add tstream_context infrastructure similar to tdgram_context
metze
2009-05-01 17:41:53 +02:00
Stefan Metzmacher
182a4b30de tsocket: rename tdgram_unix_dgram_socket() => tdgram_unix_socket()
metze
2009-05-01 17:41:38 +02:00
Stefan Metzmacher
b46599590f tsocket: move tsocket_simple_int_recv() to tsocket.c
metze
2009-05-01 17:38:27 +02:00
Stefan Metzmacher
0db3b944bd tsocket: move tsocket_sendto_queue_send/recv() to tsocket_helpers.c
metze
2009-05-01 17:38:26 +02:00
Stefan Metzmacher
b4c5387e9f tsocket: tdgram move input checks to the common code as there're needed for all backends
We need to make sure that we free the sendto and recvfrom requests before
the tdgram_context

metze
2009-05-01 17:38:25 +02:00
Stefan Metzmacher
cc75ff1a37 tsocket: for unix domain sockets we need to use sizeof(struct sockaddr_un)
sizeof(struct sockaddr_storage) generates EINVAL.

metze
2009-05-01 17:38:24 +02:00
Stefan Metzmacher
66a2cd36c6 tsocket: return EINVAL when tdgram_sendto_send() is used with len == 0
metze
2009-05-01 17:38:23 +02:00
Stefan Metzmacher
997eb9eb43 tsocket: fix dependecies
metze
2009-05-01 17:38:22 +02:00
Stefan Metzmacher
9dbb535aa5 tsocket: remove tsocket_context related stuff
It will be replaced by tdgram_context and tstream_context.

metze
2009-05-01 17:38:21 +02:00
Stefan Metzmacher
56aae35a23 tsocket: fix the build without ipv6 support
metze
2009-04-16 09:31:14 +02:00
Stefan Metzmacher
522bdea1f3 tsocket: reduce size of dummy variable
metze
2009-04-06 16:37:18 +02:00
Stefan Metzmacher
9d9f945281 tsocket: use the correct 'ret' variable for tdgram_disconnect_send/recv()
metze
2009-04-06 15:49:08 +02:00
Stefan Metzmacher
3bbad34a02 tsocket: remove DGRAM support from tsocket_context
metze
2009-04-02 21:54:08 +02:00
Stefan Metzmacher
c59ee5a139 tsocket: optimize tdgram_bsd a lot
The desire is to do as less syscalls during the
tdgram_sendto_send/recv() and tdgram_recvfrom_send/recv()
operations.

1. we first try the sendto()/recvfrom() syscall and
   only use a fd event if we got EAGAIN.

2. we cache the fd event and only change it's flags
   if really needed.

For the highload case we do almost no epoll_ctl() and epoll_wait()/select()
syscalls anymore. This speeds up the LDAP-BENCH-CLDAP test
by more than 20%. (With a modified version of this test
which let the server skip any ldb calls and just return success
I'm getting about 8000 requests per second, while I'm getting
just about 6000 requests per second without optimization)

metze
2009-04-02 21:54:00 +02:00
Stefan Metzmacher
85742dbc06 tsocket: add tdgram_sendto_queue_send/recv()
metze
2009-04-02 21:53:59 +02:00
Stefan Metzmacher
8d98070a9f tsocket: split out a smaller tdgram_context abstraction
The idea is to have a tdgram and a tstream abstraction
which only provide tevent_req based io functions.

metze
2009-04-02 21:53:03 +02:00
Stefan Metzmacher
c200e8632f tsocket: try to fix the build on solaris FIONREAD was missing
metze
2009-03-31 20:33:33 +02:00
Stefan Metzmacher
23bb1eedf6 tsocket: more s/sun/un to make the build on solaris happy
metze
2009-03-28 23:50:56 +01:00
Stefan Metzmacher
cacfae159f tsocket: try to fix the build on solaris systems
It seems that 'sun' is somewhere defined and we can
use it as name for variables or struct/union members.

metze
2009-03-27 11:40:36 +01:00
Stefan Metzmacher
4e18c24e2e lib/tsocket: add tsocket_guide.txt section with specific details about bsd style sockets
metze
2009-03-19 16:25:58 +01:00
Stefan Metzmacher
f6efec5dd4 lib/tsocket: add a fast path to tsocket_writev_send/recv()
This is similar to the tsocket_sendto_send/recv() fast path.

metze
2009-03-19 16:25:57 +01:00
Stefan Metzmacher
b900e92425 lib/tsocket: add a fast path to tsocket_sendto_send/recv()
By first trying to send data without waiting for the socket
to become writeable we gain about 10-20% performance in the
LDAP-BENCH-CLDAP test.

metze
2009-03-19 16:25:57 +01:00
Stefan Metzmacher
235a7a420b lib/tsocket: add tsocket_guide.txt section about the async _send/recv() helper functions
metze
2009-03-19 16:25:56 +01:00
Stefan Metzmacher
a27c6eb8e2 lib/tsocket: add tsocket_readv_send/recv()
metze
2009-03-19 16:25:56 +01:00
Stefan Metzmacher
6c8bd1005d lib/tsocket: add tsocket_writev_queue_send/recv()
metze
2009-03-19 16:25:55 +01:00
Stefan Metzmacher
2e44ceaea8 lib/tsocket: add tsocket_writev_send/recv()
metze
2009-03-19 16:25:55 +01:00
Stefan Metzmacher
a140823cc9 lib/tsocket: add tsocket_connect_send/recv()
metze
2009-03-19 16:25:54 +01:00
Stefan Metzmacher
4002b7bdc1 lib/tsocket: add tsocket_sendto_queue_send/recv()
metze
2009-03-19 16:25:54 +01:00
Stefan Metzmacher
9ed7a45c88 lib/tsocket: add tsocket_sendto_send/recv()
metze
2009-03-19 16:25:54 +01:00
Stefan Metzmacher
ccfd6a6e39 lib/tsocket: add tsocket_recvfrom_send/recv()
metze
2009-03-19 16:25:53 +01:00
Stefan Metzmacher
6c88d61bdd lib/tsocket: add an implementation for bsd style sockets.
metze
2009-03-19 16:25:53 +01:00
Stefan Metzmacher
c00126e609 lib/tsocket: add a tsocket_guide.txt with a description of the design
metze
2009-03-19 16:25:52 +01:00
Stefan Metzmacher
d848d517b5 lib/tsocket: add some useful helper functions
metze
2009-03-19 16:20:22 +01:00
Stefan Metzmacher
2e0e416676 lib/tsocket: add generic socket abstraction layer
This will replace source4/lib/socket/.

metze
2009-03-19 15:01:12 +01:00