1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 18:55:19 +03:00
Commit Graph

122 Commits

Author SHA1 Message Date
Zdenek Kabelac
1ce21c19d5 va_list: properly pass va_list through functions
Code should not just pass va_list arg through the function
as args could be passed in many strange ways.
Use va_copy().

For details look in i.e.:

http://julipedia.meroh.net/2011/09/using-vacopy-to-safely-pass-ap.html
2014-09-16 11:42:40 +02:00
Zdenek Kabelac
24df01f735 cleanup: avoid double assign
Skip setting a value to a variable which is never
used and overwritten/set afterwards.
2014-08-19 14:33:06 +02:00
Peter Rajnoha
3208396ce5 coverity: fix issues reported by coverity 2014-06-24 14:58:53 +02:00
Zdenek Kabelac
b193a3b09f cleanup: rename variable wait
With older system headers (sys/wait.h) this shadows declaration.
2014-06-19 12:02:48 +02:00
Petr Rockai
488f308527 libdaemon: Keep track of client threads, wait before shutdown. 2014-06-09 01:50:57 +02:00
Zdenek Kabelac
b7741f0a83 libdaemon: header cleanup
Ensure  daemon-io.h is used as a generic header included
with configure defines before other headers.
(In future all lvm2 libraries should settle on a single lib.h header)
Rename couple defines to better match header file names.
2014-04-18 16:38:49 +02:00
Peter Rajnoha
c84face8ce libdaemon: fix misleading "WARNING: Ignoring unsupported value for expected." when communicating with daemon
When we're trying to search for certain tree node
in daemon's reply, we default to a blank string ""
if the node is not found. This happens during lvmetad
initialization.

However, when the default blank string is used, we
can't use dm_config_find_str at the same time - the
dm_config_find_str_allow_empty should be used instead.
Otherwise a a warning message:

  "WARNING: Ignoring unsupported value for ..."

is issued.
2014-03-24 16:47:08 +01:00
Alasdair G Kergon
84394c0219 lvmetad: extend socket/pid file handling
Make it easier to run a live lvmetad in debugging mode and
to avoid conflicts if multiple test instances need to be run
alongside a live one.

No longer require -s when -f is used: use built-in default.
Add -p to lvmetad to specify the pid file.
No longer disable pidfile if -f used to run in foreground.
If specified socket file appears to be genuine but stale, remove it
before use.
On error, only remove lvmetad socket file if created by the same
process.  (Previous code removes socket even while a running instance
is using it!)
2013-11-29 20:56:29 +00:00
Zdenek Kabelac
50e1fad86a cleanup: use matching signed types 2013-11-28 12:47:51 +01:00
Alasdair G Kergon
527db4645f gcc: replace #ifdef linux with __linux__ 2013-11-13 13:56:29 +00:00
Petr Rockai
7d299ecbb3 libdaemon: Fix a subtle race in worker thread creation. 2013-10-10 00:34:35 +02:00
Petr Rockai
808a5d945e libdaemon: Fix an invalid memory read. 2013-10-08 23:21:09 +02:00
Zdenek Kabelac
c5957ee2ff cleanup: easier to read loop code
buffer_write now accepts const pointer
Simplify loops and drop goto when not needed.
2013-06-18 22:13:41 +02:00
Zdenek Kabelac
155841c349 lvmetad: fix compare function
Check for enough space in preallocated buffer.
Fixes problem, when lvm code started to suddenly allocate
too big memory chunks.

TODO: lvmetad protocol should announce needed size ahead,
so if metadata have 1MB we are not reallocating memory...
2013-06-18 22:12:51 +02:00
Zdenek Kabelac
e3d3921779 lvmetad: use dm_ malloc wrappers
Use matching dm_ functions for internally used buffers.
2013-06-18 22:11:31 +02:00
Zdenek Kabelac
855175fa26 cleanup: add printf attribute
Add gcc attribute for printf for daemon_logf().
2013-04-21 23:14:05 +02:00
Petr Rockai
dce8d06af7 libdaemon: Print a diagnostic when we fail to lock the pidfile. 2013-04-15 16:07:07 +02:00
Zdenek Kabelac
8bcc1da2f3 locales: use higher prio LC_ALL variable
For reseting locale environment into significantly less memory
consuming version 'C' - use LC_ALL instead of LANG since it has
higher priority in locale settings.

Otherwise we may observe whole locale-archive which might be
over 100MB on i.e. Fedora systems locked in memory with
some daemons.
2013-01-22 11:25:02 +01:00
Alasdair G Kergon
981962b339 libdaemon: add logging to daemon_open
Log all conditions encountered in daemon_open().

Only store errno when known to be set.
2013-01-04 23:29:59 +00:00
Zdenek Kabelac
3e8dbfaecf lvmetad: add check for failure dm_config_write_node
Detect if dm_config_write_node failed and fail correctly.
2012-12-15 17:23:27 +01:00
Zdenek Kabelac
4008f4f891 lvmetad: fix socket leak in handle_connect
Close socket_fd and report error on malloc failure.
2012-12-15 17:23:27 +01:00
Zdenek Kabelac
399fc1bb33 lvmetad: keep returned struct fully initialized
Always clear the response structure.
Simplify daemon_reply initialization.
2012-12-15 17:23:27 +01:00
Zdenek Kabelac
788ac7fa54 libdaemon: check for strdup result
Detect failure of dm_pool_strdup() and print error in fail path.
Save one extra strchr call - since we already know the distance
for the '=' character.

