mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2025-05-18 00:58:26 -04:00
Ricardo Galli found this too. We weren't setting no linger and keepalive
as we used to in icecast1. They make things work a bit better. svn path=/trunk/net/; revision=3177
This commit is contained in:
parent
7bccdbd4f0
commit
785cfefe3e
@ -177,6 +177,18 @@ int sock_set_blocking(sock_t sock, const int block)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int sock_set_nolinger(sock_t sock)
|
||||||
|
{
|
||||||
|
struct linger lin = { 0, 0 };
|
||||||
|
return setsockopt(sock, SOL_SOCKET, SO_LINGER, (void *)&lin, sizeof(struct linger));
|
||||||
|
}
|
||||||
|
|
||||||
|
int sock_set_keepalive(sock_t sock)
|
||||||
|
{
|
||||||
|
int keepalive = 1;
|
||||||
|
return setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (void *)&keepalive, sizeof(int));
|
||||||
|
}
|
||||||
|
|
||||||
/* sock_close
|
/* sock_close
|
||||||
**
|
**
|
||||||
** close the socket
|
** close the socket
|
||||||
@ -477,8 +489,11 @@ int sock_accept(sock_t serversock, char *ip, int len)
|
|||||||
slen = sizeof(struct sockaddr_in);
|
slen = sizeof(struct sockaddr_in);
|
||||||
ret = accept(serversock, (struct sockaddr *)&sin, &slen);
|
ret = accept(serversock, (struct sockaddr *)&sin, &slen);
|
||||||
|
|
||||||
if (ret >= 0 && ip != NULL)
|
if (ret >= 0 && ip != NULL) {
|
||||||
strncpy(ip, inet_ntoa(sin.sin_addr), len);
|
strncpy(ip, inet_ntoa(sin.sin_addr), len);
|
||||||
|
sock_set_nolinger(ret);
|
||||||
|
sock_set_keepalive(ret);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,8 @@ int sock_error(void);
|
|||||||
int sock_recoverable(int error);
|
int sock_recoverable(int error);
|
||||||
int sock_valid_socket(sock_t sock);
|
int sock_valid_socket(sock_t sock);
|
||||||
int sock_set_blocking(sock_t sock, const int block);
|
int sock_set_blocking(sock_t sock, const int block);
|
||||||
|
int sock_set_nolinger(sock_t sock);
|
||||||
|
int sock_set_keepalive(sock_t sock);
|
||||||
int sock_close(sock_t sock);
|
int sock_close(sock_t sock);
|
||||||
|
|
||||||
/* Connection related socket functions */
|
/* Connection related socket functions */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user