From: Andre Noll Date: Sun, 11 Dec 2011 19:27:27 +0000 (+0100) Subject: sc_send_bin_buffer: Use write_nonblock() rather than write_all(). X-Git-Tag: v0.4.10~11^2~5 X-Git-Url: http://git.tuebingen.mpg.de/?a=commitdiff_plain;h=6934fc28976594d0eb387bfef25cb938c677814c;hp=2e2f91c92bbdd4107925bcaf521242c588afbfe4;p=paraslash.git sc_send_bin_buffer: Use write_nonblock() rather than write_all(). The write_nonblock() variant is safer here as it allows to let the callers deal with short writes. Despite the name, write_nonblock() can be used for both blocking and non-blocking fds. It will be renamed in a subsequent patch. --- diff --git a/crypt.c b/crypt.c index 7161e626..85ec091d 100644 --- a/crypt.c +++ b/crypt.c @@ -298,7 +298,7 @@ int sc_send_bin_buffer(struct stream_cipher_context *scc, char *buf, memcpy(remainder, buf + l1, len - l1); RC4(&scc->send->key, len - l1, remainder, tmp + l1); } - ret = write_all(scc->fd, (char *)tmp, len); + ret = write_nonblock(scc->fd, (char *)tmp, len); free(tmp); return ret; } diff --git a/gcrypt.c b/gcrypt.c index 467e7399..1ce4587f 100644 --- a/gcrypt.c +++ b/gcrypt.c @@ -951,7 +951,7 @@ int sc_send_bin_buffer(struct stream_cipher_context *scc, char *buf, gret = gcry_cipher_encrypt(scc->send->handle, tmp, size, (unsigned char *)buf, size); assert(gret == 0); - ret = write_all(scc->fd, (char *)tmp, size); + ret = write_nonblock(scc->fd, (char *)tmp, size); free(tmp); return ret; }