summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/Makefile8
-rw-r--r--main/http.c29
-rw-r--r--main/iostream.c13
-rw-r--r--third-party/Makefile2
-rw-r--r--third-party/pjproject/Makefile12
5 files changed, 37 insertions, 27 deletions
diff --git a/main/Makefile b/main/Makefile
index 95c3c70c6..2b7321d4f 100644
--- a/main/Makefile
+++ b/main/Makefile
@@ -363,10 +363,14 @@ binuninstall:
rm -f "$(DESTDIR)$(ASTSBINDIR)/$(MAIN_TGT)"
rm -f "$(DESTDIR)$(ASTSBINDIR)/rasterisk"
ifneq ($(ASTSSL_LIB).$(ASTSSL_SO_VERSION),.)
- rm -f "$(DESTDIR)$(ASTLIBDIR)/$(ASTSSL_LIB).$(ASTSSL_SO_VERSION)"
+# ASTSSL_SO_VERSION may not exist on Darwin
+ rm -f "$(DESTDIR)$(ASTLIBDIR)/$(ASTSSL_LIB).$(ASTSSL_SO_VERSION)" || :
+ rm -f "$(DESTDIR)$(ASTLIBDIR)/$(ASTSSL_LIB)"
endif
ifneq ($(ASTPJ_LIB).$(ASTPJ_SO_VERSION),.)
- rm -f "$(DESTDIR)$(ASTLIBDIR)/$(ASTPJ_LIB).$(ASTPJ_SO_VERSION)"
+# ASTSSL_SO_VERSION may not exist on Darwin
+ rm -f "$(DESTDIR)$(ASTLIBDIR)/$(ASTPJ_LIB).$(ASTPJ_SO_VERSION)" || :
+ rm -f "$(DESTDIR)$(ASTLIBDIR)/$(ASTPJ_LIB)"
endif
ifneq ($(LDCONFIG),)
$(LDCONFIG) $(LDCONFIG_FLAGS) "$(DESTDIR)$(ASTLIBDIR)/"
diff --git a/main/http.c b/main/http.c
index 9aff4d167..5f57b1eb0 100644
--- a/main/http.c
+++ b/main/http.c
@@ -454,6 +454,7 @@ void ast_http_send(struct ast_tcptls_session_instance *ser,
int content_length = 0;
int close_connection;
struct ast_str *server_header_field = ast_str_create(MAX_SERVER_NAME_LENGTH);
+ int send_content;
if (!ser || !server_header_field) {
/* The connection is not open. */
@@ -504,6 +505,8 @@ void ast_http_send(struct ast_tcptls_session_instance *ser,
lseek(fd, 0, SEEK_SET);
}
+ send_content = method != AST_HTTP_HEAD || status_code >= 400;
+
/* send http header */
ast_iostream_printf(ser->stream,
"HTTP/1.1 %d %s\r\n"
@@ -513,33 +516,25 @@ void ast_http_send(struct ast_tcptls_session_instance *ser,
"%s"
"%s"
"Content-Length: %d\r\n"
- "\r\n",
+ "\r\n"
+ "%s",
status_code, status_title ? status_title : "OK",
ast_str_buffer(server_header_field),
timebuf,
close_connection ? "Connection: close\r\n" : "",
static_content ? "" : "Cache-Control: no-cache, no-store\r\n",
http_header ? ast_str_buffer(http_header) : "",
- content_length
+ content_length,
+ send_content && out && ast_str_strlen(out) ? ast_str_buffer(out) : ""
);
/* send content */
- if (method != AST_HTTP_HEAD || status_code >= 400) {
- if (out && ast_str_strlen(out)) {
- len = ast_str_strlen(out);
- if (ast_iostream_write(ser->stream, ast_str_buffer(out), len) != len) {
- ast_log(LOG_ERROR, "fwrite() failed: %s\n", strerror(errno));
+ if (send_content && fd) {
+ while ((len = read(fd, buf, sizeof(buf))) > 0) {
+ if (ast_iostream_write(ser->stream, buf, len) != len) {
+ ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
close_connection = 1;
- }
- }
-
- if (fd) {
- while ((len = read(fd, buf, sizeof(buf))) > 0) {
- if (ast_iostream_write(ser->stream, buf, len) != len) {
- ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
- close_connection = 1;
- break;
- }
+ break;
}
}
}
diff --git a/main/iostream.c b/main/iostream.c
index a20a04896..22cd5985c 100644
--- a/main/iostream.c
+++ b/main/iostream.c
@@ -404,7 +404,7 @@ ssize_t ast_iostream_write(struct ast_iostream *stream, const void *buf, size_t
ssize_t ast_iostream_printf(struct ast_iostream *stream, const void *fmt, ...)
{
- char sbuf[256], *buf = sbuf;
+ char sbuf[512], *buf = sbuf;
int len, len2, ret = -1;
va_list va;
@@ -412,15 +412,18 @@ ssize_t ast_iostream_printf(struct ast_iostream *stream, const void *fmt, ...)
len = vsnprintf(buf, sizeof(sbuf), fmt, va);
va_end(va);
- if (len > sizeof(sbuf)) {
- buf = ast_malloc(len);
+ if (len > sizeof(sbuf) - 1) {
+ /* Add one to the string length to accommodate the NULL byte */
+ size_t buf_len = len + 1;
+
+ buf = ast_malloc(buf_len);
if (!buf) {
return -1;
}
va_start(va, fmt);
- len2 = vsnprintf(buf, len, fmt, va);
+ len2 = vsnprintf(buf, buf_len, fmt, va);
va_end(va);
- if (len2 > len) {
+ if (len2 != len) {
goto error;
}
}
diff --git a/third-party/Makefile b/third-party/Makefile
index 0aca21e06..f3016f153 100644
--- a/third-party/Makefile
+++ b/third-party/Makefile
@@ -13,7 +13,7 @@ override MAKECMDGOALS?=all
MAKECMDGOALS:=$(subst dist-clean,distclean,$(MAKECMDGOALS))
MAKECMDGOALS:=$(subst tpclean,clean,$(MAKECMDGOALS))
-all distclean dist-clean install tpclean : $(TP_SUBDIRS)
+all distclean dist-clean install uninstall tpclean : $(TP_SUBDIRS)
install uninstall: $(TP_INSTALL_SUBDIRS)
$(TP_SUBDIRS):
diff --git a/third-party/pjproject/Makefile b/third-party/pjproject/Makefile
index 3f50a89b9..21bdf235e 100644
--- a/third-party/pjproject/Makefile
+++ b/third-party/pjproject/Makefile
@@ -20,6 +20,11 @@ ifeq ($(findstring clean,$(MAKECMDGOALS)),clean)
SPECIAL_TARGETS += clean
endif
+ifeq ($(findstring uninstall,$(MAKECMDGOALS)),uninstall)
+ SPECIAL_TARGETS += uninstall
+endif
+
+
ifneq ($(wildcard ../../makeopts),)
include ../../makeopts
endif
@@ -62,9 +67,12 @@ ifeq ($(SPECIAL_TARGETS),)
source/pjsip-apps/src/python/_pjsua.so: LDFLAGS += -L$(PJDIR)/pjsip-apps/lib -Wl,-whole-archive -lasterisk_malloc_debug -Wl,-no-whole-archive
source/pjsip-apps/src/python/_pjsua.so: source/pjsip-apps/lib/libasterisk_malloc_debug.a
endif
- TARGETS += pjproject.symbols
- export CFLAGS += $(CF)
+ ifeq ($(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS)),)
+ CF += -O3
+ endif
+ export CFLAGS += $(CF) -g3
export LDFLAGS += $(CC_LDFLAGS)
+ TARGETS += pjproject.symbols
else
all install:
endif