[systemd-devel] [PATCH] journal: Add missing byte order conversions

2013-12-31 Thread George McCollister
Convert entry_array.items[0] to host byte order prior to passing it to
chain_cache_put().

Signed-off-by: George McCollister george.mccollis...@gmail.com
---
 src/journal/journal-file.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 121b40a..275324b 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -1452,7 +1452,7 @@ static int generic_array_get(
 
 found:
 /* Let's cache this item for the next invocation */
-chain_cache_put(f-chain_cache, ci, first, a, o-entry_array.items[0], 
t, i);
+chain_cache_put(f-chain_cache, ci, first, a, 
le64toh(o-entry_array.items[0]), t, i);
 
 r = journal_file_move_to_object(f, OBJECT_ENTRY, p, o);
 if (r  0)
@@ -1685,7 +1685,7 @@ found:
 return 0;
 
 /* Let's cache this item for the next invocation */
-chain_cache_put(f-chain_cache, ci, first, a, 
array-entry_array.items[0], t, subtract_one ? (i  0 ? i-1 : (uint64_t) -1) : 
i);
+chain_cache_put(f-chain_cache, ci, first, a, 
le64toh(array-entry_array.items[0]), t, subtract_one ? (i  0 ? i-1 : 
(uint64_t) -1) : i);
 
 if (subtract_one  i == 0)
 p = last_p;
-- 
1.8.2.1

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 2/2] journald: fix fd leak in journal_file_empty

2013-09-04 Thread George McCollister
Before my previous patch, journal_file_empty wasn't be called with the
correct filename. Now that it's being called with the correct filename
it leaks file descriptors. This patch closes the file descriptors before
returning.

Signed-off-by: George McCollister george.mccollis...@gmail.com
---
 src/journal/journal-vacuum.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/journal/journal-vacuum.c b/src/journal/journal-vacuum.c
index ace7722..2cfc73c 100644
--- a/src/journal/journal-vacuum.c
+++ b/src/journal/journal-vacuum.c
@@ -136,12 +136,18 @@ static int journal_file_empty(int dir_fd, const char 
*name) {
 if (fd  0)
 return -errno;
 
-if (lseek(fd, offsetof(Header, n_entries), SEEK_SET)  0)
+if (lseek(fd, offsetof(Header, n_entries), SEEK_SET)  0) {
+close(fd);
 return -errno;
+}
 
 r = read(fd, n_entries, sizeof(n_entries));
-if (r != sizeof(n_entries))
+if (r != sizeof(n_entries)) {
+close(fd);
 return r == 0 ? -EINVAL : -errno;
+}
+
+close(fd);
 
 return le64toh(n_entries) == 0;
 }
-- 
1.8.2.1

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] fixed hashmap leaks in mmap-cache

2013-08-01 Thread George McCollister
hashmap_free() wasn't being called on m-contexts and m-fds resulting
in a leak.

To reproduce do:
while(1) {
sd_journal_open(j, SD_JOURNAL_LOCAL_ONLY);
sd_journal_close(j);
}

Memory usage will increase until OOM.

Signed-off-by: George McCollister george.mccollis...@gmail.com
---
 src/journal/mmap-cache.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/journal/mmap-cache.c b/src/journal/mmap-cache.c
index 767f555..03b57be 100644
--- a/src/journal/mmap-cache.c
+++ b/src/journal/mmap-cache.c
@@ -307,9 +307,13 @@ static void mmap_cache_free(MMapCache *m) {
 while ((c = hashmap_first(m-contexts)))
 context_free(c);
 
+hashmap_free(m-contexts);
+
 while ((f = hashmap_first(m-fds)))
 fd_free(f);
 
+hashmap_free(m-fds);
+
 while (m-unused)
 window_free(m-unused);
 
-- 
1.8.2.1

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] ignore keep_free when creating a new journal

2013-04-26 Thread George McCollister
keep_free should be ignored when creating a new journal, otherwise
server_rotate() will fail to setup the new journal if keep_free is exceed
and server_vacuum will not be able to reclaim space.

There might be more ellegant solutions to this problem but this works in my
tests and it's a simple change.

Signed-off-by: George McCollister george.mccollis...@gmail.com
---
 src/journal/journal-file.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index a44e126..f720d0b 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -2351,6 +2351,7 @@ int journal_file_open(
 JournalFile *f;
 int r;
 bool newly_created = false;
+uint64_t save_keep_free;
 
 assert(fname);
 assert(ret);
@@ -2491,6 +2492,11 @@ int journal_file_open(
 goto fail;
 }
 
+if (newly_created) {
+save_keep_free = f-metrics.keep_free;
+f-metrics.keep_free = 0;
+}
+
 #ifdef HAVE_GCRYPT
 r = journal_file_hmac_setup(f);
 if (r  0)
@@ -2521,6 +2527,9 @@ int journal_file_open(
 if (r  0)
 goto fail;
 
+if (newly_created)
+f-metrics.keep_free = save_keep_free;
+
 *ret = f;
 return 0;
 
-- 
1.8.2.1

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Socket is dying, how to automatically restart it?

2013-04-23 Thread George McCollister

On 04/20/2013 08:04 AM, Koen Kooi wrote:

Op 18 apr. 2013, om 19:18 heeft George 
McCollistergeorge.mccollis...@gmail.com  het volgende geschreven:


On 04/10/2013 12:03 PM, Koen Kooi wrote:

Hi,

I have a bit of a heisenbug where dropbear.socket will just die and needs a 
systemctl restart dropbear.socket. I can't tell why it's dying, just that it 
does within 3 days of uptime. After restarting it it seems to be rock solid 
again for at least some weeks.

The real way to fix this is to find out why it dies, but till someone figures 
that out I'm looking to a way to automatically restart the socket when it 
fails, kinda like Restart=Always for services. Is such a thing possible? This 
is with 195 and 196, haven't tried 201 yet.

I'm having exactly the same problem with sshd.socket (openssh) with systemd 
197. I've done a netstat after it dies (just says dead no useful information) 
and port 22 still shows up under listening. systemctl start sshd.socket fixes 
the problem. I just upgraded to systemd 201 so I'll let you know if the problem 
shows up again. The problem happens intermittently so its been a bit elusive.

It is indeed elusive, it hasn't happened to me in the past week, so progress is 
slow on this.

regards,

Koen
This is really strange but I think I just accidentally found a way to 
reproduce the problem.

1) Reboot
2) Verify ssh works
3) login as root and run: systemctl --system daemon-reload

Can't ssh anymore.

If I do 'systemctl start sshd.socket' I can ssh again and doing 
'systemctl --system daemon-reload' again doesn't seem to break it.

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Socket is dying, how to automatically restart it?

2013-04-18 Thread George McCollister

On 04/10/2013 12:03 PM, Koen Kooi wrote:

Hi,

I have a bit of a heisenbug where dropbear.socket will just die and needs a 
systemctl restart dropbear.socket. I can't tell why it's dying, just that it 
does within 3 days of uptime. After restarting it it seems to be rock solid 
again for at least some weeks.

The real way to fix this is to find out why it dies, but till someone figures 
that out I'm looking to a way to automatically restart the socket when it 
fails, kinda like Restart=Always for services. Is such a thing possible? This 
is with 195 and 196, haven't tried 201 yet.

regards,

Koen
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel
I'm having exactly the same problem with sshd.socket (openssh) with 
systemd 197. I've done a netstat after it dies (just says dead no useful 
information) and port 22 still shows up under listening. systemctl start 
sshd.socket fixes the problem. I just upgraded to systemd 201 so I'll 
let you know if the problem shows up again. The problem happens 
intermittently so its been a bit elusive.


Regards,
George McCollister
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Future of systemd Python module

2013-01-22 Thread George McCollister
Are there plans (or desire) to expand the Python module included with 
systemd beyond Journal? Is there desire to replicate or wrap 
functionality provided by the DBUS API or is this beyond the design 
scope of this module?


Regards,
George McCollister
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel