mirror of https://github.com/ericonr/sndio.git
use TCP_NODELAY
This commit is contained in:
parent
a583ebc5d9
commit
32a1e3d36e
|
@ -21,6 +21,7 @@
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#include <netinet/tcp.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
@ -178,7 +179,7 @@ listen_revents(struct file *file, struct pollfd *pfd)
|
||||||
struct listen *f = (struct listen *)file;
|
struct listen *f = (struct listen *)file;
|
||||||
struct sockaddr caddr;
|
struct sockaddr caddr;
|
||||||
socklen_t caddrlen;
|
socklen_t caddrlen;
|
||||||
int sock;
|
int sock, opt;
|
||||||
|
|
||||||
if (pfd->revents & POLLIN) {
|
if (pfd->revents & POLLIN) {
|
||||||
caddrlen = sizeof(caddrlen);
|
caddrlen = sizeof(caddrlen);
|
||||||
|
@ -193,6 +194,15 @@ listen_revents(struct file *file, struct pollfd *pfd)
|
||||||
close(sock);
|
close(sock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (f->path == NULL) {
|
||||||
|
opt = 1;
|
||||||
|
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
|
||||||
|
&opt, sizeof(int)) < 0) {
|
||||||
|
perror("setsockopt");
|
||||||
|
close(sock);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (sock_new(&sock_ops, sock) == NULL) {
|
if (sock_new(&sock_ops, sock) == NULL) {
|
||||||
close(sock);
|
close(sock);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#include <netinet/tcp.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -316,7 +317,7 @@ bad_gen:
|
||||||
int
|
int
|
||||||
aucat_connect_tcp(struct aucat *hdl, char *host, char *unit, int isaudio)
|
aucat_connect_tcp(struct aucat *hdl, char *host, char *unit, int isaudio)
|
||||||
{
|
{
|
||||||
int s, error;
|
int s, error, opt;
|
||||||
struct addrinfo *ailist, *ai, aihints;
|
struct addrinfo *ailist, *ai, aihints;
|
||||||
unsigned port;
|
unsigned port;
|
||||||
char serv[NI_MAXSERV];
|
char serv[NI_MAXSERV];
|
||||||
|
@ -356,6 +357,12 @@ aucat_connect_tcp(struct aucat *hdl, char *host, char *unit, int isaudio)
|
||||||
freeaddrinfo(ailist);
|
freeaddrinfo(ailist);
|
||||||
if (s < 0)
|
if (s < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
opt = 1;
|
||||||
|
if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(int)) < 0) {
|
||||||
|
DPERROR("setsockopt");
|
||||||
|
close(s);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
hdl->fd = s;
|
hdl->fd = s;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue