+ if (rpc_get_fd(rpc) == -1) {
+ rpc_set_error(rpc, "Socket closed\n");
+ break;
+ }
+ }
+}
+
+static void wait_for_nfs_reply(struct nfs_context *nfs, struct sync_cb_data *cb_data)
+{
+ struct pollfd pfd;
+
+ while (!cb_data->is_finished) {
+
+ pfd.fd = nfs_get_fd(nfs);
+ pfd.events = nfs_which_events(nfs);
+ if (poll(&pfd, 1, -1) < 0) {
+ nfs_set_error(nfs, "Poll failed");
+ cb_data->status = -EIO;
+ break;
+ }
+ if (nfs_service(nfs, pfd.revents) < 0) {
+ nfs_set_error(nfs, "nfs_service failed");
+ cb_data->status = -EIO;
+ break;
+ }
+ if (nfs_get_fd(nfs) == -1) {
+ char *server = strdup(nfs_get_server(nfs));
+ char *export = strdup(nfs_get_export(nfs));
+
+ if (nfs_mount(nfs, server, export) != 0) {
+ nfs_set_error(nfs, "Failed to reconnect to nfs server %s", nfs_get_error(nfs));
+ free(server);
+ free(export);
+ break;
+ }
+ free(server);
+ free(export);
+ }