SHA256
1
0
forked from pool/systemd
Dr. Werner Fink 2014-07-01 10:11:44 +00:00 committed by Git OBS Bridge
parent 76696ea5ec
commit 0cd2f82139
4 changed files with 21 additions and 8 deletions

View File

@ -5,9 +5,9 @@ Subject: [PATCH] core: close socket fds asynchronously
http://lists.freedesktop.org/archives/systemd-devel/2014-April/018928.html http://lists.freedesktop.org/archives/systemd-devel/2014-April/018928.html
--- ---
src/core/async.c | 22 ++++++++++++++++++++++ src/core/async.c | 24 ++++++++++++++++++++++++
src/core/service.c | 5 +++-- src/core/service.c | 5 +++--
2 files changed, 25 insertions(+), 2 deletions(-) 2 files changed, 27 insertions(+), 2 deletions(-)
--- src/core/service.c --- src/core/service.c
+++ src/core/service.c 2014-05-16 11:41:50.150735247 +0000 +++ src/core/service.c 2014-05-16 11:41:50.150735247 +0000
@ -47,13 +47,15 @@ http://lists.freedesktop.org/archives/systemd-devel/2014-April/018928.html
int asynchronous_job(void* (*func)(void *p), void *arg) { int asynchronous_job(void* (*func)(void *p), void *arg) {
pthread_attr_t a; pthread_attr_t a;
@@ -70,3 +71,24 @@ int asynchronous_sync(void) { @@ -70,3 +71,26 @@ int asynchronous_sync(void) {
return asynchronous_job(sync_thread, NULL); return asynchronous_job(sync_thread, NULL);
} }
+ +
+static void *close_thread(void *p) { +static void *close_thread(void *p) {
+ close_nointr_nofail(PTR_TO_INT(p)); + int fd = PTR_TO_INT(p);
+ if (fd >= 0)
+ close_nointr_nofail(fd);
+ return NULL; + return NULL;
+} +}
+ +
@ -67,7 +69,7 @@ http://lists.freedesktop.org/archives/systemd-devel/2014-April/018928.html
+ * far away as we can. */ + * far away as we can. */
+ +
+ r = asynchronous_job(close_thread, INT_TO_PTR(fd)); + r = asynchronous_job(close_thread, INT_TO_PTR(fd));
+ if (r < 0) + if (r < 0 && fd >= 0)
+ close_nointr_nofail(fd); + close_nointr_nofail(fd);
+ +
+ return -1; + return -1;

View File

@ -53,16 +53,17 @@ index c32a7ef..d4334b4 100644
return udev_queue; return udev_queue;
} }
@@ -107,6 +110,8 @@ _public_ struct udev_queue *udev_queue_unref(struct udev_queue *udev_queue) @@ -107,6 +110,9 @@ _public_ struct udev_queue *udev_queue_unref(struct udev_queue *udev_queue)
if (udev_queue->refcount > 0) if (udev_queue->refcount > 0)
return NULL; return NULL;
+ close_nointr_nofail(udev_queue->fd); + if (udev_queue->fd >= 0)
+ close_nointr_nofail(udev_queue->fd);
+ +
free(udev_queue); free(udev_queue);
return NULL; return NULL;
} }
@@ -222,3 +227,44 @@ _public_ struct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_qu @@ -222,3 +228,44 @@ _public_ struct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_qu
{ {
return NULL; return NULL;
} }

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Tue Jul 1 09:58:04 UTC 2014 - werner@suse.de
- Be aware that close_nointr_nofail() may fail whereas safe_close() not
------------------------------------------------------------------- -------------------------------------------------------------------
Tue Jul 1 08:56:48 UTC 2014 - werner@suse.de Tue Jul 1 08:56:48 UTC 2014 - werner@suse.de

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Tue Jul 1 09:58:04 UTC 2014 - werner@suse.de
- Be aware that close_nointr_nofail() may fail whereas safe_close() not
------------------------------------------------------------------- -------------------------------------------------------------------
Tue Jul 1 08:56:48 UTC 2014 - werner@suse.de Tue Jul 1 08:56:48 UTC 2014 - werner@suse.de