1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
Commit Graph

30 Commits

Author SHA1 Message Date
Michael Adam
b38ed7311a s3:unix_msg: add close_fd_array_cmsg()
Variant of close_fd_array() operating on fd_array inside msghdr.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2014-09-30 16:36:10 +02:00
Michael Adam
20cd934ec0 s3:unix_msg: factor extract_fd_array_from_msghdr() out of unix_dgram_recv_handler()
For re-use.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2014-09-30 16:36:10 +02:00
Michael Adam
67684dc695 s3:unix_msg: simplify queue_msg() by moving space calculations up.
This allows for early direct return instead of the goto invalid,
since the fds_copy array is filled later.

Pair-Programmed-With: Volker Lendecke <vl@samba.org>
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Michael Adam <obnox@samba.org>
Signed-off-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2014-09-30 16:36:10 +02:00
Michael Adam
a96f0f4c3b s3:unix_msg: use an iov in unix_dgram_msg/queue_msg instead of buffer and length
This is equivalent, reads more easily and makes extraction
more obvious.

Pair-Programmed-With: Volker Lendecke <vl@samba.org>
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Michael Adam <obnox@samba.org>
Signed-off-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2014-09-30 16:36:10 +02:00
Michael Adam
e38f4f4ceb s3:unix_msg: rename a variable buflen->data_len in queue_msg()
Pair-Programmed-With: Volker Lendecke <vl@samba.org>
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Michael Adam <obnox@samba.org>
Signed-off-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2014-09-30 16:36:10 +02:00
Michael Adam
2564a5fa57 s3:unix_msg: use a buffer pointer instead of array indexes for the iov buffer
This is more obvious to read and a preparation for following commits.

Pair-Programmed-With: Volker Lendecke <vl@samba.org>
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Michael Adam <obnox@samba.org>
Signed-off-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2014-09-30 16:36:09 +02:00
Michael Adam
9ddb661281 s3:unix_msg: remember errno in unix_dgram_send_job in case of send error.
Pair-Programmed-With: Volker Lendecke <vl@samba.org>
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Michael Adam <obnox@samba.org>
Signed-off-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2014-09-30 16:36:09 +02:00
Michael Adam
9fa673bf37 s3:unix_msg: don't close the fd-array at the end of unix_dgram_send_job()
These pthread-pool-jobs should be minimal and ideally only do one
syscall. The closing of the fds is done in unix_dgram_job_finished().

Pair-Programmed-With: Volker Lendecke <vl@samba.org>
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Michael Adam <obnox@samba.org>
Signed-off-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2014-09-30 16:36:09 +02:00
Michael Adam
698e8a2357 s3:unix_msg: add "close_fds" exit point to unix_msg_recv()
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2014-09-30 16:36:09 +02:00
Michael Adam
a4edec4e8d s3:unix_msg: fix a tab<->space mixup in unix_msg_recv()
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2014-09-27 10:17:05 +02:00
Michael Adam
1b35d2ed63 s3:unix_msg: add fds-array to unix_msg_send() for fd passing
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Michael Adam <obnox@samba.org>
2014-09-24 08:44:11 +02:00
Stefan Metzmacher
c689547c93 s3:unix_msg: pass the fd array to the unix_msg recv_callback function
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-24 08:44:11 +02:00
Michael Adam
af573af0ff s3:unix_msg: add fds-array to unix_dgram_send() for fd-passing
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Michael Adam <obnox@samba.org>
2014-09-24 08:44:11 +02:00
Stefan Metzmacher
3f519a507a s3:unix_msg: pass the fd array to the unix_dgram recv_callback function
For now unix_msg_recv() will just close the fds, but they will be passed
to the unix_msg recv_callback in the next commits.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-24 08:44:11 +02:00
Michael Adam
5b6f0416e0 s3:unix_msg: read fds from recvmsg in unix_dgram_recv_handler()
For now we directly close the fds, the next commits will pass them
to the recv_callback function.

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Michael Adam <obnox@samba.org>
2014-09-24 08:44:11 +02:00
Stefan Metzmacher
c9d08be7d0 s3:unix_msg: add close_fd_array()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-24 08:44:11 +02:00
Stefan Metzmacher
eca6d83a5f s3:unix_msg: use sendmsg() in unix_dgram_send_job()
This prepares fd-passing.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-24 08:44:11 +02:00
Volker Lendecke
fb9067c789 Remove a few #ifdef EWOULDBLOCk
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2014-09-18 20:36:11 +02:00
Volker Lendecke
f4e7a49cd7 unix_msg: simplify unix_msg_send
We have a variable array inside one-fragment fast path anyway. Moving
that to the toplevel of the function saves us a malloc/free pair.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-07-28 22:04:13 +02:00
Volker Lendecke
f1f43886f0 unix_msg: Use struct initializers
Saves a few lines and bytes of .text

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-07-28 22:04:13 +02:00
Volker Lendecke
8621870559 unix_msg: Use empty arrays in structs
Just a simple style update

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-07-28 22:04:13 +02:00
Volker Lendecke
516e2f5e68 unix_msg: Lift sockaddr_un handling from unix_msg_send
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-06-18 18:51:13 +02:00
Volker Lendecke
73a1205fe8 unix_msg: Lift sockaddr_un handling from unix_msg_init
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-06-18 18:51:13 +02:00
Volker Lendecke
0d81063ea9 unix_msg: Lift sockaddr_un handling from unix_dgram_send
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-06-18 18:51:13 +02:00
Volker Lendecke
6ea627b357 unix_msg: Lift sockaddr_un handling from unix_dgram_send_queue_init
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-06-18 18:51:13 +02:00
Volker Lendecke
4ca79b0b11 unix_msg: Lift sockaddr_un handling from unix_dgram_init
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-06-18 18:51:13 +02:00
Michael Adam
6a0ebc4596 s3:messaging: protect use of msg_control with HAVE_STRUCT_MSGHDR_MSG_CONTROL
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Tue Jun  3 01:14:17 CEST 2014 on sn-devel-104
2014-06-03 01:14:17 +02:00
Michael Adam
bd22312442 s3:messaging: change unix_dgram_recv_handler() to use recvmsg, not recv
This is in preparation of adding fd-passing to messaging.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri May 30 02:28:15 CEST 2014 on sn-devel-104
2014-05-30 02:28:15 +02:00
Volker Lendecke
ec4496b823 unix_msg: Simplify unix_msg_send a bit
Now that we settled on variable arrays, remove a fixed one

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat May 24 02:56:31 CEST 2014 on sn-devel-104
2014-05-24 02:56:31 +02:00
Volker Lendecke
6dcf2c7eab lib: Add unix_msg
This is a messaging layer based on unix domain datagram sockets.

Sending to an idle socket is just one single nonblocking sendmsg call. If the
recv queue is full, we start a background thread to do a blocking call. The
source4 based imessaging uses a polling fallback. In a situation where
thousands of senders beat one single blocked socket, this will generate load on
the system due to the constant polling. This does not happen with a threaded
blocking send call.

The threaded approach has another advantage: We save become_root() calls on the
retries. The access checks are done when the blocking socket is connected, the
threaded blocking send call does not check permissions anymore.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-04-23 22:33:08 +02:00