On 08/01/2016 17:24, Daniel P. Berrange wrote: >> > if (nbd_send_negotiate(client)) { >> > + shutdown(csock, 2); >> > + close(csock); >> > g_free(client); >> > - return NULL; >> > + ret = -1; >> > + goto out; > If you simply make this failure code branch call close_fn() then I > think you can adding needing the new NBDClientNewCB entirely if....
Good idea, but note that close_fn will call nbd_client_put, so the close/g_free must be removed. It's probably cleanest to change csock to client->sock in the shutdown call, too. Paolo