[systemd-commits] 3 commits - src/libsystemd-network src/shared src/test
Zbigniew Jędrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Mon Feb 2 17:35:41 PST 2015
src/libsystemd-network/test-dhcp-client.c | 15 ++++++++++++++-
src/shared/async.c | 12 +++---------
src/test/test-async.c | 2 ++
3 files changed, 19 insertions(+), 10 deletions(-)
New commits:
commit c1d630d5fd3c0b3307811d51f9840652e066a0f2
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Mon Feb 2 14:51:31 2015 -0500
shared/async: simplify asynchronous_job a bit
diff --git a/src/shared/async.c b/src/shared/async.c
index 115901e..7725e6d 100644
--- a/src/shared/async.c
+++ b/src/shared/async.c
@@ -41,24 +41,18 @@ int asynchronous_job(void* (*func)(void *p), void *arg) {
* only in long running processes. */
r = pthread_attr_init(&a);
- if (r != 0)
+ if (r > 0)
return -r;
r = pthread_attr_setdetachstate(&a, PTHREAD_CREATE_DETACHED);
- if (r != 0) {
- r = -r;
+ if (r > 0)
goto finish;
- }
r = pthread_create(&t, &a, func, arg);
- if (r != 0) {
- r = -r;
- goto finish;
- }
finish:
pthread_attr_destroy(&a);
- return r;
+ return -r;
}
static void *sync_thread(void *p) {
diff --git a/src/test/test-async.c b/src/test/test-async.c
index 401e685..abd36d6 100644
--- a/src/test/test-async.c
+++ b/src/test/test-async.c
@@ -38,7 +38,9 @@ int main(int argc, char *argv[]) {
fd = mkostemp_safe(name, O_RDWR|O_CLOEXEC);
assert_se(fd >= 0);
asynchronous_close(fd);
+
assert_se(asynchronous_job(async_func, NULL) >= 0);
+
assert_se(asynchronous_sync() >= 0);
sleep(1);
commit 374c22b351e43ce4ef70ef0ad1bd1e4e520f9a28
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Mon Feb 2 14:50:56 2015 -0500
test-dhcp-client: add a kludge to make valgrind happy
diff --git a/src/libsystemd-network/test-dhcp-client.c b/src/libsystemd-network/test-dhcp-client.c
index 831ec19..8e88641 100644
--- a/src/libsystemd-network/test-dhcp-client.c
+++ b/src/libsystemd-network/test-dhcp-client.c
@@ -521,5 +521,12 @@ int main(int argc, char *argv[]) {
test_discover_message(e);
test_addr_acq(e);
+#ifdef VALGRIND
+ /* Make sure the async_close thread has finished.
+ * valgrind would report some of the phread_* structures
+ * as not cleaned up properly. */
+ sleep(1);
+#endif
+
return 0;
}
commit fe0885f8ce0f49c8d7496344c39abbebc46c6155
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Mon Feb 2 14:46:40 2015 -0500
test-dhcp-client: open a real udp socket for test execution
./test-dhcp-client would attempt to operate fd 0, i.e. stdin.
For example, './test-dhcp-client </dev/null' would fail with EPERM
because /dev/null cannot be used with epoll.
https://bugzilla.redhat.com/show_bug.cgi?id=1076119
diff --git a/src/libsystemd-network/test-dhcp-client.c b/src/libsystemd-network/test-dhcp-client.c
index 8e2ede9..831ec19 100644
--- a/src/libsystemd-network/test-dhcp-client.c
+++ b/src/libsystemd-network/test-dhcp-client.c
@@ -218,7 +218,13 @@ int dhcp_network_bind_raw_socket(int index, union sockaddr_union *link,
int dhcp_network_bind_udp_socket(be32_t address, uint16_t port)
{
- return 0;
+ int fd;
+
+ fd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
+ if (fd < 0)
+ return -errno;
+
+ return fd;
}
int dhcp_network_send_udp_socket(int s, be32_t address, uint16_t port,
More information about the systemd-commits
mailing list