1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00
Commit Graph

116 Commits

Author SHA1 Message Date
Volker Lendecke
9d4bf6bb9d tsocket: Simplify tsocket.h
tevent.h already includes talloc.h

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-03-22 18:02:17 +00:00
Andreas Schneider
8a313bbdd5 lib:tsocket: Check for DOXYGEN as a #define
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>

Autobuild-User(master): Gary Lockyer <gary@samba.org>
Autobuild-Date(master): Mon Dec 17 00:10:10 CET 2018 on sn-devel-144
2018-12-17 00:10:10 +01:00
Volker Lendecke
f7f15c25d2 tsocket: Fix typos
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-01-04 00:37:20 +01:00
Andreas Schneider
4524f5986c tsocket: Do not dereference a NULL pointer
Make sure the lrbsda pointer is not allocated and we will
not end up dereferencing a NULL pointer. In practice this
can't happen, but this change links the pointer with the
code that uses it.

Found by Coverity.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Jun 30 02:53:02 CEST 2016 on sn-devel-144
2016-06-30 02:53:01 +02:00
Ralph Boehme
574313a1e1 lib/tsocket: workaround sockets not supporting FIONREAD
Netlink sockets don't support querying pending bytes with ioctl(fd,
FIONREAD, ...) and would return EOPNOTSUPP, so use recvmsg() with
MSG_PEEK|MSG_TRUNC as a fallback.

The MSG_TRUNC flag to recvmsg() is Linux only, but netlink is as well,
so we're safe for now.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=11714

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Wed Feb 10 10:30:24 CET 2016 on sn-devel-144
2016-02-10 10:30:23 +01:00
Ralph Boehme
3e705adcab lib/tsocket: fix non-blockging connect() error handling
Non-blockging connect() either returns immediate success, or -1 with
errno EINPROGESS as indication that the connection is pending. All other
errnos indicate immediate failure.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2015-10-21 23:13:17 +02:00
Volker Lendecke
052b9a53b7 Fix a typo
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ira Cooper <ira@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Fri Jun 19 01:05:17 CEST 2015 on sn-devel-104
2015-06-19 01:05:17 +02:00
Stefan Metzmacher
36b97d0bb9 lib/tsocket: add tdgram_inet_udp_broadcast_socket()
This is similar to tdgram_inet_udp_socket(), but it allows
the use of ipv4 broadcast traffic.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-06-12 17:08:17 +02:00
Stefan Metzmacher
3a8b7b0518 lib/tsocket: add tdgram_bsd_existing_socket() helper function
This is similar to tstream_bsd_existing_socket().
Both help to migrate strange code path to using the tstream or tdgram
abstractions.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-06-12 17:08:17 +02:00
Volker Lendecke
61dbe450b6 tsocket: Use common code in tsocket_bsd_common_prepare_fd
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: "Stefan (metze) Metzmacher" <metze@samba.org>
2015-06-05 14:33:19 +02:00
Volker Lendecke
d6f70d3346 tsocket: Use iov_advance
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-02-24 17:52:09 +01:00
Volker Lendecke
0a20ffb17d tsocket: Fix a typo
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-02-24 17:52:08 +01:00
Andreas Schneider
0b58eed335 tsocket: Pass the full port number to getaddrinfo().
The code stripped port numbers above 9999 down to 4 digits.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Jul  1 21:10:53 CEST 2013 on sn-devel-104
2013-07-01 21:10:53 +02:00
Volker Lendecke
fffb70168d tsocket: Add some const
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2013-06-14 20:30:33 +02:00
Ira Cooper
ccb39a3fd2 tsocket: ENOMEM can be retried on illumos/Solaris.
The writev system call can return -1 and errno ENOMEM, as a
retriable condition.

Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Mar 13 23:50:05 CET 2013 on sn-devel-104
2013-03-13 23:50:04 +01:00
Andrew Bartlett
70e1b6185e tsocket_bsd: Attempt to increase the SO_SNDBUF if we get EMSGSIZE in sendto()
This matches what was done for lib/socket/socket_unix.c in
c692bb02b0.

(and is based on that patch by Landon Fuller <landonf@bikemonkey.org>)

Andrew Bartlett

Reviewed-by: Stefan Metzmacher <metze@samba.org>

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Mon Mar  4 11:15:35 CET 2013 on sn-devel-104
2013-03-04 11:15:35 +01:00
Stefan Metzmacher
719595b6f7 lib/tsocket: optimize syscalls in tstream_readv_pdu_send()
Once we've got the first part of a pdu we try to optimize
readv calls for the rest of the pdu.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2012-11-05 17:13:40 +01:00
Stefan Metzmacher
e42889f83f lib/tsocket: disable the syscall optimization for recvfrom/readv by default
We only do the optimization on recvfrom/readv if the caller asked for it.

This is needed because in most cases we preferr to flush send
buffers before receiving incoming requests.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2012-11-05 17:13:39 +01:00
Stefan Metzmacher
d2aa785290 lib/tsocket: fix loop in tdgram_bsd_recvfrom() (bug #9184)
If the socket is not readable yet, we need to retry
if tsocket_bsd_pending() returns 0.

See also
https://lists.samba.org/archive/samba-technical/2012-October/087164.html

metze

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Tue Oct 23 14:44:21 CEST 2012 on sn-devel-104
2012-10-23 14:44:21 +02:00
Stefan Metzmacher
eacdd9f730 lib/tsocket: fix receiving of udp packets from 0 bytes (bug #9184)
It's possible for a client to send 0 bytes in a UDP packet,
we need still need to call recvfrom() and skip the invalid
packet at a higher level. Otherwise the kernel receive queue
is blocked.

metze
2012-09-22 04:31:06 +02:00
Michael Adam
9fe3544565 tsocket: Fix a couple of typos and spellings in tsocket_guide.txt
Autobuild-User: Michael Adam <obnox@samba.org>
Autobuild-Date: Tue Apr 17 14:41:53 CEST 2012 on sn-devel-104
2012-04-17 14:41:52 +02:00
Stefan Metzmacher
b97aab0223 tsocket: make use of tevent_queue_add_optimize_empty() to optimize for the empty queue case
metze
2011-08-10 08:04:15 +02:00
Volker Lendecke
f0ff6f390a Use tevent_req_oom
This fixes a few Coverity errors
2011-06-20 12:33:24 +02:00
Stefan Metzmacher
c378835cb6 tsocket: fill in sa.sa_len if the system supports it
metze
2010-11-05 08:45:14 +00:00
Jelmer Vernooij
3deece5591 s4: Remove the old perl/m4/make/mk-based build system.
The new waf-based build system now has all the same functionality, and
the old build system has been broken for quite some time.

Autobuild-User: Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date: Sun Oct 31 02:01:44 UTC 2010 on sn-devel-104
2010-10-31 02:01:44 +00:00
Stefan Metzmacher
79c6572256 tsocket: let tstream_inet_tcp_connect_recv() optionally return the used local address
tstream_inet_tcp_connect_send() usually only gets no local port number
and it may use the wildcard address '0.0.0.0' or '::'.

tstream_inet_tcp_connect_recv() provides the used local address and port
which are used on the wire.

metze
2010-10-23 08:49:30 +02:00
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