Skip to content

Commit beabde7

Browse files
committed
Added TCP_NODELAY, suggested by Daniele Alessandri.
1 parent 5bdb90c commit beabde7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

library.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
#include "common.h"
2+
#include "php_network.h"
3+
#include <sys/types.h>
4+
#include <netinet/tcp.h> /* TCP_NODELAY */
5+
#include <sys/socket.h>
26

37
PHPAPI void redis_check_eof(RedisSock *redis_sock TSRMLS_DC)
48
{
@@ -469,6 +473,11 @@ PHPAPI int redis_sock_connect(RedisSock *redis_sock TSRMLS_DC)
469473

470474
efree(host);
471475

476+
/* set TCP_NODELAY */
477+
php_netstream_data_t *sock = (php_netstream_data_t*)redis_sock->stream->abstract;
478+
int tcp_flag = 1;
479+
int result = setsockopt(sock->socket, IPPROTO_TCP, TCP_NODELAY, (char *) &tcp_flag, sizeof(int));
480+
472481
if (!redis_sock->stream) {
473482
efree(errstr);
474483
return -1;

0 commit comments

Comments
 (0)