summaryrefslogtreecommitdiff
path: root/anet.c
diff options
context:
space:
mode:
Diffstat (limited to 'anet.c')
-rw-r--r--anet.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/anet.c b/anet.c
index 45b8620..aec2cc7 100644
--- a/anet.c
+++ b/anet.c
@@ -63,11 +63,11 @@ int anetNonBlock(char *err, int fd)
* Note that fcntl(2) for F_GETFL and F_SETFL can't be
* interrupted by a signal. */
if ((flags = fcntl(fd, F_GETFL)) == -1) {
- anetSetError(err, "fcntl(F_GETFL): %s\n", strerror(errno));
+ anetSetError(err, "fcntl(F_GETFL): %s", strerror(errno));
return ANET_ERR;
}
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1) {
- anetSetError(err, "fcntl(F_SETFL,O_NONBLOCK): %s\n", strerror(errno));
+ anetSetError(err, "fcntl(F_SETFL,O_NONBLOCK): %s", strerror(errno));
return ANET_ERR;
}
return ANET_OK;
@@ -78,7 +78,7 @@ int anetTcpNoDelay(char *err, int fd)
int yes = 1;
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &yes, sizeof(yes)) == -1)
{
- anetSetError(err, "setsockopt TCP_NODELAY: %s\n", strerror(errno));
+ anetSetError(err, "setsockopt(TCP_NODELAY): %s", strerror(errno));
return ANET_ERR;
}
return ANET_OK;
@@ -88,7 +88,7 @@ int anetSetSendBuffer(char *err, int fd, int buffsize)
{
if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &buffsize, sizeof(buffsize)) == -1)
{
- anetSetError(err, "setsockopt SO_SNDBUF: %s\n", strerror(errno));
+ anetSetError(err, "setsockopt(SO_SNDBUF): %s", strerror(errno));
return ANET_ERR;
}
return ANET_OK;
@@ -98,7 +98,7 @@ int anetTcpKeepAlive(char *err, int fd)
{
int yes = 1;
if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &yes, sizeof(yes)) == -1) {
- anetSetError(err, "setsockopt SO_KEEPALIVE: %s\n", strerror(errno));
+ anetSetError(err, "setsockopt(SO_KEEPALIVE): %s", strerror(errno));
return ANET_ERR;
}
return ANET_OK;
@@ -114,7 +114,7 @@ int anetResolve(char *err, char *host, char *ipbuf)
he = gethostbyname(host);
if (he == NULL) {
- anetSetError(err, "can't resolve: %s\n", host);
+ anetSetError(err, "can't resolve: %s", host);
return ANET_ERR;
}
memcpy(&sa.sin_addr, he->h_addr, sizeof(struct in_addr));
@@ -131,7 +131,7 @@ static int anetTcpGenericConnect(char *err, const char *addr, int port, int flag
struct sockaddr_in sa;
if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
- anetSetError(err, "creating socket: %s\n", strerror(errno));
+ anetSetError(err, "creating socket: %s", strerror(errno));
return ANET_ERR;
}
/* Make sure connection-intensive things like the redis benckmark
@@ -145,7 +145,7 @@ static int anetTcpGenericConnect(char *err, const char *addr, int port, int flag
he = gethostbyname(addr);
if (he == NULL) {
- anetSetError(err, "can't resolve: %s\n", addr);
+ anetSetError(err, "can't resolve: %s", addr);
close(s);
return ANET_ERR;
}
@@ -160,7 +160,7 @@ static int anetTcpGenericConnect(char *err, const char *addr, int port, int flag
flags & ANET_CONNECT_NONBLOCK)
return s;
- anetSetError(err, "connect: %s\n", strerror(errno));
+ anetSetError(err, "connect: %s", strerror(errno));
close(s);
return ANET_ERR;
}
@@ -213,11 +213,11 @@ int anetTcpServer(char *err, int port, char *bindaddr)
struct sockaddr_in sa;
if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
- anetSetError(err, "socket: %s\n", strerror(errno));
+ anetSetError(err, "socket: %s", strerror(errno));
return ANET_ERR;
}
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) {
- anetSetError(err, "setsockopt SO_REUSEADDR: %s\n", strerror(errno));
+ anetSetError(err, "setsockopt(SO_REUSEADDR): %s", strerror(errno));
close(s);
return ANET_ERR;
}
@@ -227,18 +227,18 @@ int anetTcpServer(char *err, int port, char *bindaddr)
sa.sin_addr.s_addr = htonl(INADDR_ANY);
if (bindaddr) {
if (inet_aton(bindaddr, &sa.sin_addr) == 0) {
- anetSetError(err, "Invalid bind address\n");
+ anetSetError(err, "inet_aton: Invalid bind address");
close(s);
return ANET_ERR;
}
}
if (bind(s, (struct sockaddr*)&sa, sizeof(sa)) == -1) {
- anetSetError(err, "bind: %s\n", strerror(errno));
+ anetSetError(err, "bind: %s", strerror(errno));
close(s);
return ANET_ERR;
}
if (listen(s, 511) == -1) { /* the magic 511 constant is from nginx */
- anetSetError(err, "listen: %s\n", strerror(errno));
+ anetSetError(err, "listen: %s", strerror(errno));
close(s);
return ANET_ERR;
}
@@ -258,7 +258,7 @@ int anetAccept(char *err, int serversock, char *ip, int *port)
if (errno == EINTR)
continue;
else {
- anetSetError(err, "accept: %s\n", strerror(errno));
+ anetSetError(err, "accept: %s", strerror(errno));
return ANET_ERR;
}
}