-----BEGIN PGP SIGNATURE-----
iQIcBAABCAAGBQJahcheAAoJEL6G67QVEE/f48oP/i7z661EpJypffna2IQlqF1k m+MMzWHjXKmLhIVtvypTwoqvPSdzlz4ZaSOx5MuWctL4MXS2IyzYVGKYBp9v+zLN DZr8ZSAYD+r2EW6SiIMJb3Tzr//tgNsal8TJF7iv4ZCX0R+jXCNDfdp4vF8CHEgW 8Lnkh6pHYnd792askpOuIe1+Mi0rUxGgIPvU4FbOicSYn4keLtr2TobtCNgIUhig 8VJVHa9h6nASl4zU0ZD/+Y9lOwZh+wAxN7r7afQy3TqQSEFHcqccqSDB9MQACKgx RXfInu7BWuK2ir+LlvKluTFaXWIdxaey2BMKN0ygcy9sU900gshJixVT0+QAGOQO XNE8aqTwmoleQDULVAK8LhLI4CQs/z5QBc5LzMD/D6jYh6JuD7kasyurStqTg6e5 tSoRqPMw0uHlmlrmw0BKU1bz/MKnMxOhv1vMsLvO4WRWxF8kS8bYJjGwvlluwptj kKNIj1RGmvPt+hm1QvMgzQehTqB4yJyn14gdfhowfiEEomOerjyDVC24Sf2kvGha gGEo2EOIfFc7jg2/S+06mMr47OVqLT2Bq86cDiXM+khoAm3jvPw5SnCsHkeduUKv 2fFuKMQUWU5vjHgad4y+FJpT6ysr9rcMb6Ld806226+M1mBWx1BQoCbu3zco2d0D GAhMVaGRLphcK091eCMn =7TYE -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/berrange/tags/qio-next-pull-request' into staging # gpg: Signature made Thu 15 Feb 2018 17:50:22 GMT # gpg: using RSA key BE86EBB415104FDF # gpg: Good signature from "Daniel P. Berrange <dan@berrange.com>" # gpg: aka "Daniel P. Berrange <berrange@redhat.com>" # Primary key fingerprint: DAF3 A6FD B26B 6291 2D0E 8E3F BE86 EBB4 1510 4FDF * remotes/berrange/tags/qio-next-pull-request: allow to build with older sed io/channel-command: Do not kill the child process after closing the pipe io: Add /dev/fdset/ support to QIOChannelFile io: Don't call close multiple times in QIOChannelFile io: Fix QIOChannelFile when creating and opening read-write io/channel-websock: handle continuous reads without any data io: fix QIONetListener memory leak Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
0402ca3c70
3
Makefile
3
Makefile
@ -256,8 +256,7 @@ GENERATED_FILES += $(KEYCODEMAP_FILES)
|
||||
|
||||
ui/input-keymap-%.c: $(KEYCODEMAP_GEN) $(KEYCODEMAP_CSV) $(SRC_PATH)/ui/Makefile.objs
|
||||
$(call quiet-command,\
|
||||
src=$$(echo $@ | sed -E -e "s,^ui/input-keymap-(.+)-to-(.+)\.c$$,\1,") && \
|
||||
dst=$$(echo $@ | sed -E -e "s,^ui/input-keymap-(.+)-to-(.+)\.c$$,\2,") && \
|
||||
stem=$* && src=$${stem%-to-*} dst=$${stem#*-to-} && \
|
||||
test -e $(KEYCODEMAP_GEN) && \
|
||||
$(PYTHON) $(KEYCODEMAP_GEN) \
|
||||
--lang glib2 \
|
||||
|
@ -73,7 +73,7 @@ qio_channel_file_new_fd(int fd);
|
||||
* qio_channel_file_new_path:
|
||||
* @path: the file path
|
||||
* @flags: the open flags (O_RDONLY|O_WRONLY|O_RDWR, etc)
|
||||
* @mode: the file creation mode if O_WRONLY is set in @flags
|
||||
* @mode: the file creation mode if O_CREAT is set in @flags
|
||||
* @errp: pointer to initialized error object
|
||||
*
|
||||
* Create a new IO channel object for a file represented
|
||||
|
@ -301,6 +301,9 @@ static int qio_channel_command_close(QIOChannel *ioc,
|
||||
{
|
||||
QIOChannelCommand *cioc = QIO_CHANNEL_COMMAND(ioc);
|
||||
int rv = 0;
|
||||
#ifndef WIN32
|
||||
pid_t wp;
|
||||
#endif
|
||||
|
||||
/* We close FDs before killing, because that
|
||||
* gives a better chance of clean shutdown
|
||||
@ -315,11 +318,18 @@ static int qio_channel_command_close(QIOChannel *ioc,
|
||||
rv = -1;
|
||||
}
|
||||
cioc->writefd = cioc->readfd = -1;
|
||||
|
||||
#ifndef WIN32
|
||||
if (qio_channel_command_abort(cioc, errp) < 0) {
|
||||
do {
|
||||
wp = waitpid(cioc->pid, NULL, 0);
|
||||
} while (wp == (pid_t)-1 && errno == EINTR);
|
||||
if (wp == (pid_t)-1) {
|
||||
error_setg_errno(errp, errno, "Failed to wait for pid %llu",
|
||||
(unsigned long long)cioc->pid);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (rv < 0) {
|
||||
error_setg_errno(errp, errno, "%s",
|
||||
"Unable to close command");
|
||||
|
@ -50,11 +50,7 @@ qio_channel_file_new_path(const char *path,
|
||||
|
||||
ioc = QIO_CHANNEL_FILE(object_new(TYPE_QIO_CHANNEL_FILE));
|
||||
|
||||
if (flags & O_WRONLY) {
|
||||
ioc->fd = open(path, flags, mode);
|
||||
} else {
|
||||
ioc->fd = open(path, flags);
|
||||
}
|
||||
ioc->fd = qemu_open(path, flags, mode);
|
||||
if (ioc->fd < 0) {
|
||||
object_unref(OBJECT(ioc));
|
||||
error_setg_errno(errp, errno,
|
||||
@ -78,7 +74,7 @@ static void qio_channel_file_finalize(Object *obj)
|
||||
{
|
||||
QIOChannelFile *ioc = QIO_CHANNEL_FILE(obj);
|
||||
if (ioc->fd != -1) {
|
||||
close(ioc->fd);
|
||||
qemu_close(ioc->fd);
|
||||
ioc->fd = -1;
|
||||
}
|
||||
}
|
||||
@ -177,11 +173,12 @@ static int qio_channel_file_close(QIOChannel *ioc,
|
||||
{
|
||||
QIOChannelFile *fioc = QIO_CHANNEL_FILE(ioc);
|
||||
|
||||
if (close(fioc->fd) < 0) {
|
||||
if (qemu_close(fioc->fd) < 0) {
|
||||
error_setg_errno(errp, errno,
|
||||
"Unable to close file");
|
||||
return -1;
|
||||
}
|
||||
fioc->fd = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -499,9 +499,12 @@ static int qio_channel_websock_handshake_read(QIOChannelWebsock *ioc,
|
||||
error_setg(errp,
|
||||
"End of headers not found in first 4096 bytes");
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
} else if (ret == 0) {
|
||||
error_setg(errp,
|
||||
"End of headers not found before connection closed");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
*handshake_end = '\0';
|
||||
|
||||
|
@ -234,6 +234,7 @@ QIOChannelSocket *qio_net_listener_wait_client(QIONetListener *listener)
|
||||
for (i = 0; i < listener->nsioc; i++) {
|
||||
g_source_unref(sources[i]);
|
||||
}
|
||||
g_free(sources);
|
||||
g_main_loop_unref(loop);
|
||||
g_main_context_unref(ctxt);
|
||||
|
||||
|
@ -24,16 +24,21 @@
|
||||
#include "io-channel-helpers.h"
|
||||
#include "qapi/error.h"
|
||||
|
||||
static void test_io_channel_file(void)
|
||||
#define TEST_FILE "tests/test-io-channel-file.txt"
|
||||
#define TEST_MASK 0600
|
||||
|
||||
static void test_io_channel_file_helper(int flags)
|
||||
{
|
||||
QIOChannel *src, *dst;
|
||||
QIOChannelTest *test;
|
||||
struct stat st;
|
||||
mode_t mask;
|
||||
int ret;
|
||||
|
||||
#define TEST_FILE "tests/test-io-channel-file.txt"
|
||||
unlink(TEST_FILE);
|
||||
src = QIO_CHANNEL(qio_channel_file_new_path(
|
||||
TEST_FILE,
|
||||
O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0600,
|
||||
flags, TEST_MASK,
|
||||
&error_abort));
|
||||
dst = QIO_CHANNEL(qio_channel_file_new_path(
|
||||
TEST_FILE,
|
||||
@ -45,18 +50,33 @@ static void test_io_channel_file(void)
|
||||
qio_channel_test_run_reader(test, dst);
|
||||
qio_channel_test_validate(test);
|
||||
|
||||
/* Check that the requested mode took effect. */
|
||||
mask = umask(0);
|
||||
umask(mask);
|
||||
ret = stat(TEST_FILE, &st);
|
||||
g_assert_cmpint(ret, >, -1);
|
||||
g_assert_cmpuint(TEST_MASK & ~mask, ==, st.st_mode & 0777);
|
||||
|
||||
unlink(TEST_FILE);
|
||||
object_unref(OBJECT(src));
|
||||
object_unref(OBJECT(dst));
|
||||
}
|
||||
|
||||
static void test_io_channel_file(void)
|
||||
{
|
||||
test_io_channel_file_helper(O_WRONLY | O_CREAT | O_TRUNC | O_BINARY);
|
||||
}
|
||||
|
||||
static void test_io_channel_file_rdwr(void)
|
||||
{
|
||||
test_io_channel_file_helper(O_RDWR | O_CREAT | O_TRUNC | O_BINARY);
|
||||
}
|
||||
|
||||
static void test_io_channel_fd(void)
|
||||
{
|
||||
QIOChannel *ioc;
|
||||
int fd = -1;
|
||||
|
||||
#define TEST_FILE "tests/test-io-channel-file.txt"
|
||||
fd = open(TEST_FILE, O_CREAT | O_TRUNC | O_WRONLY, 0600);
|
||||
g_assert_cmpint(fd, >, -1);
|
||||
|
||||
@ -114,6 +134,7 @@ int main(int argc, char **argv)
|
||||
g_test_init(&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func("/io/channel/file", test_io_channel_file);
|
||||
g_test_add_func("/io/channel/file/rdwr", test_io_channel_file_rdwr);
|
||||
g_test_add_func("/io/channel/file/fd", test_io_channel_fd);
|
||||
#ifndef _WIN32
|
||||
g_test_add_func("/io/channel/pipe/sync", test_io_channel_pipe_sync);
|
||||
|
Loading…
Reference in New Issue
Block a user