don't forget to close a descriptor on a malloc failure.

On passing, small rearrangement of the code to reduce indentation.

There is a bit more cleanup planned for this file, so a merge to 1.4
will be done when it is all done.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45152 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Luigi Rizzo
2006-10-15 20:54:15 +00:00
parent 9a3cef21ac
commit 895eb4fd73

View File

@@ -494,6 +494,8 @@ static void *http_root(void *data)
pthread_attr_t attr;
for (;;) {
int flags;
ast_wait_for_input(httpfd, -1);
sinlen = sizeof(sin);
fd = accept(httpfd, (struct sockaddr *)&sin, &sinlen);
@@ -503,8 +505,12 @@ static void *http_root(void *data)
continue;
}
ser = ast_calloc(1, sizeof(*ser));
if (ser) {
int flags = fcntl(fd, F_GETFL);
if (!ser) {
ast_log(LOG_WARNING, "No memory for new session: %s\n", strerror(errno));
close(fd);
continue;
}
flags = fcntl(fd, F_GETFL);
fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
ser->fd = fd;
memcpy(&ser->requestor, &sin, sizeof(ser->requestor));
@@ -523,7 +529,6 @@ static void *http_root(void *data)
free(ser);
}
}
}
return NULL;
}