fix getsockname on unbound sockets

This commit is contained in:
roberto@natty32
2011-03-04 09:01:14 +01:00
parent a2b74d0afd
commit 5f207e6978
+9
View File
@@ -1010,6 +1010,11 @@ int uwsgi_start(void *v_argv) {
// never here
exit(1);
}
// do not go on if no socket or gateway is defined
if (!uwsgi.sockets_cnt && !uwsgi.gateways_cnt) {
exit(0);
}
close(emperor_pipe[0]);
uwsgi.has_emperor = 1;
uwsgi.emperor_fd = emperor_pipe[1];
@@ -1249,6 +1254,10 @@ int uwsgi_start(void *v_argv) {
socket_type_len = sizeof(struct sockaddr_un);
gsa.sa = &usa.sa;
if (!getsockname(j, gsa.sa, &socket_type_len)) {
if (socket_type_len <= 2) {
// unbound socket
continue;
}
if (gsa.sa->sa_family == AF_UNIX) {
if (!strcmp(usa.sa_un.sun_path, uwsgi.sockets[i].name)) {
uwsgi.sockets[i].fd = j;