Drop stack trace from return after log_error().
2012-12-15 17:23:26 +01:00
Zdenek Kabelac
1b05438fcb cleanup: ignore errors
Since we are doing just dump and function doesn't report
any error, explicitely ignore return values from
dm_config_write_node and dm_asprintf.

Same applies for the logging function.
2012-12-15 14:57:40 +01:00
Alasdair G Kergon
8290de964f lvmetad: rename DEBUG() to DEBUGLOG()
DEBUG is already defined by -DDEBUG
2012-10-15 14:20:11 +01:00
Alasdair G Kergon
78dafcba99 lvmetad: use -l for logging level not -d 2012-10-15 10:44:43 +01:00
Zdenek Kabelac
3ed2c32e0a lvmetad: empty types string is ok
Since now return code is test - return OK for this case.
2012-10-15 11:02:15 +02:00
Alasdair G Kergon
a0e60d27ff lvmetad: document and tidy cmdline args
Try to bring the lvmetad usage text and man page closer to the code.
There seem to be 3 useful ways to use -d with lvmetad at the moment:
  -d all
  -d wire
  -d debug
(They can also be comma-separated like -d wire,debug.)
Prior to the last release, -d, -dd and -ddd were supported.
Fail if an unrecognised debug arg is supplied on the command line.
Change -V to report the same version as the lvm binary: previously it
just reported version 0.
2012-10-15 02:06:27 +01:00
Zdenek Kabelac
920352da70 lvmetad: fix leak of append on error path 2012-10-14 23:14:48 +02:00
Zdenek Kabelac
4379365cae lvmetad: fix memory leaks in error paths
Destroy interator in error path.
Releasy any possible allocated buffer from buffer_append_f
and buffer_append_vf  in error path.
2012-10-13 19:19:50 +02:00
Zdenek Kabelac
88c547d1ca lvmetad: move initialization in the inner loop
Set append to NULL in the front of cycle, so the INTERNAL error path
is not leading to double-free of append pointer.
2012-10-13 19:15:15 +02:00
Zdenek Kabelac
feea5003cc cleanup: remove unneeded headers
Header do not provide any needed symbols.
2012-10-13 19:13:25 +02:00
Zdenek Kabelac
5a958655dd lvmetad: fix test for dm_asprintf 2012-10-12 11:36:01 +02:00
Zdenek Kabelac
f2a5d3ae3a lvmetad: validate dm_asprintf in buffer_append_vf
Check result of dm_asprintf
Check buffer_append result
Declare vars in front
2012-10-12 10:59:10 +02:00
Zdenek Kabelac
5c792f620b lvmetad: check result of buffer_realloc 2012-10-12 10:59:10 +02:00
Zdenek Kabelac
9ee071705b cleanup: fix compiler warnings
remove unused vars
move var declarations into the front of functions.
fix some sign warnings
2012-10-12 10:25:07 +02:00
Petr Rockai
b07df8850a libdaemon: Make buffer handling asymptotically more efficient. 2012-10-11 18:09:41 +02:00
Petr Rockai
329d10268c libdaemon-server: Do not create pidfile if NULL. 2012-10-09 20:37:34 +02:00
Petr Rockai
a19a595343 libdaemon-client: Fix a memory leak in daemon_send. 2012-10-08 20:35:29 +02:00
Petr Rockai
4b4c2833d9 libdaemon-server: Optimize logging for a fast no-output path. 2012-10-08 20:35:29 +02:00
Petr Rockai
cc9c02fe68 libdaemon-server: Fix a memory leak in daemon_log_multi. 2012-10-08 20:35:29 +02:00
Petr Rockai
662a2122f6 libdaemon: Split daemon-shared.[hc] into daemon-io.[hc] and config-util.[hc]. 2012-09-26 17:26:23 +02:00
Petr Rockai
4ece923a4b libdaemonclient: Use log_sys_error in place of perror. 2012-09-26 17:26:23 +02:00
Petr Rockai
7a2a1a7456 libdaemonclient: Use dm_{malloc,free} in place of {malloc,free}. 2012-09-26 17:26:23 +02:00
Petr Rockai
c731bb1ee1 lvmetad: Fix #845269: SEGV on corrupt lvmetad response. 2012-09-26 17:26:23 +02:00
Petr Rockai
0a87fed794 Makefiles: Build libdaemonclient unconditionally. 2012-09-26 17:26:23 +02:00
Petr Rockai
c9f56d639b lvmetad: Use "%" PRId64 in place of "%d" for extra clarity. 2012-09-26 17:26:16 +02:00
Petr Rockai
c7b17836ea Implement devices/global_filter.
The global filter is applied first, and is also applied in pvscan --cache (which
is called from udev rules to keep lvmetad updated). Cf. example.conf.
2012-09-26 14:49:15 +02:00
Petr Rockai
ea14d5159c libdaemon: Extend and refactor APIs.
- move common dm_config_tree manipulation functions from lvmetad-core to
  daemon-shared
