diff --git a/README.md b/README.md index d241ad2..b0d8f86 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,7 @@ Funnels file descriptor in readable stream into event loop and thence executes a - **nbytes** (int|null) - The number of bytes to read. > Specifying `null` will condition the use of a 1KB buffer. - **vcount** (int|null) - The number of read vectors to use. - > Specifying `null` will condition the use of 2 vectors. + > Specifying `null` will condition the use of `1` vector. > Any value north of `8` will likely result in an inefficient read. - **offset** (int|null) - The point at which to start the read operation. > Specifying `null` will condition the use of an offset of `0`. @@ -214,7 +214,7 @@ Funnels file descriptor in writable stream into event loop and thence executes a > The file descriptor in the stream is internally given a non-blocking disposition. - **contents** (string) - The contents to write to the file descriptor. - **vcount** (int|null) - The number of write vectors to use. - > Specifying `null` will condition the use of 2 vectors. + > Specifying `null` will condition the use of `1` vector. > Any value north of `8` will likely result in an inefficient write. - **callback** (callable) - The unary function through which the number of written bytes is propagated. diff --git a/src/loop.c b/src/loop.c index 775fb8f..e9b6d8f 100644 --- a/src/loop.c +++ b/src/loop.c @@ -261,7 +261,7 @@ static void *php_mrloop_tcp_client_setup(int fd, char **buffer, int *bsize) conn = emalloc(sizeof(php_mrloop_conn_t)); conn->fd = fd; - conn->buffer = emalloc(MRLOOP_G(tcp_buff_size)); + conn->buffer = ecalloc(1, MRLOOP_G(tcp_buff_size)); *buffer = conn->buffer; *bsize = MRLOOP_G(tcp_buff_size); @@ -587,7 +587,7 @@ static void php_mrloop_add_read_stream(INTERNAL_FUNCTION_PARAMETERS) foffset = (size_t)(offset_null == true ? DEFAULT_READV_OFFSET : offset); iov = emalloc(sizeof(php_iovec_t)); - iov->iov_base = emalloc(fnbytes); + iov->iov_base = ecalloc(1, fnbytes); iov->iov_len = fnbytes; cb = emalloc(sizeof(php_mrloop_cb_t)); @@ -634,7 +634,7 @@ static void php_mrloop_add_write_stream(INTERNAL_FUNCTION_PARAMETERS) nbytes = ZSTR_LEN(contents); iov = emalloc(sizeof(php_iovec_t)); - iov->iov_base = emalloc(nbytes); + iov->iov_base = ecalloc(1, nbytes); iov->iov_len = nbytes; strcpy(iov->iov_base, ZSTR_VAL(contents)); diff --git a/src/loop.h b/src/loop.h index c130b5d..74c7242 100644 --- a/src/loop.h +++ b/src/loop.h @@ -26,7 +26,7 @@ #define DEFAULT_STREAM_BUFF_LEN 1024 #define DEFAULT_CONN_BUFF_LEN 8132 #define DEFAULT_HTTP_HEADER_LIMIT 100 -#define DEFAULT_VECTOR_COUNT 2 +#define DEFAULT_VECTOR_COUNT 1 #define DEFAULT_READV_OFFSET 0 #define PHP_MRLOOP_TIMER 1 #define PHP_MRLOOP_PERIODIC_TIMER 2