Merge "Bundled pjproject: Fix finding SIP transactions."
authorJoshua Colp <jcolp@digium.com>
Wed, 7 Dec 2016 19:38:25 +0000 (13:38 -0600)
committerGerrit Code Review <gerrit2@gerrit.digium.api>
Wed, 7 Dec 2016 19:38:25 +0000 (13:38 -0600)
main/Makefile
main/http.c
main/iostream.c
third-party/Makefile
third-party/pjproject/Makefile

index 95c3c70..2b7321d 100644 (file)
@@ -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)/"
index 9aff4d1..5f57b1e 100644 (file)
@@ -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;
                        }
                }
        }
index a20a048..22cd598 100644 (file)
@@ -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;
                }
        }
index 0aca21e..f3016f1 100644 (file)
@@ -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):
index 3f50a89..21bdf23 100644 (file)
@@ -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