diff options
author | Matt Johnston <matt@ucc.asn.au> | 2015-03-20 22:53:32 +0800 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2015-03-20 22:53:32 +0800 |
commit | 20f9683ae050092a1f028ae55c546966c4882925 (patch) | |
tree | dbec8f8e56a0bc4ee4e15b031a2ba8e2e101ab07 /packet.c | |
parent | dce384668bb8e684c0e83f03a7ff4b30cfc6fe4b (diff) |
avoid malloc for iovec
Diffstat (limited to 'packet.c')
-rw-r--r-- | packet.c | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -58,8 +58,9 @@ void write_packet() { ssize_t written; #ifdef HAVE_WRITEV - struct iovec *iov = NULL; - int iov_count; + /* 50 is somewhat arbitrary */ + int iov_count = 50; + struct iovec iov[50]; #endif TRACE2(("enter write_packet")) @@ -67,7 +68,7 @@ void write_packet() { #if defined(HAVE_WRITEV) && (defined(IOV_MAX) || defined(UIO_MAXIOV)) - iov = packet_queue_to_iovec(&ses.writequeue, &iov_count); + packet_queue_to_iovec(&ses.writequeue, iov, &iov_count); /* This may return EAGAIN. The main loop sometimes calls write_packet() without bothering to test with select() since it's likely to be necessary */ @@ -75,13 +76,11 @@ void write_packet() { if (written < 0) { if (errno == EINTR || errno == EAGAIN) { TRACE2(("leave write_packet: EINTR")) - m_free(iov); return; } else { dropbear_exit("Error writing: %s", strerror(errno)); } } - m_free(iov); packet_queue_consume(&ses.writequeue, written); |