Skip to content

Commit bfedc73

Browse files
committed
writev: retract the topic until we have a better emulation
The emulation layer we added for writev(3p) tries to be too faithful to the spec that on systems with SSIZE_MAX set to lower than 64kB to fit a single sideband packet would fail just like the real system writev(), which makes our use of writev() for sideband messages unworkable. Let's revert them and reboot the effort after the release. The reverted commits are: $ git log -Swritev --oneline 8023abc^..v2.52.0-rc1 89152af cmake: use writev(3p) wrapper as needed 26986f4 sideband: use writev(3p) to send pktlines 1970fce wrapper: introduce writev(3p) wrappers 3b9b2c2 compat/posix: introduce writev(3p) wrapper 8023abc is the merge of ps/upload-pack-buffer-more-writes topic to the mainline. Helped-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 parents 60f07c4 + 7798034 commit bfedc73

File tree

11 files changed

+4
-140
lines changed

11 files changed

+4
-140
lines changed

Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,10 +2029,6 @@ ifdef NO_PREAD
20292029
COMPAT_CFLAGS += -DNO_PREAD
20302030
COMPAT_OBJS += compat/pread.o
20312031
endif
2032-
ifdef NO_WRITEV
2033-
COMPAT_CFLAGS += -DNO_WRITEV
2034-
COMPAT_OBJS += compat/writev.o
2035-
endif
20362032
ifdef NO_FAST_WORKING_DIRECTORY
20372033
BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY
20382034
endif

compat/posix.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,6 @@
137137
#include <sys/socket.h>
138138
#include <sys/ioctl.h>
139139
#include <sys/statvfs.h>
140-
#ifndef NO_WRITEV
141-
#include <sys/uio.h>
142-
#endif
143140
#include <termios.h>
144141
#ifndef NO_SYS_SELECT_H
145142
#include <sys/select.h>
@@ -326,17 +323,6 @@ int git_lstat(const char *, struct stat *);
326323
ssize_t git_pread(int fd, void *buf, size_t count, off_t offset);
327324
#endif
328325

329-
#ifdef NO_WRITEV
330-
#define writev git_writev
331-
#define iovec git_iovec
332-
struct git_iovec {
333-
void *iov_base;
334-
size_t iov_len;
335-
};
336-
337-
ssize_t git_writev(int fd, const struct iovec *iov, int iovcnt);
338-
#endif
339-
340326
#ifdef NO_SETENV
341327
#define setenv gitsetenv
342328
int gitsetenv(const char *, const char *, int);

compat/writev.c

Lines changed: 0 additions & 44 deletions
This file was deleted.

config.mak.uname

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,6 @@ ifeq ($(uname_S),Windows)
459459
SANE_TOOL_PATH ?= $(msvc_bin_dir_msys)
460460
HAVE_ALLOCA_H = YesPlease
461461
NO_PREAD = YesPlease
462-
NO_WRITEV = YesPlease
463462
NEEDS_CRYPTO_WITH_SSL = YesPlease
464463
NO_LIBGEN_H = YesPlease
465464
NO_POLL = YesPlease
@@ -675,7 +674,6 @@ ifeq ($(uname_S),MINGW)
675674
pathsep = ;
676675
HAVE_ALLOCA_H = YesPlease
677676
NO_PREAD = YesPlease
678-
NO_WRITEV = YesPlease
679677
NEEDS_CRYPTO_WITH_SSL = YesPlease
680678
NO_LIBGEN_H = YesPlease
681679
NO_POLL = YesPlease

contrib/buildsystems/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ endif()
376376
#function checks
377377
set(function_checks
378378
strcasestr memmem strlcpy strtoimax strtoumax strtoull
379-
setenv mkdtemp poll pread memmem writev)
379+
setenv mkdtemp poll pread memmem)
380380

381381
#unsetenv,hstrerror are incompatible with windows build
382382
if(NOT WIN32)
@@ -421,10 +421,6 @@ if(NOT HAVE_MEMMEM)
421421
list(APPEND compat_SOURCES compat/memmem.c)
422422
endif()
423423

424-
if(NOT HAVE_WRITEV)
425-
list(APPEND compat_SOURCES compat/writev.c)
426-
endif()
427-
428424
if(NOT WIN32)
429425
if(NOT HAVE_UNSETENV)
430426
list(APPEND compat_SOURCES compat/unsetenv.c)

meson.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,6 @@ checkfuncs = {
14291429
'initgroups' : [],
14301430
'strtoumax' : ['strtoumax.c', 'strtoimax.c'],
14311431
'pread' : ['pread.c'],
1432-
'writev' : ['writev.c'],
14331432
}
14341433

14351434
if host_machine.system() == 'windows'

sideband.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ void send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_ma
264264
const char *p = data;
265265

266266
while (sz) {
267-
struct iovec iov[2];
268267
unsigned n;
269268
char hdr[5];
270269

@@ -274,19 +273,12 @@ void send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_ma
274273
if (0 <= band) {
275274
xsnprintf(hdr, sizeof(hdr), "%04x", n + 5);
276275
hdr[4] = band;
277-
iov[0].iov_base = hdr;
278-
iov[0].iov_len = 5;
276+
write_or_die(fd, hdr, 5);
279277
} else {
280278
xsnprintf(hdr, sizeof(hdr), "%04x", n + 4);
281-
iov[0].iov_base = hdr;
282-
iov[0].iov_len = 4;
279+
write_or_die(fd, hdr, 4);
283280
}
284-
285-
iov[1].iov_base = (void *) p;
286-
iov[1].iov_len = n;
287-
288-
writev_or_die(fd, iov, ARRAY_SIZE(iov));
289-
281+
write_or_die(fd, p, n);
290282
p += n;
291283
sz -= n;
292284
}

wrapper.c

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -323,47 +323,6 @@ ssize_t write_in_full(int fd, const void *buf, size_t count)
323323
return total;
324324
}
325325

326-
ssize_t writev_in_full(int fd, struct iovec *iov, int iovcnt)
327-
{
328-
ssize_t total_written = 0;
329-
330-
while (iovcnt) {
331-
ssize_t bytes_written = writev(fd, iov, iovcnt);
332-
if (bytes_written < 0) {
333-
if (errno == EINTR || errno == EAGAIN)
334-
continue;
335-
return -1;
336-
}
337-
if (!bytes_written) {
338-
errno = ENOSPC;
339-
return -1;
340-
}
341-
342-
total_written += bytes_written;
343-
344-
/*
345-
* We first need to discard any iovec entities that have been
346-
* fully written.
347-
*/
348-
while (iovcnt && (size_t)bytes_written >= iov->iov_len) {
349-
bytes_written -= iov->iov_len;
350-
iov++;
351-
iovcnt--;
352-
}
353-
354-
/*
355-
* Finally, we need to adjust the last iovec in case we have
356-
* performed a partial write.
357-
*/
358-
if (iovcnt && bytes_written) {
359-
iov->iov_base = (char *) iov->iov_base + bytes_written;
360-
iov->iov_len -= bytes_written;
361-
}
362-
}
363-
364-
return total_written;
365-
}
366-
367326
ssize_t pread_in_full(int fd, void *buf, size_t count, off_t offset)
368327
{
369328
char *p = buf;

wrapper.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,6 @@ ssize_t read_in_full(int fd, void *buf, size_t count);
4747
ssize_t write_in_full(int fd, const void *buf, size_t count);
4848
ssize_t pread_in_full(int fd, void *buf, size_t count, off_t offset);
4949

50-
/*
51-
* Try to write all iovecs. Returns -1 in case an error occurred with a proper
52-
* errno set, the number of bytes written otherwise.
53-
*
54-
* Note that the iovec will be modified as a result of this call to adjust for
55-
* partial writes!
56-
*/
57-
ssize_t writev_in_full(int fd, struct iovec *iov, int iovcnt);
58-
5950
static inline ssize_t write_str_in_full(int fd, const char *str)
6051
{
6152
return write_in_full(fd, str, strlen(str));

write-or-die.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,6 @@ void write_or_die(int fd, const void *buf, size_t count)
9696
}
9797
}
9898

99-
void writev_or_die(int fd, struct iovec *iov, int iovlen)
100-
{
101-
if (writev_in_full(fd, iov, iovlen) < 0) {
102-
check_pipe(errno);
103-
die_errno("writev error");
104-
}
105-
}
106-
10799
void fwrite_or_die(FILE *f, const void *buf, size_t count)
108100
{
109101
if (fwrite(buf, 1, count, f) != count)

0 commit comments

Comments
 (0)