- add config-tree-based request manipulation APIs to daemon-client
- factor out _v (va_list) variants of most variadic functions in libdaemon
2012-09-26 14:49:09 +02:00
Zdenek Kabelac
c6f680ee49 clvmd,lvmetad: check for fcntl result
Report any problem of fcntl.
2012-08-23 14:38:48 +02:00
Zdenek Kabelac
93f36fb77f cleanup: add va_end
Pair va_start with va_end.
2012-08-23 14:37:21 +02:00
Zdenek Kabelac
ba309e0da5 cleanup: add standard GPL file header
Add FIXME about DEBUG define colission.
2012-08-23 14:37:20 +02:00
Zdenek Kabelac
b0b507b197 cleanup: use <> for system header file 2012-08-23 14:37:20 +02:00
Zdenek Kabelac
ed53b4b674 lvmetad: do not deref NULL pointer
Call log only for req.cft != NULL.
2012-08-23 14:34:54 +02:00
Zdenek Kabelac
3685701529 lvmetad: fix memleak on error path
Release allocated buffer on error path.
2012-08-23 14:33:27 +02:00
Zdenek Kabelac
8edc0e450d lvmetad: fix memleaks
Release allocated buffers in daemon_logf, daemon_log_parse
2012-08-23 14:33:23 +02:00
Petr Rockai
b61be64370 libdaemon: Draft logging infrastructure.
- logging is not controlled by "levels" but by "types"; types are
  independent of each other... implementation of the usual "log level"
  user-level semantics can be simply done on top; the immediate
  application is enabling/disabling wire traffic logging independently
  of other debug data, since the former is rather bulky and can easily
  obscure almost everything else
- all logs go to "outlets", of which we currently have 2: syslog and
  stderr; which "types" go to which "outlets" is entirely configurable
2012-08-08 09:44:19 +02:00
Marian Csontos
3843f54974 [lvmetad] Continue reading/writing on EINTR 2012-08-02 16:50:37 +02:00
Marian Csontos
49ae67cba3 lvmetad: Skip redundant checks on no input 2012-08-02 16:50:37 +02:00
Peter Rajnoha
8d5ae472e5 daemon-server: fix error message on daemon shutdown
If a daemon (like lvmetad that is using common daemon-server code)
received a kill signal that was supposed to shut the daemon down,
a spurious message was issued: "Failed to handle a client connection".

This happened if the kill signal came just in the middle of waiting
for a client request in "select" - the request that was supposed to
be handled was blank at that moment of course.
2012-07-19 16:45:08 +02:00
Zdenek Kabelac
6f3cd63551 cleanup: replace memset with struct initilization
Simplifies the code, properly detects too long socket paths,
drops unused parameter.
2012-06-22 13:23:03 +02:00
Peter Rajnoha
bf29fa49d3 Use dm_strncpy instead of plain strncpy while setting the socket path.
Also check the return value as it meaningless to work with truncated strings.
2012-04-27 09:52:33 +00:00
Peter Rajnoha
9a2b6bda59 strcpy -> strncpy in common daemon code. 2012-04-10 12:55:37 +00:00
Peter Rajnoha
761407217a Do exit if LISTEN_PID environment variable not correct during systemd handover. 2012-03-16 21:30:53 +00:00
Peter Rajnoha
93945bb616 Use SD_ACTIVATION env. var. in systemd units to better detect systemd in use.
LISTEN_PID and LISTEN_FDS environment variables are defined only during systemd
"start" action. But we still need to know whether we're activated during
"reload" action as well - we use the reload action to call "dmeventd -R"/"lvmetad -R"
for statefull daemon restart. We can't use normal "restart" as that is simply
composed of "stop" and "start" and we would lose any state the daemon has.
2012-03-14 15:51:51 +00:00
Peter Rajnoha
32b7eb9b6b Do not unlink the socket on daemon shutdown if activation is done via systemd. 2012-03-08 14:54:05 +00:00
Zdenek Kabelac
c452307543 Few more close and dev_close trace
Adding (void) where we cannot really report an error.
2012-03-01 21:12:37 +00:00
Petr Rockai
823268475c Use 64 bit integers whenever extracting numbers from daemon replies. 2012-03-01 19:54:53 +00:00
Alasdair Kergon
7126d8c21b Reflect new file locations, include file updates etc. 2012-02-28 18:35:04 +00:00
Alasdair Kergon
ec6559c93e move daemon files 2012-02-28 18:30:39 +00:00
Alasdair Kergon
6d41ef6ce5 new makefiles 2012-02-28 18:26:40 +00:00
Alasdair Kergon
ed997ca884 Series of commits to move daemon code into separate top-level dir and
fix build deps etc.
2012-02-28 18:25:48 +00:00