Skip to content

Commit 03f365c

Browse files
committed
Merge branch 'jc/no-writev-does-not-work' into jch
* jc/no-writev-does-not-work: Revert "compat/posix: introduce writev(3p) wrapper" Revert "wrapper: introduce writev(3p) wrappers" Revert "sideband: use writev(3p) to send pktlines" Revert "cmake: use writev(3p) wrapper as needed"
2 parents 3d6167f + bfedc73 commit 03f365c

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
@@ -2030,10 +2030,6 @@ ifdef NO_PREAD
20302030
COMPAT_CFLAGS += -DNO_PREAD
20312031
COMPAT_OBJS += compat/pread.o
20322032
endif
2033-
ifdef NO_WRITEV
2034-
COMPAT_CFLAGS += -DNO_WRITEV
2035-
COMPAT_OBJS += compat/writev.o
2036-
endif
20372033
ifdef NO_FAST_WORKING_DIRECTORY
20382034
BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY
20392035
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
@@ -1430,7 +1430,6 @@ checkfuncs = {
14301430
'initgroups' : [],
14311431
'strtoumax' : ['strtoumax.c', 'strtoimax.c'],
14321432
'pread' : ['pread.c'],
1433-
'writev' : ['writev.c'],
14341433
}
14351434

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

sideband.c

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

441441
while (sz) {
442-
struct iovec iov[2];
443442
unsigned n;
444443
char hdr[5];
445444

@@ -449,19 +448,12 @@ void send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_ma
449448
if (0 <= band) {
450449
xsnprintf(hdr, sizeof(hdr), "%04x", n + 5);
451450
hdr[4] = band;
452-
iov[0].iov_base = hdr;
453-
iov[0].iov_len = 5;
451+
write_or_die(fd, hdr, 5);
454452
} else {
455453
xsnprintf(hdr, sizeof(hdr), "%04x", n + 4);
456-
iov[0].iov_base = hdr;
457-
iov[0].iov_len = 4;
454+
write_or_die(fd, hdr, 4);
458455
}
459-
460-
iov[1].iov_base = (void *) p;
461-
iov[1].iov_len = n;
462-
463-
writev_or_die(fd, iov, ARRAY_SIZE(iov));
464-
456+
write_or_die(fd, p, n);
465457
p += n;
466458
sz -= n;
467459
}

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)