Skip to content

Commit

Permalink
util: remove the obsolete non-blocking connect
Browse files Browse the repository at this point in the history
The non-blocking connect mechanism is obsolete, and it doesn't
work well in inet connection, because it will call getaddrinfo
first and getaddrinfo will blocks on DNS lookups. Since commit
e65c67e & d984464, the non-blocking connect of migration goes
through QIOChannel in a different manner(using a thread), and
nobody use this old non-blocking connect anymore.

Any newly written code which needs a non-blocking connect should
use the QIOChannel code, so we can drop NonBlockingConnectHandler
as a concept entirely.

Suggested-by: Daniel P. Berrange <[email protected]>
Signed-off-by: Cao jin <[email protected]>
Signed-off-by: Mao Zhongyi <[email protected]>
Reviewed-by: Juan Quintela <[email protected]>
Signed-off-by: Daniel P. Berrange <[email protected]>
  • Loading branch information
Cao jin authored and berrange committed Sep 5, 2017
1 parent d4adf96 commit b258793
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 195 deletions.
2 changes: 1 addition & 1 deletion block/sheepdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ static int connect_to_sdog(BDRVSheepdogState *s, Error **errp)
{
int fd;

fd = socket_connect(s->addr, NULL, NULL, errp);
fd = socket_connect(s->addr, errp);

if (s->addr->type == SOCKET_ADDRESS_TYPE_INET && fd >= 0) {
int ret = socket_set_nodelay(fd);
Expand Down
2 changes: 1 addition & 1 deletion block/ssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ static int connect_to_ssh(BDRVSSHState *s, QDict *options,
}

/* Open the socket and connect. */
s->sock = inet_connect_saddr(s->inet, NULL, NULL, errp);
s->sock = inet_connect_saddr(s->inet, errp);
if (s->sock < 0) {
ret = -EIO;
goto err;
Expand Down
12 changes: 2 additions & 10 deletions include/qemu/sockets.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,19 @@ int socket_set_fast_reuse(int fd);
#define SHUT_RDWR 2
#endif

/* callback function for nonblocking connect
* valid fd on success, negative error code on failure
*/
typedef void NonBlockingConnectHandler(int fd, Error *err, void *opaque);

int inet_ai_family_from_address(InetSocketAddress *addr,
Error **errp);
int inet_parse(InetSocketAddress *addr, const char *str, Error **errp);
int inet_connect(const char *str, Error **errp);
int inet_connect_saddr(InetSocketAddress *saddr,
NonBlockingConnectHandler *callback, void *opaque,
Error **errp);
int inet_connect_saddr(InetSocketAddress *saddr, Error **errp);

NetworkAddressFamily inet_netfamily(int family);

int unix_listen(const char *path, char *ostr, int olen, Error **errp);
int unix_connect(const char *path, Error **errp);

SocketAddress *socket_parse(const char *str, Error **errp);
int socket_connect(SocketAddress *addr, NonBlockingConnectHandler *callback,
void *opaque, Error **errp);
int socket_connect(SocketAddress *addr, Error **errp);
int socket_listen(SocketAddress *addr, Error **errp);
void socket_listen_cleanup(int fd, Error **errp);
int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp);
Expand Down
2 changes: 1 addition & 1 deletion io/channel-socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ int qio_channel_socket_connect_sync(QIOChannelSocket *ioc,
int fd;

trace_qio_channel_socket_connect_sync(ioc, addr);
fd = socket_connect(addr, NULL, NULL, errp);
fd = socket_connect(addr, errp);
if (fd < 0) {
trace_qio_channel_socket_connect_fail(ioc);
return -1;
Expand Down
Loading

0 comments on commit b258793

Please sign in to comment.