mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-09 05:33:58 -04:00
Merge branch 'client-sendall'
This commit is contained in:
commit
2398af7b47
1 changed files with 28 additions and 7 deletions
35
client.c
35
client.c
|
|
@ -39,6 +39,27 @@ sig_handler(int signo)
|
||||||
aborted = 1;
|
aborted = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ssize_t
|
||||||
|
sendall(int sock, const void *_buf, size_t len)
|
||||||
|
{
|
||||||
|
const uint8_t *buf = _buf;
|
||||||
|
size_t left = len;
|
||||||
|
|
||||||
|
while (left > 0) {
|
||||||
|
ssize_t r = send(sock, buf, left, MSG_NOSIGNAL);
|
||||||
|
if (r < 0) {
|
||||||
|
if (errno == EINTR)
|
||||||
|
continue;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf += r;
|
||||||
|
left -= r;
|
||||||
|
}
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
version_and_features(void)
|
version_and_features(void)
|
||||||
{
|
{
|
||||||
|
|
@ -385,9 +406,9 @@ main(int argc, char *const *argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send everything except argv[] */
|
/* Send everything except argv[] */
|
||||||
if (send(fd, &(uint32_t){total_len}, sizeof(uint32_t), 0) != sizeof(uint32_t) ||
|
if (sendall(fd, &(uint32_t){total_len}, sizeof(uint32_t)) < 0 ||
|
||||||
send(fd, &data, sizeof(data), 0) != sizeof(data) ||
|
sendall(fd, &data, sizeof(data)) < 0 ||
|
||||||
send(fd, cwd, cwd_len, 0) != cwd_len)
|
sendall(fd, cwd, cwd_len) < 0)
|
||||||
{
|
{
|
||||||
LOG_ERRNO("failed to send setup packet to server");
|
LOG_ERRNO("failed to send setup packet to server");
|
||||||
goto err;
|
goto err;
|
||||||
|
|
@ -397,8 +418,8 @@ main(int argc, char *const *argv)
|
||||||
tll_foreach(overrides, it) {
|
tll_foreach(overrides, it) {
|
||||||
const struct override *o = &it->item;
|
const struct override *o = &it->item;
|
||||||
struct client_string s = {o->len};
|
struct client_string s = {o->len};
|
||||||
if (send(fd, &s, sizeof(s), 0) != sizeof(s) ||
|
if (sendall(fd, &s, sizeof(s)) < 0 ||
|
||||||
send(fd, o->str, o->len, 0) != o->len)
|
sendall(fd, o->str, o->len) < 0)
|
||||||
{
|
{
|
||||||
LOG_ERRNO("failed to send setup packet (overrides) to server");
|
LOG_ERRNO("failed to send setup packet (overrides) to server");
|
||||||
goto err;
|
goto err;
|
||||||
|
|
@ -407,8 +428,8 @@ main(int argc, char *const *argv)
|
||||||
|
|
||||||
/* Send argv[] */
|
/* Send argv[] */
|
||||||
for (size_t i = 0; i < argc; i++) {
|
for (size_t i = 0; i < argc; i++) {
|
||||||
if (send(fd, &cargv[i], sizeof(cargv[i]), 0) != sizeof(cargv[i]) ||
|
if (sendall(fd, &cargv[i], sizeof(cargv[i])) < 0 ||
|
||||||
send(fd, argv[i], cargv[i].len, 0) != cargv[i].len)
|
sendall(fd, argv[i], cargv[i].len) < 0)
|
||||||
{
|
{
|
||||||
LOG_ERRNO("failed to send setup packet (argv) to server");
|
LOG_ERRNO("failed to send setup packet (argv) to server");
|
||||||
goto err;
|
goto err;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue