<p>Nir Simionovich (GreenfieldTech - Israel) has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/6819">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">This patch adds a beanstalk CDR backend.<br><br>Beanstalkd is a simple to use job queue. It provides a means to<br>create multiple job queues called "tubes". Each tube can store<br>multiple jobs, with varying priorities with the queue. Queue<br>processing is available via a simple TCP socket or via well defined<br>libraries, avaialble at<br>https://github.com/kr/beanstalkd/wiki/client-libraries<br><br>At the same time, I cleaned up some minor syntax correction inside<br>cdr_manager.c, per remarks by Corey Farrel<br><br>Change-Id: I5fe4089a34ab3b39230786d9bbfddafa56715f48<br>---<br>M build_tools/menuselect-deps.in<br>A cdr/cdr_beanstalkd.c<br>M cdr/cdr_manager.c<br>A configs/samples/cdr_beanstalkd.conf.sample<br>M configure<br>M configure.ac<br>M include/asterisk/autoconfig.h.in<br>M makeopts.in<br>8 files changed, 598 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/19/6819/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/build_tools/menuselect-deps.in b/build_tools/menuselect-deps.in<br>index ec70be0..9629ea5 100644<br>--- a/build_tools/menuselect-deps.in<br>+++ b/build_tools/menuselect-deps.in<br>@@ -1,5 +1,6 @@<br> ALSA=@PBX_ALSA@<br> BLUETOOTH=@PBX_BLUETOOTH@<br>+BEANSTALK=@PBX_BEANSTALK@<br> COROSYNC=@PBX_COROSYNC@<br> CRYPTO=@PBX_CRYPTO@<br> BFD=@PBX_BFD@<br>diff --git a/cdr/cdr_beanstalkd.c b/cdr/cdr_beanstalkd.c<br>new file mode 100644<br>index 0000000..5ec6e64<br>--- /dev/null<br>+++ b/cdr/cdr_beanstalkd.c<br>@@ -0,0 +1,416 @@<br>+/*<br>+ * Asterisk -- An open source telephony toolkit.<br>+ *<br>+ * Copyright (C) 2017<br>+ *<br>+ * Nir Simionovich <nirs@greenfieldtech.net><br>+ *<br>+ * See http://www.asterisk.org for more information about<br>+ * the Asterisk project. Please do not directly contact<br>+ * any of the maintainers of this project for assistance;<br>+ * the project provides a web site, mailing lists and IRC<br>+ * channels for your use.<br>+ *<br>+ * This program is free software, distributed under the terms of<br>+ * the GNU General Public License Version 2. See the LICENSE file<br>+ * at the top of the source tree.<br>+ */<br>+<br>+/*!<br>+ * \file<br>+ * \brief Asterisk Beanstalkd CDR records.<br>+ *<br>+ * See also<br>+ * \arg \ref AstCDR<br>+ * \ingroup cdr_drivers<br>+ */<br>+<br>+/*! \li \ref cdr_beanstalkd.c uses the configuration file \ref cdr_beanstalkd.conf<br>+ * \addtogroup configuration_file Configuration Files<br>+ */<br>+<br>+/*!<br>+ * \page cdr_beanstalkd.conf cdr_beanstalkd.conf<br>+ * \verbinclude cdr_beanstalkd.conf.sample<br>+ */<br>+<br>+/*** MODULEINFO<br>+     <depend>beanstalk</depend><br>+ ***/<br>+<br>+/*** DOCUMENTATION<br>+       <managerEvent language="en_US" name="Cdr"><br>+         <managerEventInstance class="EVENT_FLAG_CDR"><br>+                        <synopsis>Raised when a CDR is generated.</synopsis><br>+                     <syntax><br>+                               <parameter name="AccountCode"><br>+                                       <para>The account code of the Party A channel.</para><br>+                            </parameter><br>+                           <parameter name="Source"><br>+                                    <para>The Caller ID number associated with the Party A in the CDR.</para><br>+                                </parameter><br>+                           <parameter name="Destination"><br>+                                       <para>The dialplan extension the Party A was executing.</para><br>+                           </parameter><br>+                           <parameter name="DestinationContext"><br>+                                        <para>The dialplan context the Party A was executing.</para><br>+                             </parameter><br>+                           <parameter name="CallerID"><br>+                                  <para>The Caller ID name associated with the Party A in the CDR.</para><br>+                          </parameter><br>+                           <parameter name="Channel"><br>+                                   <para>The channel name of the Party A.</para><br>+                            </parameter><br>+                           <parameter name="DestinationChannel"><br>+                                        <para>The channel name of the Party B.</para><br>+                            </parameter><br>+                           <parameter name="LastApplication"><br>+                                   <para>The last dialplan application the Party A executed.</para><br>+                         </parameter><br>+                           <parameter name="LastData"><br>+                                  <para><br>+                                         The parameters passed to the last dialplan application the<br>+                                           Party A executed.<br>+                                    </para><br>+                                </parameter><br>+                           <parameter name="StartTime"><br>+                                 <para>The time the CDR was created.</para><br>+                               </parameter><br>+                           <parameter name="AnswerTime"><br>+                                        <para><br>+                                         The earliest of either the time when Party A answered, or<br>+                                            the start time of this CDR.<br>+                                  </para><br>+                                </parameter><br>+                           <parameter name="EndTime"><br>+                                   <para><br>+                                         The time when the CDR was finished. This occurs when the<br>+                                             Party A hangs up or when the bridge between Party A and<br>+                                              Party B is broken.<br>+                                   </para><br>+                                </parameter><br>+                           <parameter name="Duration"><br>+                                  <para>The time, in seconds, of <replaceable>EndTime</replaceable> - <replaceable>StartTime</replaceable>.</para><br>+                         </parameter><br>+                           <parameter name="BillableSeconds"><br>+                                   <para>The time, in seconds, of <replaceable>AnswerTime</replaceable> - <replaceable>StartTime</replaceable>.</para><br>+                              </parameter><br>+                           <parameter name="Disposition"><br>+                                       <para>The final known disposition of the CDR.</para><br>+                                     <enumlist><br>+                                             <enum name="NO ANSWER"><br>+                                                      <para>The channel was not answered. This is the default disposition.</para><br>+                                              </enum><br>+                                                <enum name="FAILED"><br>+                                                 <para>The channel attempted to dial but the call failed.</para><br>+                                                  <note><br>+                                                         <para>The congestion setting in <filename>cdr.conf</filename> can result<br>+                                                           in the <literal>AST_CAUSE_CONGESTION</literal> hang up cause or the<br>+                                                              <literal>CONGESTION</literal> dial status to map to this disposition.<br>+                                                            </para><br>+                                                        </note><br>+                                                </enum><br>+                                                <enum name="BUSY"><br>+                                                   <para>The channel attempted to dial but the remote party was busy.</para><br>+                                                </enum><br>+                                                <enum name="ANSWERED"><br>+                                                       <para>The channel was answered. The hang up cause will no longer<br>+                                                       impact the disposition of the CDR.</para><br>+                                              </enum><br>+                                                <enum name="CONGESTION"><br>+                                                     <para>The channel attempted to dial but the remote party was congested.</para><br>+                                           </enum><br>+                                        </enumlist><br>+                            </parameter><br>+                           <parameter name="AMAFlags"><br>+                                  <para>A flag that informs a billing system how to treat the CDR.</para><br>+                                  <enumlist><br>+                                             <enum name="OMIT"><br>+                                                   <para>This CDR should be ignored.</para><br>+                                         </enum><br>+                                                <enum name="BILLING"><br>+                                                        <para>This CDR contains valid billing data.</para><br>+                                               </enum><br>+                                                <enum name="DOCUMENTATION"><br>+                                                  <para>This CDR is for documentation purposes.</para><br>+                                             </enum><br>+                                        </enumlist><br>+                            </parameter><br>+                           <parameter name="UniqueID"><br>+                                  <para>A unique identifier for the Party A channel.</para><br>+                                </parameter><br>+                           <parameter name="UserField"><br>+                                 <para><br>+                                         A user defined field set on the channels. If set on both the Party A<br>+                                         and Party B channel, the userfields of both are concatenated and<br>+                                             separated by a <literal>;</literal>.<br>+                                     </para><br>+                                </parameter><br>+                   </syntax><br>+                      <description><br>+                          <para><br>+                                 The <replaceable>Cdr</replaceable> job is only raised when the<br>+                                   <filename>cdr_beanstalk</filename> backend is loaded and registered with<br>+                                 the CDR engine.<br>+                              </para><br>+                                <note><br>+                                 <para><br>+                                         This job can contain additional fields depending on the configuration<br>+                                                provided by <filename>cdr_beanstalkd.conf</filename>.<br>+                                    </para><br>+                                </note><br>+                        </description><br>+         </managerEventInstance><br>+        </managerEvent><br>+ ***/<br>+<br>+#include "beanstalk.h"<br>+<br>+#include "asterisk.h"<br>+<br>+#include <time.h><br>+#include <stdio.h><br>+<br>+#include "asterisk/channel.h"<br>+#include "asterisk/cdr.h"<br>+#include "asterisk/module.h"<br>+#include "asterisk/utils.h"<br>+#include "asterisk/manager.h"<br>+#include "asterisk/config.h"<br>+#include "asterisk/pbx.h"<br>+#include "asterisk/json.h"<br>+<br>+#define DATE_FORMAT    "%Y-%m-%d %T"<br>+#define CONF_FILE    "cdr_beanstalkd.conf"<br>+#define CUSTOM_FIELDS_BUF_SIZE 1024<br>+#define BEANSTALK_JOB_SIZE 4096<br>+#define BEANSTALK_JOB_PRIORITY 99<br>+#define BEANSTALK_JOB_TTR 60<br>+#define BEANSTALK_JOB_DELAY 0<br>+<br>+static const char name[] = "cdr_beanstalkd";<br>+<br>+static int enablecdr = 0;<br>+static char *bs_host = "127.0.0.1";<br>+static int bs_port = 13000;<br>+static char *bs_tube = "asterisk-cdr";<br>+static int priority = BEANSTALK_JOB_PRIORITY;<br>+<br>+static struct ast_str *customfields;<br>+AST_RWLOCK_DEFINE_STATIC(customfields_lock);<br>+<br>+static int beanstalk_put(struct ast_cdr *cdr);<br>+<br>+static int load_config(int reload) {<br>+    char *cat;<br>+    struct ast_config *cfg;<br>+    struct ast_variable *v;<br>+    struct ast_flags config_flags = {reload ? CONFIG_FLAG_FILEUNCHANGED : 0};<br>+    int newenablecdr = 0;<br>+<br>+    cfg = ast_config_load(CONF_FILE, config_flags);<br>+    if (cfg == CONFIG_STATUS_FILEUNCHANGED) {<br>+        return 0;<br>+    }<br>+<br>+    if (cfg == CONFIG_STATUS_FILEINVALID) {<br>+        ast_log(LOG_ERROR, "Config file '%s' could not be parsed\n", CONF_FILE);<br>+        return -1;<br>+    }<br>+<br>+    if (!cfg) {<br>+        /* Standard configuration */<br>+        ast_log(LOG_WARNING, "Failed to load configuration file. Module not activated.\n");<br>+        if (enablecdr) {<br>+            ast_cdr_backend_suspend(name);<br>+        }<br>+        enablecdr = 0;<br>+        return -1;<br>+    }<br>+<br>+    if (reload) {<br>+        ast_rwlock_wrlock(&customfields_lock);<br>+    }<br>+<br>+    if (reload && customfields) {<br>+        ast_free(customfields);<br>+        customfields = NULL;<br>+    }<br>+<br>+    while ((cat = ast_category_browse(cfg, cat))) {<br>+        if (!strcasecmp(cat, "general")) {<br>+            v = ast_variable_browse(cfg, cat);<br>+            while (v) {<br>+<br>+                if (!newenablecdr) {<br>+                    if (!strcasecmp(v->name, "enabled")) {<br>+                        newenablecdr = ast_true(v->value);<br>+                    }<br>+                } else {<br>+                    if (!strcasecmp(v->name, "host")) {<br>+                        bs_host = ast_strdup(v->value);<br>+                    } else if (!strcasecmp(v->name, "port")) {<br>+                        bs_port = atoi(v->value);<br>+                    } else if (!strcasecmp(v->name, "tube")) {<br>+                        bs_tube = ast_strdup(v->value);<br>+                    } else if (!strcasecmp(v->name, "priority")) {<br>+                        priority = atoi(v->value);<br>+                    }<br>+                    v = v->next;<br>+                }<br>+            }<br>+        }<br>+        ast_log(LOG_NOTICE, "Added beanstalkd server %s at port %d with tube %s", bs_host, bs_port, bs_tube);<br>+    }<br>+<br>+    if (reload) {<br>+        ast_rwlock_unlock(&customfields_lock);<br>+    }<br>+<br>+    ast_config_destroy(cfg);<br>+<br>+    if (!newenablecdr) {<br>+        ast_cdr_backend_suspend(name);<br>+    } else if (newenablecdr) {<br>+        ast_cdr_backend_unsuspend(name);<br>+    }<br>+    enablecdr = newenablecdr;<br>+<br>+    return 0;<br>+}<br>+<br>+static int beanstalk_put(struct ast_cdr *cdr) {<br>+    struct ast_tm timeresult;<br>+    char strStartTime[80];<br>+    char strAnswerTime[80];<br>+    char strEndTime[80];<br>+    char buf[CUSTOM_FIELDS_BUF_SIZE];<br>+    char *cdr_buffer;<br>+    int bs_id;<br>+    int bs_socket;<br>+    struct ast_json *t_cdr_json;<br>+<br>+    if (!enablecdr) {<br>+        return 0;<br>+    }<br>+<br>+    bs_socket = bs_connect(bs_host, bs_port);<br>+<br>+    if (bs_use(bs_socket, bs_tube) != BS_STATUS_OK) {<br>+        ast_log(LOG_ERROR, "Connection to Beanstalk tube %s @ %s:%d had failed", bs_tube, bs_host, bs_port);<br>+        return 0;<br>+    }<br>+<br>+    ast_localtime(&cdr->start, &timeresult, NULL);<br>+    ast_strftime(strStartTime, sizeof(strStartTime), DATE_FORMAT, &timeresult);<br>+<br>+    if (cdr->answer.tv_sec) {<br>+        ast_localtime(&cdr->answer, &timeresult, NULL);<br>+        ast_strftime(strAnswerTime, sizeof(strAnswerTime), DATE_FORMAT, &timeresult);<br>+    }<br>+<br>+    ast_localtime(&cdr->end, &timeresult, NULL);<br>+    ast_strftime(strEndTime, sizeof(strEndTime), DATE_FORMAT, &timeresult);<br>+<br>+    buf[0] = '\0';<br>+    //cdr_buffer[0] = '\0';<br>+<br>+    ast_rwlock_rdlock(&customfields_lock);<br>+    if (customfields && ast_str_strlen(customfields)) {<br>+        struct ast_channel *dummy = ast_dummy_channel_alloc();<br>+        if (!dummy) {<br>+            ast_log(LOG_ERROR, "Unable to allocate channel for variable substitution.\n");<br>+            return 0;<br>+        }<br>+        ast_channel_cdr_set(dummy, ast_cdr_dup(cdr));<br>+        pbx_substitute_variables_helper(dummy, ast_str_buffer(customfields), buf, sizeof(buf) - 1);<br>+        ast_channel_unref(dummy);<br>+    }<br>+    ast_rwlock_unlock(&customfields_lock);<br>+<br>+    t_cdr_json = ast_json_pack("{s:s, s:s, s:s, s:s, s:s, s:s, s:s, s:s, s:s, s:s, s:s, s:s, s:i, s:i, s:s, s:s, s:s, s:s, s:s}",<br>+                               "AccountCode", S_OR(cdr->accountcode, ""),<br>+                               "Source", S_OR(cdr->src, ""),<br>+                               "Destination", S_OR(cdr->dst, ""),<br>+                               "DestinationContext", S_OR(cdr->dcontext, ""),<br>+                               "CallerID", S_OR(cdr->clid, ""),<br>+                               "Channel", S_OR(cdr->channel, ""),<br>+                               "DestinationChannel", S_OR(cdr->dstchannel, ""),<br>+                               "LastApplication", S_OR(cdr->lastapp, ""),<br>+                               "LastData", S_OR(cdr->lastdata, ""),<br>+                               "StartTime", S_OR(strStartTime, ""),<br>+                               "AnswerTime", S_OR(strAnswerTime, ""),<br>+                               "EndTime", S_OR(strEndTime, ""),<br>+                               "Duration", cdr->duration,<br>+                               "Billsec", cdr->billsec,<br>+                               "Disposition", S_OR(ast_cdr_disp2str(cdr->disposition), ""),<br>+                               "AMAFlags", S_OR(ast_channel_amaflags2string(cdr->amaflags), ""),<br>+                               "UniqueID", S_OR(cdr->uniqueid, ""),<br>+                               "UserField", S_OR(cdr->userfield, ""),<br>+                               "CustomFields", S_OR(buf, ""));<br>+<br>+    cdr_buffer = ast_json_dump_string(t_cdr_json);<br>+<br>+    /*<br>+    snprintf(cdr_buffer, BEANSTALK_JOB_SIZE,<br>+            "{ \"AccountCode\": \"%s\", \"Source\": \"%s\", \"Destination\": \"%s\", \"DestinationContext\": \"%s\", "<br>+                    "\"CallerID\": \"%s\", \"Channel\": \"%s\", \"DestinationChannel\": \"%s\", \"LastApplication\": \"%s\", "<br>+                    "\"LastData\": \"%s\", \"StartTime\": \"%s\", \"AnswerTime\": \"%s\", \"EndTime\": \"%s\", "<br>+                    "\"Duration\": \"%ld\", \"BillableSeconds\": \"%ld\", \"Disposition\": \"%s\", \"AMAFlags\": \"%s\", "<br>+                    "\"UniqueID\": \"%s\", \"UserField\": \"%s\", \"CustomFields\": \"%s\" }",<br>+            cdr->accountcode, cdr->src, cdr->dst, cdr->dcontext, cdr->clid, cdr->channel,<br>+            cdr->dstchannel, cdr->lastapp, cdr->lastdata, strStartTime, strAnswerTime, strEndTime,<br>+            cdr->duration, cdr->billsec, ast_cdr_disp2str(cdr->disposition),<br>+            ast_channel_amaflags2string(cdr->amaflags), cdr->uniqueid, cdr->userfield, buf<br>+    );<br>+    */<br>+<br>+    bs_id = bs_put(bs_socket, priority, BEANSTALK_JOB_DELAY, BEANSTALK_JOB_TTR, cdr_buffer, strlen(cdr_buffer));<br>+<br>+    if (bs_id > 0) {<br>+        ast_log(LOG_NOTICE, "Successfully created job %d with %s\n", bs_id, cdr_buffer);<br>+    } else {<br>+        ast_log(LOG_ERROR, "CDR job creation failed for %s\n", cdr_buffer);<br>+    }<br>+<br>+    bs_disconnect(bs_socket);<br>+    return 0;<br>+}<br>+<br>+static int unload_module(void) {<br>+    if (ast_cdr_unregister(name)) {<br>+        return -1;<br>+    }<br>+<br>+    if (customfields) {<br>+        ast_free(customfields);<br>+    }<br>+<br>+    return 0;<br>+}<br>+<br>+static int load_module(void) {<br>+    if (ast_cdr_register(name, "Asterisk CDR Beanstalkd Backend", beanstalk_put)) {<br>+        return AST_MODULE_LOAD_DECLINE;<br>+    }<br>+<br>+    if (load_config(0)) {<br>+        ast_cdr_unregister(name);<br>+        return AST_MODULE_LOAD_DECLINE;<br>+    }<br>+<br>+    return AST_MODULE_LOAD_SUCCESS;<br>+}<br>+<br>+static int reload(void) {<br>+    return load_config(1);<br>+}<br>+<br>+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Asterisk Beanstalkd CDR Backend",<br>+    .support_level = AST_MODULE_SUPPORT_CORE,<br>+    .load = load_module,<br>+    .unload = unload_module,<br>+    .reload = reload,<br>+    .load_pri = AST_MODPRI_CDR_DRIVER,<br>+);<br>+<br>diff --git a/cdr/cdr_manager.c b/cdr/cdr_manager.c<br>index 3f0cc6b..af0c372 100644<br>--- a/cdr/cdr_manager.c<br>+++ b/cdr/cdr_manager.c<br>@@ -273,13 +273,14 @@<br> static int manager_log(struct ast_cdr *cdr)<br> {<br>   struct ast_tm timeresult;<br>-    char strStartTime[80] = "";<br>-        char strAnswerTime[80] = "";<br>-       char strEndTime[80] = "";<br>+  char strStartTime[80];<br>+       char strAnswerTime[80];<br>+      char strEndTime[80];<br>  char buf[CUSTOM_FIELDS_BUF_SIZE];<br> <br>- if (!enablecdr)<br>+      if (!enablecdr) {<br>             return 0;<br>+    }<br> <br>  ast_localtime(&cdr->start, &timeresult, NULL);<br>     ast_strftime(strStartTime, sizeof(strStartTime), DATE_FORMAT, &timeresult);<br>@@ -340,8 +341,9 @@<br>          return -1;<br>    }<br> <br>- if (customfields)<br>+    if (customfields) {<br>           ast_free(customfields);<br>+      }<br> <br>  return 0;<br> }<br>diff --git a/configs/samples/cdr_beanstalkd.conf.sample b/configs/samples/cdr_beanstalkd.conf.sample<br>new file mode 100644<br>index 0000000..26d2d83<br>--- /dev/null<br>+++ b/configs/samples/cdr_beanstalkd.conf.sample<br>@@ -0,0 +1,22 @@<br>+;<br>+; Asterisk Call Management CDR via Beanstalkd job queue<br>+;<br>+; Beanstalkd is a simple job queue server, that is highly versatile and simple to use.<br>+; Beanstalkd includes the capability of using multiple queues at the same time, with priorities.<br>+;<br>+<br>+[general]<br>+;enabled = yes<br>+<br>+;host = 127.0.0.1    ; Specify the remote IP address of the Beanstalkd server<br>+;port = 11300        ; Specify the remote PORT of the the Beanstalkd server<br>+;tube = asterisk-cdr ; Specify the default CDR job queue to use<br>+;priority = 99       ; Specify the default job priority for the queue. This parameter is useful when building<br>+                     ; platform with multiple Asterisk servers, that are used for different functions. For example,<br>+                     ; none billable CDR records can be inserted with a priority of 99, while billable ones be<br>+                     ; inserted with a priority of 1<br>+<br>+<br>+<br>+<br>+<br>diff --git a/configure b/configure<br>index 893f107..bc4b03c 100755<br>--- a/configure<br>+++ b/configure<br>@@ -991,6 +991,10 @@<br> PJSIP_DLG_CREATE_UAS_AND_INC_LOCK_DIR<br> PJSIP_DLG_CREATE_UAS_AND_INC_LOCK_INCLUDE<br> PJSIP_DLG_CREATE_UAS_AND_INC_LOCK_LIB<br>+PBX_BEANSTALK<br>+BEANSTALK_DIR<br>+BEANSTALK_INCLUDE<br>+BEANSTALK_LIB<br> PBX_PGSQL<br> PGSQL_DIR<br> PGSQL_INCLUDE<br>@@ -1430,6 +1434,7 @@<br> with_osptk<br> with_oss<br> with_postgres<br>+with_beanstalk<br> with_pjproject<br> with_popt<br> with_portaudio<br>@@ -2182,6 +2187,7 @@<br>   --with-osptk=PATH       use OSP Toolkit files in PATH<br>   --with-oss=PATH         use Open Sound System files in PATH<br>   --with-postgres=PATH    use PostgreSQL files in PATH<br>+  --with-beanstalk=PATH   use Beanstalk Job Queue files in PATH<br>   --with-pjproject=PATH   use PJPROJECT files in PATH<br>   --with-popt=PATH        use popt files in PATH<br>   --with-portaudio=PATH   use PortAudio files in PATH<br>@@ -11409,6 +11415,38 @@<br>      *)<br>    PGSQL_DIR="${withval}"<br>      ac_mandatory_list="${ac_mandatory_list} PGSQL"<br>+     ;;<br>+   esac<br>+<br>+fi<br>+<br>+<br>+<br>+<br>+<br>+<br>+<br>+<br>+    BEANSTALK_DESCRIP="Beanstalk Job Queue"<br>+    BEANSTALK_OPTION="beanstalk"<br>+    PBX_BEANSTALK=0<br>+<br>+# Check whether --with-beanstalk was given.<br>+if test "${with_beanstalk+set}" = set; then :<br>+  withval=$with_beanstalk;<br>+      case ${withval} in<br>+   n|no)<br>+        USE_BEANSTALK=no<br>+     # -1 is a magic value used by menuselect to know that the package<br>+    # was disabled, other than 'not found'<br>+       PBX_BEANSTALK=-1<br>+     ;;<br>+   y|ye|yes)<br>+    ac_mandatory_list="${ac_mandatory_list} BEANSTALK"<br>+ ;;<br>+   *)<br>+   BEANSTALK_DIR="${withval}"<br>+ ac_mandatory_list="${ac_mandatory_list} BEANSTALK"<br>  ;;<br>    esac<br> <br>@@ -25043,6 +25081,111 @@<br> <br> <br> <br>+<br>+if test "x${PBX_BEANSTALK}" != "x1" -a "${USE_BEANSTALK}" != "no"; then<br>+   pbxlibdir=""<br>+   # if --with-BEANSTALK=DIR has been specified, use it.<br>+   if test "x${BEANSTALK_DIR}" != "x"; then<br>+      if test -d ${BEANSTALK_DIR}/lib; then<br>+         pbxlibdir="-L${BEANSTALK_DIR}/lib"<br>+      else<br>+         pbxlibdir="-L${BEANSTALK_DIR}"<br>+      fi<br>+   fi<br>+   pbxfuncname="bs_version"<br>+   if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers<br>+      AST_BEANSTALK_FOUND=yes<br>+   else<br>+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"<br>+      CFLAGS="${CFLAGS} "<br>+      as_ac_Lib=`$as_echo "ac_cv_lib_beanstalk_${pbxfuncname}" | $as_tr_sh`<br>+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${pbxfuncname} in -lbeanstalk" >&5<br>+$as_echo_n "checking for ${pbxfuncname} in -lbeanstalk... " >&6; }<br>+if eval \${$as_ac_Lib+:} false; then :<br>+  $as_echo_n "(cached) " >&6<br>+else<br>+  ac_check_lib_save_LIBS=$LIBS<br>+LIBS="-lbeanstalk ${pbxlibdir}  $LIBS"<br>+cat confdefs.h - <<_ACEOF >conftest.$ac_ext<br>+/* end confdefs.h.  */<br>+<br>+/* Override any GCC internal prototype to avoid an error.<br>+   Use char because int might match the return type of a GCC<br>+   builtin and then its argument prototype would still apply.  */<br>+#ifdef __cplusplus<br>+extern "C"<br>+#endif<br>+char ${pbxfuncname} ();<br>+int<br>+main ()<br>+{<br>+return ${pbxfuncname} ();<br>+  ;<br>+  return 0;<br>+}<br>+_ACEOF<br>+if ac_fn_c_try_link "$LINENO"; then :<br>+  eval "$as_ac_Lib=yes"<br>+else<br>+  eval "$as_ac_Lib=no"<br>+fi<br>+rm -f core conftest.err conftest.$ac_objext \<br>+    conftest$ac_exeext conftest.$ac_ext<br>+LIBS=$ac_check_lib_save_LIBS<br>+fi<br>+eval ac_res=\$$as_ac_Lib<br>+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5<br>+$as_echo "$ac_res" >&6; }<br>+if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :<br>+  AST_BEANSTALK_FOUND=yes<br>+else<br>+  AST_BEANSTALK_FOUND=no<br>+fi<br>+<br>+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"<br>+   fi<br>+<br>+   # now check for the header.<br>+   if test "${AST_BEANSTALK_FOUND}" = "yes"; then<br>+      BEANSTALK_LIB="${pbxlibdir} -lbeanstalk "<br>+      # if --with-BEANSTALK=DIR has been specified, use it.<br>+      if test "x${BEANSTALK_DIR}" != "x"; then<br>+         BEANSTALK_INCLUDE="-I${BEANSTALK_DIR}/include"<br>+      fi<br>+      BEANSTALK_INCLUDE="${BEANSTALK_INCLUDE} "<br>+      if test "xbeanstalk.h" = "x" ; then    # no header, assume found<br>+         BEANSTALK_HEADER_FOUND="1"<br>+      else                          # check for the header<br>+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"<br>+         CPPFLAGS="${CPPFLAGS} ${BEANSTALK_INCLUDE}"<br>+         ac_fn_c_check_header_mongrel "$LINENO" "beanstalk.h" "ac_cv_header_beanstalk_h" "$ac_includes_default"<br>+if test "x$ac_cv_header_beanstalk_h" = xyes; then :<br>+  BEANSTALK_HEADER_FOUND=1<br>+else<br>+  BEANSTALK_HEADER_FOUND=0<br>+fi<br>+<br>+<br>+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"<br>+      fi<br>+      if test "x${BEANSTALK_HEADER_FOUND}" = "x0" ; then<br>+         BEANSTALK_LIB=""<br>+         BEANSTALK_INCLUDE=""<br>+      else<br>+         if test "x${pbxfuncname}" = "x" ; then              # only checking headers -> no library<br>+            BEANSTALK_LIB=""<br>+         fi<br>+         PBX_BEANSTALK=1<br>+         cat >>confdefs.h <<_ACEOF<br>+#define HAVE_BEANSTALK 1<br>+_ACEOF<br>+<br>+      fi<br>+   fi<br>+fi<br>+<br>+<br>+<br> # possible places for oss definitions<br> <br> if test "x${PBX_OSS}" != "x1" -a "${USE_OSS}" != "no"; then<br>diff --git a/configure.ac b/configure.ac<br>index e714c54..1ca64c8 100644<br>--- a/configure.ac<br>+++ b/configure.ac<br>@@ -526,6 +526,7 @@<br> AST_EXT_LIB_SETUP([OSPTK], [OSP Toolkit], [osptk])<br> AST_EXT_LIB_SETUP([OSS], [Open Sound System], [oss])<br> AST_EXT_LIB_SETUP([PGSQL], [PostgreSQL], [postgres])<br>+AST_EXT_LIB_SETUP([BEANSTALK], [Beanstalk Job Queue], [beanstalk])<br> <br> if test "x${PBX_PJPROJECT}" != "x1" ; then<br> AST_EXT_LIB_SETUP([PJPROJECT], [PJPROJECT], [pjproject])<br>@@ -2170,6 +2171,8 @@<br> <br> AST_EXT_LIB_CHECK([BLUETOOTH], [bluetooth], [ba2str], [bluetooth/bluetooth.h])<br> <br>+AST_EXT_LIB_CHECK([BEANSTALK], [beanstalk], [bs_version], [beanstalk.h])<br>+<br> # possible places for oss definitions<br> AST_EXT_LIB_CHECK([OSS], [ossaudio], [], [linux/soundcard.h])<br> AST_EXT_LIB_CHECK([OSS], [ossaudio], [], [sys/soundcard.h])<br>diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in<br>index b9b4e1f..c7a1908 100644<br>--- a/include/asterisk/autoconfig.h.in<br>+++ b/include/asterisk/autoconfig.h.in<br>@@ -115,6 +115,9 @@<br>    attribute. */<br> #undef HAVE_ATTRIBUTE_warn_unused_result<br> <br>+/* Define to 1 if you have the Beanstalk Job Queue library. */<br>+#undef HAVE_BEANSTALK<br>+<br> /* Define to 1 if you have the Debug symbol decoding library. */<br> #undef HAVE_BFD<br> <br>diff --git a/makeopts.in b/makeopts.in<br>index 6a1164c..924f3e2 100644<br>--- a/makeopts.in<br>+++ b/makeopts.in<br>@@ -383,3 +383,6 @@<br> <br> SNDFILE_INCLUDE=@SNDFILE_INCLUDE@<br> SNDFILE_LIB=@SNDFILE_LIB@<br>+<br>+BEANSTALK_INCLUDE=@BEANSTALK_INCLUDE@<br>+BEANSTALK_LIB=@BEANSTALK_LIB@<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/6819">change 6819</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/6819"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I5fe4089a34ab3b39230786d9bbfddafa56715f48 </div>
<div style="display:none"> Gerrit-Change-Number: 6819 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Nir Simionovich (GreenfieldTech - Israel) <nirs@greenfieldtech.net> </div>