View | Details | Raw Unified | Return to bug 1354 | Differences between
and this patch

Collapse All | Expand All

(-)sftp-client.c.drain-acks (-18 / +11 lines)
Lines 992-998 int Link Here
992
do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
992
do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
993
    int pflag)
993
    int pflag)
994
{
994
{
995
	int local_fd, status;
995
	int local_fd;
996
	int status = SSH2_FX_OK;
996
	u_int handle_len, id, type;
997
	u_int handle_len, id, type;
997
	u_int64_t offset;
998
	u_int64_t offset;
998
	char *handle, *data;
999
	char *handle, *data;
Lines 1074-1080 do_upload(struct sftp_conn *conn, char * Link Here
1074
		 * Simulate an EOF on interrupt, allowing ACKs from the
1075
		 * Simulate an EOF on interrupt, allowing ACKs from the
1075
		 * server to drain.
1076
		 * server to drain.
1076
		 */
1077
		 */
1077
		if (interrupted)
1078
		if (interrupted || status != SSH2_FX_OK)
1078
			len = 0;
1079
			len = 0;
1079
		else do
1080
		else do
1080
			len = read(local_fd, data, conn->transfer_buflen);
1081
			len = read(local_fd, data, conn->transfer_buflen);
Lines 1131-1148 do_upload(struct sftp_conn *conn, char * Link Here
1131
				fatal("Can't find request for ID %u", r_id);
1132
				fatal("Can't find request for ID %u", r_id);
1132
			TAILQ_REMOVE(&acks, ack, tq);
1133
			TAILQ_REMOVE(&acks, ack, tq);
1133
1134
1134
			if (status != SSH2_FX_OK) {
1135
				error("Couldn't write to remote file \"%s\": %s",
1136
				    remote_path, fx2txt(status));
1137
				if (showprogress)
1138
					stop_progress_meter();
1139
				do_close(conn, handle, handle_len);
1140
				close(local_fd);
1141
				xfree(data);
1142
				xfree(ack);
1143
				status = -1;
1144
				goto done;
1145
			}
1146
			debug3("In write loop, ack for %u %u bytes at %llu",
1135
			debug3("In write loop, ack for %u %u bytes at %llu",
1147
			    ack->id, ack->len, (unsigned long long)ack->offset);
1136
			    ack->id, ack->len, (unsigned long long)ack->offset);
1148
			++ackid;
1137
			++ackid;
Lines 1154-1174 do_upload(struct sftp_conn *conn, char * Link Here
1154
		stop_progress_meter();
1143
		stop_progress_meter();
1155
	xfree(data);
1144
	xfree(data);
1156
1145
1146
	if (status != SSH2_FX_OK) {
1147
		error("Couldn't write to remote file \"%s\": %s",
1148
		    remote_path, fx2txt(status));
1149
		status = -1;
1150
	}
1151
1157
	if (close(local_fd) == -1) {
1152
	if (close(local_fd) == -1) {
1158
		error("Couldn't close local file \"%s\": %s", local_path,
1153
		error("Couldn't close local file \"%s\": %s", local_path,
1159
		    strerror(errno));
1154
		    strerror(errno));
1160
		do_close(conn, handle, handle_len);
1161
		status = -1;
1155
		status = -1;
1162
		goto done;
1163
	}
1156
	}
1164
1157
1165
	/* Override umask and utimes if asked */
1158
	/* Override umask and utimes if asked */
1166
	if (pflag)
1159
	if (pflag)
1167
		do_fsetstat(conn, handle, handle_len, &a);
1160
		do_fsetstat(conn, handle, handle_len, &a);
1168
1161
1169
	status = do_close(conn, handle, handle_len);
1162
	if (do_close(conn, handle, handle_len) != SSH2_FX_OK)
1163
		status = -1;
1170
1164
1171
done:
1172
	xfree(handle);
1165
	xfree(handle);
1173
	buffer_free(&msg);
1166
	buffer_free(&msg);
1174
	return(status);
1167
	return(status);

Return to bug 1354