提交 61674cc1 编写于 作者: D Daniel P. Berrange

Make RPC call dispatch threaded

上级 458a673c
Tue Jan 20 16:36:53 GMT 2009 Daniel P. Berrange <berrange@redhat.com>
Make RPC call dispatch threaded
* src/libvirt_private.syms, src/util.h, src/util.c: Add
a general virSetNonBlock() helper with portability to
Win32
* src/remote_internal.c: Re-factor I/O to allow RPC calls
from multiple threads to be handled concurrently.
Tue Jan 20 17:08:20 CET 2009 Daniel Veillard <veillard@redhat.com> Tue Jan 20 17:08:20 CET 2009 Daniel Veillard <veillard@redhat.com>
* src/domain_conf.h src/lxc_driver.c src/uml_driver.c: virDomainObj * src/domain_conf.h src/lxc_driver.c src/uml_driver.c: virDomainObj
......
...@@ -290,6 +290,7 @@ virEnumToString; ...@@ -290,6 +290,7 @@ virEnumToString;
virEventAddHandle; virEventAddHandle;
virEventRemoveHandle; virEventRemoveHandle;
virExec; virExec;
virSetNonBlock;
virFormatMacAddr; virFormatMacAddr;
virGetHostname; virGetHostname;
virParseMacAddr; virParseMacAddr;
......
此差异已折叠。
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <poll.h> #include <poll.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/ioctl.h>
#if HAVE_SYS_WAIT_H #if HAVE_SYS_WAIT_H
#include <sys/wait.h> #include <sys/wait.h>
#endif #endif
...@@ -155,25 +156,35 @@ virArgvToString(const char *const *argv) ...@@ -155,25 +156,35 @@ virArgvToString(const char *const *argv)
return ret; return ret;
} }
int virSetNonBlock(int fd) {
#ifndef __MINGW32__ #ifndef WIN32
static int virSetCloseExec(int fd) {
int flags; int flags;
if ((flags = fcntl(fd, F_GETFD)) < 0) if ((flags = fcntl(fd, F_GETFL)) < 0)
return -1; return -1;
flags |= FD_CLOEXEC; flags |= O_NONBLOCK;
if ((fcntl(fd, F_SETFD, flags)) < 0) if ((fcntl(fd, F_SETFL, flags)) < 0)
return -1; return -1;
#else
unsigned long flag = 1;
/* This is actually Gnulib's replacement rpl_ioctl function.
* We can't call ioctlsocket directly in any case.
*/
if (ioctl (fd, FIONBIO, (void *) &flag) == -1)
return -1;
#endif
return 0; return 0;
} }
static int virSetNonBlock(int fd) {
#ifndef WIN32
static int virSetCloseExec(int fd) {
int flags; int flags;
if ((flags = fcntl(fd, F_GETFL)) < 0) if ((flags = fcntl(fd, F_GETFD)) < 0)
return -1; return -1;
flags |= O_NONBLOCK; flags |= FD_CLOEXEC;
if ((fcntl(fd, F_SETFL, flags)) < 0) if ((fcntl(fd, F_SETFD, flags)) < 0)
return -1; return -1;
return 0; return 0;
} }
......
...@@ -38,6 +38,8 @@ enum { ...@@ -38,6 +38,8 @@ enum {
VIR_EXEC_DAEMON = (1 << 1), VIR_EXEC_DAEMON = (1 << 1),
}; };
int virSetNonBlock(int fd);
int virExec(virConnectPtr conn, int virExec(virConnectPtr conn,
const char *const*argv, const char *const*argv,
const char *const*envp, const char *const*envp,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册