Commit graph

32 commits

Author SHA1 Message Date
Michal Schmidt 279d3c9cea treewide: more log_*_errno() conversions 2014-11-28 14:45:55 +01:00
Michal Schmidt da927ba997 treewide: no need to negate errno for log_*_errno()
It corrrectly handles both positive and negative errno values.
2014-11-28 13:29:21 +01:00
Michal Schmidt 0a1beeb642 treewide: auto-convert the simple cases to log_*_errno()
As a followup to 086891e5c1 "log: add an "error" parameter to all
low-level logging calls and intrdouce log_error_errno() as log calls
that take error numbers", use sed to convert the simple cases to use
the new macros:

find . -name '*.[ch]' | xargs sed -r -i -e \
's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/'

Multi-line log_*() invocations are not covered.
And we also should add log_unit_*_errno().
2014-11-28 12:04:41 +01:00
Susant Sahani 25dbe4f50f socket-proxyd: Unchecked return value from library
CID 1237543 (#1 of 1): Unchecked return value from library
(CHECKED_RETURN)
2014-10-09 15:34:07 +02:00
Emil Renner Berthing fdb8bd0fe7 include fcntl.h rather than sys/fcntl.h 2014-09-18 17:59:15 +02:00
Michal Schmidt d5099efc47 hashmap: introduce hash_ops to make struct Hashmap smaller
It is redundant to store 'hash' and 'compare' function pointers in
struct Hashmap separately. The functions always comprise a pair.
Store a single pointer to struct hash_ops instead.

systemd keeps hundreds of hashmaps, so this saves a little bit of
memory.
2014-09-15 16:08:50 +02:00
Zbigniew Jędrzejewski-Szmek 601185b43d Unify parse_argv style
getopt is usually good at printing out a nice error message when
commandline options are invalid. It distinguishes between an unknown
option and a known option with a missing arg. It is better to let it
do its job and not use opterr=0 unless we actually want to suppress
messages. So remove opterr=0 in the few places where it wasn't really
useful.

When an error in options is encountered, we should not print a lengthy
help() and overwhelm the user, when we know precisely what is wrong
with the commandline. In addition, since help() prints to stdout, it
should not be used except when requested with -h or --help.

Also, simplify things here and there.
2014-08-03 21:46:07 -04:00
Thomas Hindoe Paaboel Andersen e5a1c18d70 fix warnings
Prevent use of uninitialized variable and removed a now unused
cleanup function for freeaddrinfo
2014-06-06 23:31:25 +02:00
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)