Commit Graph

74 Commits

Author SHA1 Message Date
Lennart Poettering fb69d7096d socket-proxyd: port to asynchronous name resolution using sd-resolve 2014-06-05 16:12:48 +02:00
Lennart Poettering 3d94f76c99 util: replace close_pipe() with new safe_close_pair()
safe_close_pair() is more like safe_close(), except that it handles
pairs of fds, and doesn't make and misleading allusion, as it works
similarly well for socketpairs() as for pipe()s...
2014-03-24 03:22:44 +01:00
Lennart Poettering 03e334a1c7 util: replace close_nointr_nofail() by a more useful safe_close()
safe_close() automatically becomes a NOP when a negative fd is passed,
and returns -1 unconditionally. This makes it easy to write lines like
this:

        fd = safe_close(fd);

Which will close an fd if it is open, and reset the fd variable
correctly.

By making use of this new scheme we can drop a > 200 lines of code that
was required to test for non-negative fds or to reset the closed fd
variable afterwards.
2014-03-18 19:31:34 +01:00
Lennart Poettering 151b9b9662 api: in constructor function calls, always put the returned object pointer first (or second)
Previously the returned object of constructor functions where sometimes
returned as last, sometimes as first and sometimes as second parameter.
Let's clean this up a bit. Here are the new rules:

1. The object the new object is derived from is put first, if there is any

2. The object we are creating will be returned in the next arguments

3. This is followed by any additional arguments

Rationale:

For functions that operate on an object we always put that object first.
Constructors should probably not be too different in this regard. Also,
if the additional parameters might want to use varargs which suggests to
put them last.

Note that this new scheme only applies to constructor functions, not to
all other functions. We do give a lot of freedom for those.

Note that this commit only changes the order of the new functions we
added, for old ones we accept the wrong order and leave it like that.
2014-02-20 00:03:10 +01:00
Lennart Poettering 7b77ed8cf3 event: be more conservative when returning errors from event handler callbacks
We really should return errors from event handlers if we have a
continous problem and don't know any other solution.
2013-12-13 04:06:43 +01:00
Lennart Poettering cde93897cd event: hook up sd-event with the service watchdog logic
Adds a new call sd_event_set_watchdog() that can be used to hook up the
event loop with the watchdog supervision logic of systemd. If enabled
and $WATCHDOG_USEC is set the event loop will ping the invoking systemd
daemon right after coming back from epoll_wait() but not more often than
$WATCHDOG_USEC/4. The epoll_wait() will sleep no longer than
$WATCHDOG_USEC/4*3, to make sure the service manager is called in time.

This means that setting WatchdogSec= in a .service file and calling
sd_event_set_watchdog() in your daemon is enough to hook it up with the
watchdog logic.
2013-12-11 18:20:09 +01:00
Lennart Poettering 8cf030b349 Revert "socket-proxyd: Add --listener option for listener/destination pairs."
This reverts commit adcf4c81c5.

We have a better solution for the problem of making two processes run in
the same namespace, and --listener is not needed hence and should be
dropped.

Conflicts:
	man/systemd-socket-proxyd.xml
2013-11-27 20:55:15 +01:00
David Strauss adcf4c81c5 socket-proxyd: Add --listener option for listener/destination pairs. 2013-11-25 10:46:48 +10:00
Lennart Poettering adcc4ca30d event: rename sd_event_get() to sd_event_source_get_event() 2013-11-22 01:42:15 +01:00
Lennart Poettering afc6adb5ec bus: introduce concept of a "default" event loop per-thread and make use of it everywhere
Try to emphasize a bit that there should be a mapping between event
loops and threads, hence introduce a logic that there's one "default"
event loop for each thread, that can be queried via
"sd_event_default()".
2013-11-12 00:12:43 +01:00
Lennart Poettering e633ea1c9c socket-proxy: actually properly keep track of connections 2013-11-07 16:53:26 +01:00
Lennart Poettering 1ec6af16f5 socket-proxyd: no need to redefine sockaddr union 2013-11-07 16:53:26 +01:00
Lennart Poettering b7484e2a58 event: make sure we keep a reference to all events we dispatch while we do so. 2013-11-07 00:13:58 +01:00
Lennart Poettering 8569a77629 socket-proxyd: rework to support multiple sockets and splice()-based zero-copy network IO
This also drops --ignore-env, which can't really work anymore if we
allow multiple fds. Also adds support for pretty printing of peer
identities for debug purposes, and abstract namespace UNIX sockets. Also
ensures that we never take more connections than a certain limit.
2013-11-06 23:03:12 +01:00
Lennart Poettering 5f7e83e8ad socket-proxy: clean-up indenting 2013-11-06 18:29:24 +01:00
Lennart Poettering eb9da376d7 clients: unify how we invoke getopt_long()
Among other things this makes sure we always expose a --version command
and show it in the help texts.
2013-11-06 18:28:39 +01:00
David Strauss a42431ca6a socket-proxyd: Actually, some of those sizes are unsigned. 2013-10-31 15:30:49 -07:00
Ronny Chevalier 0885468d80 fix compiler warnings
multiple warnings like

src/socket-proxy/socket-proxyd.c: In function ‘transfer_data_cb’:
src/socket-proxy/socket-proxyd.c:237:25: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 6 has type ‘size_t’ [-Wformat=]
                         log_debug("Buffer now has %ld bytes full.", c->buffer_filled_len);
2013-10-31 15:17:46 -07:00
David Strauss f4bd42aa3c socket-proxyd: Fix-up from previous change to avoid looping on errors. 2013-10-21 18:41:35 -07:00
David Strauss 40976028c6 socket-proxyd: Use ONESHOT to behave properly with multiple accept() processes. 2013-10-21 18:32:08 -07:00
David Strauss 6298945d5c socket-proxyd: Remove datagram research TODO. This proxy will not work with them. 2013-10-19 17:11:36 -07:00
David Strauss 20c7c931a9 socket-proxyd: Comment and log text cleanup.
* Standardize on "nonblocking" spelling, per Linux man pages.
 * Clarify that the nonblocking sockets are never in a "blocking"
   or "unblocked" state, just a "would block" or "ready" state.
2013-10-19 17:05:42 -07:00
Kay Sievers b6818c7d10 socket-proxyd: initialize variable used in error code path 2013-10-20 01:10:49 +02:00
Lennart Poettering 96c374d0a5 socket-proxyd: rename from saproxy
The thing is a daemon, hence needs a "d" prefix. Also, we tend to not
abbreviate names of background components unnecessarily, since they are
not primary commands people type. Then, the fact that this thing does
socket actviation is mostly in implementationd detail for the proxy.

Also, do some minor indenting clean-ups and other code updates.
2013-10-18 02:58:47 +02:00
Renamed from src/saproxy/saproxy.c (Browse further)