mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
make use F_CLOEXEC wherever useful
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@174 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
348738751c
commit
5f52999c01
9 changed files with 35 additions and 1 deletions
1
doc/todo
1
doc/todo
|
|
@ -13,7 +13,6 @@
|
|||
- remove all gcc warnings
|
||||
- add total sample cache size to stat
|
||||
- make fragments settings runtime configurable
|
||||
- CLOEXEC
|
||||
- logging
|
||||
- automatic termination of daemon if unused
|
||||
- add sample directory
|
||||
|
|
|
|||
|
|
@ -93,6 +93,8 @@ int pa_signal_init(struct pa_mainloop_api *a) {
|
|||
|
||||
pa_make_nonblock_fd(signal_pipe[0]);
|
||||
pa_make_nonblock_fd(signal_pipe[1]);
|
||||
pa_fd_set_cloexec(signal_pipe[0], 1);
|
||||
pa_fd_set_cloexec(signal_pipe[1], 1);
|
||||
|
||||
api = a;
|
||||
io_event = api->io_new(api, signal_pipe[0], PA_IO_EVENT_INPUT, callback, NULL);
|
||||
|
|
|
|||
|
|
@ -143,6 +143,8 @@ int pa_module_init(struct pa_core *c, struct pa_module*m) {
|
|||
goto fail;
|
||||
}
|
||||
|
||||
pa_fd_set_cloexec(fd, 1);
|
||||
|
||||
if (fstat(fd, &st) < 0) {
|
||||
fprintf(stderr, __FILE__": fstat('%s'): %s\n", p, strerror(errno));
|
||||
goto fail;
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
#include <fcntl.h>
|
||||
|
||||
#include "oss-util.h"
|
||||
#include "util.h"
|
||||
|
||||
int pa_oss_open(const char *device, int *mode, int* pcaps) {
|
||||
int fd = -1;
|
||||
|
|
@ -77,6 +78,8 @@ int pa_oss_open(const char *device, int *mode, int* pcaps) {
|
|||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
pa_fd_set_cloexec(fd, 1);
|
||||
|
||||
return fd;
|
||||
|
||||
|
|
|
|||
|
|
@ -152,6 +152,7 @@ struct pa_socket_client* pa_socket_client_new_ipv4(struct pa_mainloop_api *m, ui
|
|||
goto fail;
|
||||
}
|
||||
|
||||
pa_fd_set_cloexec(c->fd, 1);
|
||||
pa_socket_tcp_low_delay(c->fd);
|
||||
|
||||
sa.sin_family = AF_INET;
|
||||
|
|
@ -181,6 +182,7 @@ struct pa_socket_client* pa_socket_client_new_unix(struct pa_mainloop_api *m, co
|
|||
goto fail;
|
||||
}
|
||||
|
||||
pa_fd_set_cloexec(c->fd, 1);
|
||||
pa_socket_low_delay(c->fd);
|
||||
|
||||
sa.sun_family = AF_LOCAL;
|
||||
|
|
@ -208,6 +210,7 @@ struct pa_socket_client* pa_socket_client_new_sockaddr(struct pa_mainloop_api *m
|
|||
goto fail;
|
||||
}
|
||||
|
||||
pa_fd_set_cloexec(c->fd, 1);
|
||||
if (sa->sa_family == AF_INET)
|
||||
pa_socket_tcp_low_delay(c->fd);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
#include "socket-server.h"
|
||||
#include "socket-util.h"
|
||||
#include "xmalloc.h"
|
||||
#include "util.h"
|
||||
|
||||
struct pa_socket_server {
|
||||
int ref;
|
||||
|
|
@ -65,6 +66,8 @@ static void callback(struct pa_mainloop_api *mainloop, struct pa_io_event *e, in
|
|||
goto finish;
|
||||
}
|
||||
|
||||
pa_fd_set_cloexec(nfd, 1);
|
||||
|
||||
if (!s->on_connection) {
|
||||
close(nfd);
|
||||
goto finish;
|
||||
|
|
@ -122,6 +125,8 @@ struct pa_socket_server* pa_socket_server_new_unix(struct pa_mainloop_api *m, co
|
|||
goto fail;
|
||||
}
|
||||
|
||||
pa_fd_set_cloexec(fd, 1);
|
||||
|
||||
sa.sun_family = AF_LOCAL;
|
||||
strncpy(sa.sun_path, filename, sizeof(sa.sun_path)-1);
|
||||
sa.sun_path[sizeof(sa.sun_path) - 1] = 0;
|
||||
|
|
@ -166,6 +171,8 @@ struct pa_socket_server* pa_socket_server_new_ipv4(struct pa_mainloop_api *m, ui
|
|||
goto fail;
|
||||
}
|
||||
|
||||
pa_fd_set_cloexec(fd, 1);
|
||||
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0)
|
||||
fprintf(stderr, "setsockopt(): %s\n", strerror(errno));
|
||||
|
||||
|
|
|
|||
|
|
@ -217,3 +217,4 @@ finish:
|
|||
pa_xfree(dir);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
15
polyp/util.c
15
polyp/util.c
|
|
@ -249,3 +249,18 @@ void pa_reset_priority(void) {
|
|||
|
||||
setpriority(PRIO_PROCESS, 0, 0);
|
||||
}
|
||||
|
||||
int pa_fd_set_cloexec(int fd, int b) {
|
||||
int v;
|
||||
assert(fd >= 0);
|
||||
|
||||
if ((v = fcntl(fd, F_GETFD, 0)) < 0)
|
||||
return -1;
|
||||
|
||||
v = (v & ~FD_CLOEXEC) | (b ? FD_CLOEXEC : 0);
|
||||
|
||||
if (fcntl(fd, F_SETFD, v) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,4 +44,6 @@ uint32_t pa_age(struct timeval *tv);
|
|||
void pa_raise_priority(void);
|
||||
void pa_reset_priority(void);
|
||||
|
||||
int pa_fd_set_cloexec(int fd, int b);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue