pulse-server: reuse the socket

This commit is contained in:
Wim Taymans 2020-10-08 17:50:20 +02:00
parent d44fdabea1
commit 71e3052a33

View file

@ -2723,13 +2723,17 @@ error:
static int make_inet_socket(struct impl *impl, uint32_t address, uint16_t port) static int make_inet_socket(struct impl *impl, uint32_t address, uint16_t port)
{ {
struct sockaddr_in addr; struct sockaddr_in addr;
int res, fd; int res, fd, on;
if ((fd = socket(PF_INET, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0)) < 0) { if ((fd = socket(PF_INET, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0)) < 0) {
res = -errno; res = -errno;
goto error; goto error;
} }
on = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const void *) &on, sizeof(on)) < 0)
pw_log_warn(NAME" %p: setsockopt(): %m", impl);
spa_zero(addr); spa_zero(addr);
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_port = htons(port); addr.sin_port = htons(port);