Re: [libvirt] PATCH: 1/4: Remove qemudSetNonlock/SetCloseExec

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The qemudSetNonBlock() and qemudSetCloseExec() should not exist anymore
since we have impls virSetNonBlock virSetCloseExec in util.h. Removing
these makes it possible to link directly to qemud/event.c for a later
test case.

Daniel

diff -r d5dc15adcbea qemud/event.c
--- a/qemud/event.c	Fri May 08 11:58:19 2009 +0100
+++ b/qemud/event.c	Fri May 08 15:52:29 2009 +0100
@@ -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],
diff -r d5dc15adcbea qemud/qemud.c
--- a/qemud/qemud.c	Fri May 08 11:58:19 2009 +0100
+++ b/qemud/qemud.c	Fri May 08 15:52:29 2009 +0100
@@ -371,32 +371,6 @@ qemudDispatchSignalEvent(int watch ATTRI
     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_
         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 *se
         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 qe
     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));
diff -r d5dc15adcbea qemud/qemud.h
--- a/qemud/qemud.h	Fri May 08 11:58:19 2009 +0100
+++ b/qemud/qemud.h	Fri May 08 15:52:29 2009 +0100
@@ -198,9 +198,6 @@ void qemudLog(int priority, const char *
     ATTRIBUTE_FORMAT(printf,2,3);
 
 
-int qemudSetCloseExec(int fd);
-int qemudSetNonBlock(int fd);
-
 int
 remoteDispatchClientRequest (struct qemud_server *server,
                              struct qemud_client *client,


-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]