summaryrefslogtreecommitdiff
path: root/src/node_crypto_bio.cc
diff options
context:
space:
mode:
authorFedor Indutny <fedor.indutny@gmail.com>2013-11-28 02:49:30 +0400
committerFedor Indutny <fedor.indutny@gmail.com>2013-12-07 03:47:57 +0400
commit03747f69fba646dc9902519c1736d5f4f267ef7b (patch)
tree8f77bcc99ae036a4574926dbf63cdbe418499c6c /src/node_crypto_bio.cc
parentf5ab3e4c5cd37b76d60f657190b315183dbefeba (diff)
downloadandroid-node-v8-03747f69fba646dc9902519c1736d5f4f267ef7b.tar.gz
android-node-v8-03747f69fba646dc9902519c1736d5f4f267ef7b.tar.bz2
android-node-v8-03747f69fba646dc9902519c1736d5f4f267ef7b.zip
tls_wrap: use writev when possible
Try writing multiple chunks from NodeBIO if possible.
Diffstat (limited to 'src/node_crypto_bio.cc')
-rw-r--r--src/node_crypto_bio.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/node_crypto_bio.cc b/src/node_crypto_bio.cc
index 05a4b5f48f..84dc42b464 100644
--- a/src/node_crypto_bio.cc
+++ b/src/node_crypto_bio.cc
@@ -96,6 +96,33 @@ char* NodeBIO::Peek(size_t* size) {
}
+size_t NodeBIO::PeekMultiple(char** out, size_t* size, size_t* count) {
+ Buffer* pos = read_head_;
+ size_t max = *count;
+ size_t total = 0;
+
+ size_t i;
+ for (i = 0; i < max; i++) {
+ size[i] = pos->write_pos_ - pos->read_pos_;
+ total += size[i];
+ out[i] = pos->data_ + pos->read_pos_;
+
+ /* Don't get past write head */
+ if (pos == write_head_)
+ break;
+ else
+ pos = pos->next_;
+ }
+
+ if (i == max)
+ *count = i;
+ else
+ *count = i + 1;
+
+ return total;
+}
+
+
int NodeBIO::Write(BIO* bio, const char* data, int len) {
BIO_clear_retry_flags(bio);