aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2014-05-22 18:14:01 +0100
committerPeter Maydell <peter.maydell@linaro.org>2014-05-22 18:14:01 +0100
commit6054d883d6138bfc92c73a7c090c824b64086fd2 (patch)
tree3ac0d7a468e313793ebd94a1d4002621b3c61fa8 /util
parent5118dc5975e6aa2e823961e15b162919f94721cc (diff)
parentd2e064a73ee7e5af244ff7b6406ac2344bbaa231 (diff)
downloadqemu-6054d883d6138bfc92c73a7c090c824b64086fd2.zip
qemu-6054d883d6138bfc92c73a7c090c824b64086fd2.tar.gz
qemu-6054d883d6138bfc92c73a7c090c824b64086fd2.tar.bz2
Merge remote-tracking branch 'remotes/kraxel/tags/pull-chardev-2' into staging
purge error_is_set() # gpg: Signature made Wed 21 May 2014 11:43:44 BST using RSA key ID D3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" # gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" # gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" * remotes/kraxel/tags/pull-chardev-2: error: error_is_set() is finally unused; remove char: Explain qmp_chardev_add()'s unusual error handling char: Clean up fragile use of error_is_set() char: Use return values instead of error_is_set(errp) qemu-socket: Clean up inet_connect_opts() Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'util')
-rw-r--r--util/error.c5
-rw-r--r--util/qemu-sockets.c28
2 files changed, 16 insertions, 17 deletions
diff --git a/util/error.c b/util/error.c
index 66245cc..2ace0d8 100644
--- a/util/error.c
+++ b/util/error.c
@@ -142,11 +142,6 @@ Error *error_copy(const Error *err)
return err_new;
}
-bool error_is_set(Error **errp)
-{
- return (errp && *errp);
-}
-
ErrorClass error_get_class(const Error *err)
{
return err->err_class;
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 8818d7c..627e609 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -354,6 +354,7 @@ static struct addrinfo *inet_parse_connect_opts(QemuOpts *opts, Error **errp)
int inet_connect_opts(QemuOpts *opts, Error **errp,
NonBlockingConnectHandler *callback, void *opaque)
{
+ Error *local_err = NULL;
struct addrinfo *res, *e;
int sock = -1;
bool in_progress;
@@ -372,24 +373,27 @@ int inet_connect_opts(QemuOpts *opts, Error **errp,
}
for (e = res; e != NULL; e = e->ai_next) {
- if (error_is_set(errp)) {
- error_free(*errp);
- *errp = NULL;
- }
+ error_free(local_err);
+ local_err = NULL;
if (connect_state != NULL) {
connect_state->current_addr = e;
}
- sock = inet_connect_addr(e, &in_progress, connect_state, errp);
- if (in_progress) {
- return sock;
- } else if (sock >= 0) {
- /* non blocking socket immediate success, call callback */
- if (callback != NULL) {
- callback(sock, opaque);
- }
+ sock = inet_connect_addr(e, &in_progress, connect_state, &local_err);
+ if (sock >= 0) {
break;
}
}
+
+ if (sock < 0) {
+ error_propagate(errp, local_err);
+ } else if (in_progress) {
+ /* wait_for_connect() will do the rest */
+ return sock;
+ } else {
+ if (callback) {
+ callback(sock, opaque);
+ }
+ }
g_free(connect_state);
freeaddrinfo(res);
return sock;