socket: Add num connections to qio_net_listener_open_sync()

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
Juan Quintela 2019-08-19 18:08:21 +02:00
parent 7959e29ea0
commit fc8135c630
7 changed files with 10 additions and 7 deletions

View File

@ -101,7 +101,7 @@ void nbd_server_start(SocketAddress *addr, const char *tls_creds,
qio_net_listener_set_name(nbd_server->listener,
"nbd-listener");
if (qio_net_listener_open_sync(nbd_server->listener, addr, errp) < 0) {
if (qio_net_listener_open_sync(nbd_server->listener, addr, 1, errp) < 0) {
goto error;
}

View File

@ -1170,7 +1170,7 @@ static int qmp_chardev_open_socket_server(Chardev *chr,
qio_net_listener_set_name(s->listener, name);
g_free(name);
if (qio_net_listener_open_sync(s->listener, s->addr, errp) < 0) {
if (qio_net_listener_open_sync(s->listener, s->addr, 1, errp) < 0) {
object_unref(OBJECT(s->listener));
s->listener = NULL;
return -1;

View File

@ -95,6 +95,7 @@ void qio_net_listener_set_name(QIONetListener *listener,
* qio_net_listener_open_sync:
* @listener: the network listener object
* @addr: the address to listen on
* @num: the amount of expected connections
* @errp: pointer to a NULL initialized error object
*
* Synchronously open a listening connection on all
@ -104,6 +105,7 @@ void qio_net_listener_set_name(QIONetListener *listener,
*/
int qio_net_listener_open_sync(QIONetListener *listener,
SocketAddress *addr,
int num,
Error **errp);
/**

View File

@ -62,6 +62,7 @@ static gboolean qio_net_listener_channel_func(QIOChannel *ioc,
int qio_net_listener_open_sync(QIONetListener *listener,
SocketAddress *addr,
int num,
Error **errp)
{
QIODNSResolver *resolver = qio_dns_resolver_get_instance();
@ -82,7 +83,7 @@ int qio_net_listener_open_sync(QIONetListener *listener,
for (i = 0; i < nresaddrs; i++) {
QIOChannelSocket *sioc = qio_channel_socket_new();
if (qio_channel_socket_listen_sync(sioc, resaddrs[i], 1,
if (qio_channel_socket_listen_sync(sioc, resaddrs[i], num,
err ? NULL : &err) == 0) {
success = true;

View File

@ -181,7 +181,7 @@ static void socket_start_incoming_migration(SocketAddress *saddr,
qio_net_listener_set_name(listener, "migration-socket-listener");
if (qio_net_listener_open_sync(listener, saddr, errp) < 0) {
if (qio_net_listener_open_sync(listener, saddr, 1, errp) < 0) {
object_unref(OBJECT(listener));
return;
}

View File

@ -1054,7 +1054,7 @@ int main(int argc, char **argv)
server = qio_net_listener_new();
if (socket_activation == 0) {
saddr = nbd_build_socket_address(sockpath, bindto, port);
if (qio_net_listener_open_sync(server, saddr, &local_err) < 0) {
if (qio_net_listener_open_sync(server, saddr, 1, &local_err) < 0) {
object_unref(OBJECT(server));
error_report_err(local_err);
exit(EXIT_FAILURE);

View File

@ -3765,7 +3765,7 @@ static int vnc_display_listen(VncDisplay *vd,
qio_net_listener_set_name(vd->listener, "vnc-listen");
for (i = 0; i < nsaddr; i++) {
if (qio_net_listener_open_sync(vd->listener,
saddr[i],
saddr[i], 1,
errp) < 0) {
return -1;
}
@ -3780,7 +3780,7 @@ static int vnc_display_listen(VncDisplay *vd,
qio_net_listener_set_name(vd->wslistener, "vnc-ws-listen");
for (i = 0; i < nwsaddr; i++) {
if (qio_net_listener_open_sync(vd->wslistener,
wsaddr[i],
wsaddr[i], 1,
errp) < 0) {
return -1;
}