mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 02:51:16 +00:00
Remove use of qemudSetNonBlock/SetCloseExec in favour of shared impl
This commit is contained in:
parent
b8761bb215
commit
72dc6d60ab
@ -1,3 +1,9 @@
|
||||
Tue May 12 16:38:22 BST 2009 Daniel P. Berrange <berrange@redhat.com>
|
||||
|
||||
* qemud/qemud.c, qemud/qemud.h, qemud/event.c: Remove use
|
||||
of qemudSetNonBock/SetCloseExec in favour of virSetNonBlock
|
||||
and virSetCloseExec.
|
||||
|
||||
Tue May 12 16:38:22 BST 2009 Daniel P. Berrange <berrange@redhat.com>
|
||||
|
||||
Allow for quieter build with 'make -s'
|
||||
|
@ -30,7 +30,8 @@
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "qemud.h"
|
||||
#include "threads.h"
|
||||
#include "logging.h"
|
||||
#include "event.h"
|
||||
#include "memory.h"
|
||||
#include "util.h"
|
||||
@ -597,10 +598,10 @@ int virEventInit(void)
|
||||
return -1;
|
||||
|
||||
if (pipe(eventLoop.wakeupfd) < 0 ||
|
||||
qemudSetNonBlock(eventLoop.wakeupfd[0]) < 0 ||
|
||||
qemudSetNonBlock(eventLoop.wakeupfd[1]) < 0 ||
|
||||
qemudSetCloseExec(eventLoop.wakeupfd[0]) < 0 ||
|
||||
qemudSetCloseExec(eventLoop.wakeupfd[1]) < 0)
|
||||
virSetNonBlock(eventLoop.wakeupfd[0]) < 0 ||
|
||||
virSetNonBlock(eventLoop.wakeupfd[1]) < 0 ||
|
||||
virSetCloseExec(eventLoop.wakeupfd[0]) < 0 ||
|
||||
virSetCloseExec(eventLoop.wakeupfd[1]) < 0)
|
||||
return -1;
|
||||
|
||||
if (virEventAddHandleImpl(eventLoop.wakeupfd[0],
|
||||
|
@ -371,32 +371,6 @@ qemudDispatchSignalEvent(int watch ATTRIBUTE_UNUSED,
|
||||
virMutexUnlock(&server->lock);
|
||||
}
|
||||
|
||||
int qemudSetCloseExec(int fd) {
|
||||
int flags;
|
||||
if ((flags = fcntl(fd, F_GETFD)) < 0)
|
||||
goto error;
|
||||
flags |= FD_CLOEXEC;
|
||||
if ((fcntl(fd, F_SETFD, flags)) < 0)
|
||||
goto error;
|
||||
return 0;
|
||||
error:
|
||||
VIR_ERROR0(_("Failed to set close-on-exec file descriptor flag"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int qemudSetNonBlock(int fd) {
|
||||
int flags;
|
||||
if ((flags = fcntl(fd, F_GETFL)) < 0)
|
||||
goto error;
|
||||
flags |= O_NONBLOCK;
|
||||
if ((fcntl(fd, F_SETFL, flags)) < 0)
|
||||
goto error;
|
||||
return 0;
|
||||
error:
|
||||
VIR_ERROR0(_("Failed to set non-blocking file descriptor flag"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int qemudGoDaemon(void) {
|
||||
int pid = fork();
|
||||
@ -525,8 +499,8 @@ static int qemudListenUnix(struct qemud_server *server,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (qemudSetCloseExec(sock->fd) < 0 ||
|
||||
qemudSetNonBlock(sock->fd) < 0)
|
||||
if (virSetCloseExec(sock->fd) < 0 ||
|
||||
virSetNonBlock(sock->fd) < 0)
|
||||
goto cleanup;
|
||||
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
@ -687,8 +661,8 @@ remoteListenTCP (struct qemud_server *server,
|
||||
else
|
||||
sock->port = -1;
|
||||
|
||||
if (qemudSetCloseExec(sock->fd) < 0 ||
|
||||
qemudSetNonBlock(sock->fd) < 0)
|
||||
if (virSetCloseExec(sock->fd) < 0 ||
|
||||
virSetNonBlock(sock->fd) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (listen (sock->fd, 30) < 0) {
|
||||
@ -1273,8 +1247,8 @@ static int qemudDispatchServer(struct qemud_server *server, struct qemud_socket
|
||||
setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, (void *)&no_slow_start,
|
||||
sizeof no_slow_start);
|
||||
|
||||
if (qemudSetCloseExec(fd) < 0 ||
|
||||
qemudSetNonBlock(fd) < 0) {
|
||||
if (virSetCloseExec(fd) < 0 ||
|
||||
virSetNonBlock(fd) < 0) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
@ -2872,10 +2846,10 @@ int main(int argc, char **argv) {
|
||||
goto error1;
|
||||
|
||||
if (pipe(sigpipe) < 0 ||
|
||||
qemudSetNonBlock(sigpipe[0]) < 0 ||
|
||||
qemudSetNonBlock(sigpipe[1]) < 0 ||
|
||||
qemudSetCloseExec(sigpipe[0]) < 0 ||
|
||||
qemudSetCloseExec(sigpipe[1]) < 0) {
|
||||
virSetNonBlock(sigpipe[0]) < 0 ||
|
||||
virSetNonBlock(sigpipe[1]) < 0 ||
|
||||
virSetCloseExec(sigpipe[0]) < 0 ||
|
||||
virSetCloseExec(sigpipe[1]) < 0) {
|
||||
char ebuf[1024];
|
||||
VIR_ERROR(_("Failed to create pipe: %s"),
|
||||
virStrerror(errno, ebuf, sizeof ebuf));
|
||||
|
@ -198,9 +198,6 @@ void qemudLog(int priority, const char *fmt, ...)
|
||||
ATTRIBUTE_FORMAT(printf,2,3);
|
||||
|
||||
|
||||
int qemudSetCloseExec(int fd);
|
||||
int qemudSetNonBlock(int fd);
|
||||
|
||||
int
|
||||
remoteDispatchClientRequest (struct qemud_server *server,
|
||||
struct qemud_client *client,
|
||||
|
Loading…
Reference in New Issue
Block a user