[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Nbd] did 'nbd-server -d' accidentally break?



I don't see how it can be reliable:

static void
handle_modern_connection(GArray *const servers, const int sock, struct
generic_conf *genconf)
{
...
	int commsocket;
...
        if (!dontfork) {
                pid = spawn_child(&commsocket);
...
	}
...
        client = negotiate(net, servers, genconf);
        if (!client) {
                msg(LOG_ERR, "Modern initial negotiation failed");
                goto handler_err;
        }
	len = strlen(client->server->servename);
	writeit(commsocket, &len, sizeof len);
	writeit(commsocket, client->server->servename, len);
	readit(commsocket, &acl, 1);
	close(commsocket);

Since -d turns dontfork on, it means commsocket is uninitialized(!). If
you're lucky, it starts life as 0, and if you are in an interactive
environment (where stdin happens to be a tty), then the output goes
somewhere rather than causing an error, and then you have to type
something other than N or X to get the readit() to succeed.

Looks like commit 7e901617 is the culprit, and maybe the solution is to
just skip the commsocket stuff when -d is active (should -d also imply
maxconnections of 1?).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: