Skip to content

Commit 743adcc

Browse files
committed
[mod_amqp] Add support for newer librabbitmq
1 parent ffec6d9 commit 743adcc

File tree

6 files changed

+31
-4
lines changed

6 files changed

+31
-4
lines changed

configure.ac

100755100644
Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,9 +1546,22 @@ PKG_CHECK_MODULES([SIGNALWIRE_CLIENT], [signalwire_client2 >= 2.0.0],[
15461546
])
15471547
])
15481548

1549-
PKG_CHECK_MODULES([AMQP], [librabbitmq >= 0.5.2],[
1550-
AM_CONDITIONAL([HAVE_AMQP],[true])],[
1551-
AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_AMQP],[false])])
1549+
PKG_CHECK_MODULES([AMQP], [librabbitmq >= 0.5.2], [
1550+
AM_CONDITIONAL([HAVE_AMQP], [true])
1551+
# Extract the version of librabbitmq
1552+
AMQP_VERSION=`$PKG_CONFIG --modversion librabbitmq`
1553+
AC_DEFINE_UNQUOTED([AMQP_VERSION], ["$AMQP_VERSION"], [Version of librabbitmq])
1554+
# Parse major and minor version numbers
1555+
AMQP_MAJOR_VERSION=`echo $AMQP_VERSION | cut -d. -f1`
1556+
AMQP_MINOR_VERSION=`echo $AMQP_VERSION | cut -d. -f2`
1557+
AC_DEFINE_UNQUOTED([AMQP_MAJOR_VERSION], [$AMQP_MAJOR_VERSION], [Major version of librabbitmq])
1558+
AC_DEFINE_UNQUOTED([AMQP_MINOR_VERSION], [$AMQP_MINOR_VERSION], [Minor version of librabbitmq])
1559+
AC_SUBST(AMQP_MAJOR_VERSION)
1560+
AC_SUBST(AMQP_MINOR_VERSION)
1561+
], [
1562+
AC_MSG_RESULT([no])
1563+
AM_CONDITIONAL([HAVE_AMQP], [false])
1564+
])
15521565

15531566
PKG_CHECK_MODULES([H2O], [libh2o-evloop >= 0.11.0],[
15541567
AM_CONDITIONAL([HAVE_H2O],[true])],[

src/mod/event_handlers/mod_amqp/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if HAVE_AMQP
55

66
mod_LTLIBRARIES = mod_amqp.la
77
mod_amqp_la_SOURCES = mod_amqp_utils.c mod_amqp_connection.c mod_amqp_producer.c mod_amqp_command.c mod_amqp_logging.c mod_amqp.c
8-
mod_amqp_la_CFLAGS = $(AM_CFLAGS) $(AMQP_CFLAGS)
8+
mod_amqp_la_CFLAGS = $(AM_CFLAGS) $(AMQP_CFLAGS) -DAMQP_MAJOR_VERSION=$(AMQP_MAJOR_VERSION) -DAMQP_MINOR_VERSION=$(AMQP_MINOR_VERSION)
99
mod_amqp_la_LIBADD = $(switch_builddir)/libfreeswitch.la
1010
mod_amqp_la_LDFLAGS = -avoid-version -module -no-undefined -shared $(AMQP_LIBS) $(SWITCH_AM_LDFLAGS)
1111

src/mod/event_handlers/mod_amqp/mod_amqp.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,18 @@
4040
#define MOD_AMQP_H
4141

4242
#include <switch.h>
43+
#define AMQP_VERSION_INT(a, b) ((a)<<8 | (b))
44+
#if AMQP_VERSION_INT(AMQP_MAJOR_VERSION, AMQP_MINOR_VERSION) >= AMQP_VERSION_INT(0, 12)
45+
#include <rabbitmq-c/amqp.h>
46+
#include <rabbitmq-c/framing.h>
47+
#include <rabbitmq-c/tcp_socket.h>
48+
#include <rabbitmq-c/ssl_socket.h>
49+
#else
4350
#include <amqp.h>
4451
#include <amqp_framing.h>
4552
#include <amqp_tcp_socket.h>
4653
#include <amqp_ssl_socket.h>
54+
#endif
4755

4856
#ifndef _MSC_VER
4957
#include <strings.h>

src/mod/event_handlers/mod_amqp/mod_amqp_connection.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ switch_status_t mod_amqp_connection_open(mod_amqp_connection_t *connections, mod
117117

118118
while (connection_attempt && amqp_status){
119119
if (connection_attempt->ssl_on == 1) {
120+
#if AMQP_VERSION_INT(AMQP_MAJOR_VERSION, AMQP_MINOR_VERSION) < AMQP_VERSION_INT(0, 13)
120121
amqp_set_initialize_ssl_library(connection_attempt->ssl_on);
122+
#endif
121123
if (!(socket = amqp_ssl_socket_new(newConnection))) {
122124
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not create SSL socket\n");
123125
goto err;

w32/rabbitmq-c-version.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
<Import Project="basedir.props" Condition=" '$(BaseDirImported)' == ''"/>
55
</ImportGroup>
66
<PropertyGroup Label="UserMacros">
7+
<rabbitmq_cMajorVersion>0</rabbitmq_cMajorVersion>
8+
<rabbitmq_cMinorVersion>15</rabbitmq_cMinorVersion>
9+
<rabbitmq_cRevisionVersion>0</rabbitmq_cRevisionVersion>
710
<rabbitmq_cVersion>0.15.0</rabbitmq_cVersion>
811
<rabbitmq_cBuildNumber>0</rabbitmq_cBuildNumber>
912
</PropertyGroup>

w32/rabbitmq-c.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
<ItemDefinitionGroup>
5353
<ClCompile>
5454
<AdditionalIncludeDirectories>$(rabbitmq_c_libDir)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
55+
<PreprocessorDefinitions>AMQP_MAJOR_VERSION=$(rabbitmq_cMajorVersion);AMQP_MINOR_VERSION=$(rabbitmq_cMinorVersion);%(PreprocessorDefinitions)</PreprocessorDefinitions>
5556
</ClCompile>
5657
<Link>
5758
<AdditionalLibraryDirectories>$(rabbitmq_c_libDir)\binaries\$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>

0 commit comments

Comments
 (0)