fixed resubscription when different sockets type are in place

This commit is contained in:
Unbit
2014-01-04 10:12:03 +01:00
parent e4a993ac31
commit f18ceea9bf
2 changed files with 29 additions and 3 deletions
+28 -2
View File
@@ -601,7 +601,7 @@ static void send_subscription(int sfd, char *host, char *message, uint16_t messa
char *udp_port = strchr(host, ':');
if (fd < 0) {
if (fd == -1) {
if (udp_port) {
fd = socket(AF_INET, SOCK_DGRAM, 0);
}
@@ -614,6 +614,32 @@ static void send_subscription(int sfd, char *host, char *message, uint16_t messa
}
uwsgi_socket_nb(fd);
}
else if (fd == -2) {
static int unix_fd = -1;
static int inet_fd = -1;
if (udp_port) {
if (inet_fd == -1) {
inet_fd = socket(AF_INET, SOCK_DGRAM, 0);
if (inet_fd < 0) {
uwsgi_error("send_subscription()/socket()");
return;
}
uwsgi_socket_nb(inet_fd);
}
fd = inet_fd;
}
else {
if (unix_fd == -1) {
unix_fd = socket(AF_UNIX, SOCK_DGRAM, 0);
if (unix_fd < 0) {
uwsgi_error("send_subscription()/socket()");
return;
}
uwsgi_socket_nb(unix_fd);
}
fd = unix_fd;
}
}
if (udp_port) {
udp_port[0] = 0;
@@ -642,7 +668,7 @@ static void send_subscription(int sfd, char *host, char *message, uint16_t messa
uwsgi_error("send_subscription()/sendto()");
}
if (sfd < 0)
if (sfd == -1)
close(fd);
}
+1 -1
View File
@@ -217,7 +217,7 @@ void uwsgi_corerouter_manage_subscription(struct uwsgi_corerouter *ucr, int id,
sni_ca = uwsgi_concat2n(usr.sni_ca, usr.sni_ca_len, "", 0);
}
uwsgi_foreach(usl, ucr->resubscribe) {
uwsgi_send_subscription_from_fd(ugs->fd, usl->value, usr.key, usr.keylen, usr.modifier1, usr.modifier2, bbuf[3], address, NULL, sni_key, sni_cert, sni_ca);
uwsgi_send_subscription_from_fd(-2, usl->value, usr.key, usr.keylen, usr.modifier1, usr.modifier2, bbuf[3], address, NULL, sni_key, sni_cert, sni_ca);
}
if (sni_key) free(sni_key);
if (sni_cert) free(sni_cert);