Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leaks upon disconnect #36

Open
wants to merge 70 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
b07dba7
fix memory leak in logging of large buffers
Aug 6, 2012
53cdc96
configure.ac: fix building without libxml2
pasis Oct 8, 2012
9088383
build shared library
pasis Oct 10, 2012
d0515b0
add libstrophe.pc file
pasis Oct 10, 2012
71000f2
update .gitignore
pasis Oct 11, 2012
8467256
Makefile.am: preserve system defined CFLAGS
pasis Oct 11, 2012
bb9cff0
base64_decode: avoid null pointer dereference
pasis Oct 11, 2012
e547233
base64_decode: handle zero-length buffers
pasis Oct 11, 2012
f658ee2
Merge branch 'master' of github.com:pasis/libstrophe
pasis Oct 11, 2012
8fc5462
Merge remote-tracking branch 'rzuck/master'
pasis Oct 11, 2012
c1facb1
xmpp_log: free memory before exit
pasis Oct 11, 2012
89b712e
_log_open_tag: size_t can never be less then 0
pasis Oct 11, 2012
a5d5986
base64_decode: shut up compiler
pasis Oct 11, 2012
387483e
auth.c: remove unused declaration
pasis Oct 11, 2012
2ccdf4e
thread.c: fix memory leak within mutex_destroy
pasis Oct 11, 2012
a9c4a08
ctx.c: spacing
pasis Oct 12, 2012
5e87552
update .gitignore
pasis Oct 12, 2012
a4164ac
xmpp_log: do not process when handler is NULL
pasis Oct 12, 2012
0bd52ce
rename fork to libcouplet
pasis Oct 12, 2012
6e48d26
remove expat dir
pasis Oct 12, 2012
7c17159
Makefile.am: rename variables
pasis Oct 12, 2012
fba22e2
Merge branch 'libcouplet'
pasis Oct 12, 2012
2f0ba0c
autotools: replace AC_PROG_RANLIB and AC_PROG_LIBTOOL with LT_INIT
pasis Oct 12, 2012
9108479
ctx.c: spacing
pasis Oct 12, 2012
6eb6018
ctx.c: update todo list
pasis Oct 12, 2012
bded019
common.h: spacing
pasis Oct 12, 2012
b986f8c
conn.c: spacing
pasis Oct 12, 2012
57c28e0
event.c: spacing
pasis Oct 13, 2012
103e7be
event, conn: lock send_queue with mutex
pasis Oct 13, 2012
7e40667
conn.c: spacing
pasis Oct 13, 2012
a8e6ec7
conn.c: little code refactoring
pasis Oct 13, 2012
0ba86a0
conn.c: update todo list
pasis Oct 13, 2012
abec656
thread.c: spacing
pasis Oct 14, 2012
fa77c20
move sending loop to a separated thread
pasis Oct 14, 2012
2f02910
event.c: update todo list
pasis Oct 14, 2012
5b48a24
thread: introduce xmpp_sem_destroy
pasis Oct 15, 2012
419c0d4
thread.c: fix typo
pasis Oct 15, 2012
39f1d53
thread.c: initialize ret in xmpp_sem_destroy
pasis Oct 15, 2012
b2a19c1
rename and document send queue helpers
pasis Oct 16, 2012
a90f09e
conn: set maximum domain length to 255
pasis Oct 16, 2012
1158369
conn: check for domain length before call strcpy
pasis Oct 16, 2012
ccb6e96
replace port number 5222 with a macro
pasis Oct 16, 2012
b6496f8
sock.c: add missing couplet.h
pasis Oct 16, 2012
eb52f45
sasl: spacing
pasis Oct 17, 2012
943bd62
ctx.c: update todo list
pasis Oct 17, 2012
a1c6745
ctx: destroy send_queeu_sem on destroying ctx
pasis Oct 17, 2012
226f59c
doc: update README
pasis Oct 18, 2012
349c1aa
introduce api for general lists
pasis Oct 18, 2012
76e5234
list: update api
pasis Oct 18, 2012
0c00ae8
list: implement some functions
pasis Oct 19, 2012
4d554b9
list: rename some functions
pasis Oct 19, 2012
1e58cd3
conn: use general list for send queue
pasis Oct 19, 2012
1ca7d8f
list: implement list_destroy
pasis Oct 19, 2012
8442c4d
list: update api, implement some functions
pasis Oct 19, 2012
46d3629
ctx: use general list for connlist
pasis Oct 19, 2012
0a78494
remove trailing whitespaces
pasis Oct 21, 2012
39abc3c
list: implement list_get_last
pasis Oct 21, 2012
677f500
update list api, implement list_pop_next
pasis Oct 22, 2012
6b28ba2
event.c: replace 4096 with XMPP_RCV_BUF macro
pasis Oct 22, 2012
b91aea0
common.h: add XMPP_RCV_BUF macro
pasis Oct 22, 2012
2830789
list.c: fix typo
pasis Oct 22, 2012
99407fb
doc: update README
pasis Oct 23, 2012
bc566b1
list: init next field when add new item
pasis Oct 23, 2012
6f50b7c
use generic list for handlers and timed_handlers
pasis Oct 23, 2012
09b0989
Added tags and cscope.out to .gitignore
boothj5 Oct 24, 2012
4137a06
Added ping namespace to couplet.h
boothj5 Oct 24, 2012
d556892
Merge pull request #1 from boothj5/master
pasis Oct 24, 2012
59aedf9
rewrite Makefile.am and configure.ac
pasis Oct 27, 2012
ed3917c
Fix two memory leaks, both related to cleanup
horazont Jan 11, 2013
91e9395
Merge branch 'master' of ssh://github.com/horazont/libstrophe
horazont Jan 21, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,31 @@ compile
aclocal.m4
config.log
config.status
config.guess
config.sub
depcomp
autom4te.cache
libtool
ltmain.sh
.dirstamp
.deps
.sconsign*
src/*.lo
src/*.o
examples/*.o
tests/*.o
tests/check_parser
*.la
*.a
*.tar.gz
*.zip
*.pc
*~
*.swp
docs/html
TAGS
tags
cscope.out
examples/basic
examples/active
examples/roster
Expand All @@ -33,3 +44,6 @@ tests/test_hash
tests/test_jid
tests/test_sasl
tests/test_sock
.libs/
examples/.libs/
src/.libs/
48 changes: 14 additions & 34 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,58 +1,38 @@
AUTOMAKE_OPTIONS = subdir-objects

CFLAGS = -g -Wall
COUPLET_LIBS = libcouplet.la

PARSER_CFLAGS=@PARSER_CFLAGS@
PARSER_LIBS=@PARSER_LIBS@

SSL_LIBS = -lssl -lcrypto -lz

STROPHE_FLAGS = -I$(top_srcdir)
STROPHE_LIBS = libstrophe.a $(PARSER_LIBS) $(SSL_LIBS)
pkgconfigdir = $(libdir)/pkgconfig

## Main build targets
lib_LIBRARIES = libstrophe.a
lib_LTLIBRARIES = libcouplet.la

libstrophe_a_CFLAGS=$(STROPHE_FLAGS) $(PARSER_CFLAGS)
libstrophe_a_SOURCES = src/auth.c src/conn.c src/ctx.c \
libcouplet_la_SOURCES = src/auth.c src/conn.c src/ctx.c \
src/event.c src/handler.c src/hash.c \
src/jid.c src/md5.c src/sasl.c src/sha1.c \
src/snprintf.c src/sock.c src/stanza.c src/thread.c \
src/tls_openssl.c src/util.c \
src/tls_openssl.c src/util.c src/list.c \
src/common.h src/hash.h src/md5.h src/ostypes.h src/parser.h \
src/sasl.h src/sha1.h src/sock.h src/thread.h src/tls.h src/util.h
src/sasl.h src/sha1.h src/sock.h src/thread.h src/tls.h src/util.h \
src/list.h

if PARSER_EXPAT
libstrophe_a_SOURCES += src/parser_expat.c
libcouplet_la_SOURCES += src/parser_expat.c
else
libstrophe_a_SOURCES += src/parser_libxml2.c
libcouplet_la_SOURCES += src/parser_libxml2.c
endif

include_HEADERS = strophe.h
noinst_HEADERS = strophepp.h
include_HEADERS = couplet.h
noinst_HEADERS = coupletpp.h

EXTRA_DIST = docs

## Examples
noinst_PROGRAMS = examples/active examples/roster examples/basic examples/bot
examples_active_SOURCES = examples/active.c
examples_active_CFLAGS = $(STROPHE_FLAGS)
examples_active_LDADD = $(STROPHE_LIBS)
examples_roster_SOURCES = examples/roster.c
examples_roster_CFLAGS = $(STROPHE_FLAGS)
examples_roster_LDADD = $(STROPHE_LIBS)
examples_basic_SOURCES = examples/basic.c
examples_basic_CFLAGS = $(STROPHE_FLAGS)
examples_basic_LDADD = $(STROPHE_LIBS)
examples_bot_SOURCES = examples/bot.c
examples_bot_CFLAGS = $(STROPHE_FLAGS)
examples_bot_LDADD = $(STROPHE_LIBS)

pkgconfig_DATA = libcouplet.pc

## Tests
TESTS = tests/check_parser
check_PROGRAMS = tests/check_parser
tests_check_parser_SOURCES = tests/check_parser.c tests/test.h
tests_check_parser_CFLAGS = @check_CFLAGS@ $(PARSER_CFLAGS) $(STROPHE_FLAGS) \
tests_check_parser_CFLAGS = @check_CFLAGS@ $(AM_CFLAGS) \
-I$(top_srcdir)/src
tests_check_parser_LDADD = @check_LIBS@ $(STROPHE_LIBS)
tests_check_parser_LDADD = @check_LIBS@ $(COUPLET_LIBS)
34 changes: 17 additions & 17 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
# libstrophe
# libcouplet

libstrophe is a lightweight XMPP client library written in C. It has
minimal dependencies and is configurable for various environments. It
runs well on both Linux, Unix, and Windows based platforms.

Its goals are:

- usable quickly
- well documented
- reliable
libcouplet is a fork of libstrophe - a lightweight XMPP client library
written in C. Goal of the fork is make library suitable for multi-thread
applications.

## Build Instructions

Expand All @@ -23,27 +17,33 @@ From the top-level directory, run the following commands:
./configure
make

This will create a static library, also in the top-level
directory, which can be linked into other programs. The
public API is defined in `strophe.h` which is also in the
top-level directory.

The `examples` directory contains some examples of how to
use the library; these may be helpful in addition to the
API documentation

## Requirements

libstrophe requires:
libcouplet requires:

- expat or libxml2 - expat is the default; use --with-libxml2 to
switch
- openssl
- libresolv on UNIX systems - make sure you include -lresolv
if you are compiling by hand.
if you are compiling by hand.

In addition, if you wish to run the unit tests, you will need the
check package.

Windows systems aren't supported for now.

### Gentoo

libcouplet can be installed from Gentoo overlay 'stuff':

layman -a stuff
echo =dev-libs/libcouplet-9999 ** >> /etc/portage/package.keywords
emerge libcouplet

### OS X (with Homebrew package manager)

You can install the requirements with:
Expand Down
1 change: 1 addition & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ if [ -d /usr/local/share/aclocal ]; then
ACFLAGS="-I /usr/local/share/aclocal"
fi

libtoolize
aclocal ${ACFLAGS}
automake --add-missing --foreign --copy
autoconf
58 changes: 30 additions & 28 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,48 +1,50 @@
AC_INIT([libstrophe], [0.8-snapshot], [[email protected]])
AC_INIT([libcouplet], [0.8], [[email protected]])
AM_INIT_AUTOMAKE
AC_CONFIG_FILES([Makefile libcouplet.pc])

AC_PROG_CC
AC_PROG_RANLIB
AM_PROG_CC_C_O

AC_CHECK_HEADER(openssl/ssl.h, [], [AC_MSG_ERROR([couldn't find openssl headers, openssl required])])
PKG_CHECK_MODULES([check], [check >= 0.9.4], [], [AC_MSG_WARN([libcheck not found; unit tests will not be compilable])])
LT_INIT

AC_ARG_WITH([libxml2],
[AS_HELP_STRING([--with-libxml2], [use libxml2 for XML parsing])],
[with_libxml2=check],
[with_libxml2=no])

if test "x$with_libxml2" != xno; then
PKG_CHECK_MODULES([libxml2], [libxml-2.0 >= 2.7],
[with_libxml2=yes],
[AC_MSG_ERROR([couldn't find libxml2])])
else
AC_CHECK_HEADER(expat.h, [], [AC_MSG_ERROR([couldn't find expat headers; expat required])])
[AS_HELP_STRING([--with-libxml2], [use libxml2 for XML parsing])])

PKG_CHECK_MODULES([openssl], [openssl], [],
[AC_MSG_ERROR([openssl is required for libcouplet])])
PKG_CHECK_MODULES([check], [check >= 0.9.4], [],
[AC_MSG_WARN([libcheck not found; unit tests will not be compilable])])
AC_CHECK_LIB(pthread, pthread_create, [],
[AC_MSG_ERROR([pthread support is required])])
AC_CHECK_LIB(resolv, res_query, [],
[AC_MSG_ERROR([libresolv is not found])])

if test "x$with_libxml2" = xyes; then
PKG_CHECK_MODULES([libxml2], [libxml-2.0 >= 2.7], [],
[AC_MSG_ERROR([libxml2 is required for libcouplet])])
else
PKG_CHECK_MODULES([expat], [expat], [],
[AC_MSG_ERROR([expat is required for libcouplet])])
fi

if test "x$with_libxml2" = xyes; then
with_parser=libxml2
PARSER_NAME=libxml2
PARSER_CFLAGS=\$\(libxml2_CFLAGS\)
PARSER_LIBS=\$\(libxml2_LIBS\)
LIBS="$LIBS $libxml2_LIBS"
AM_CFLAGS="$AM_CFLAGS $libxml2_CFLAGS"
else
with_parser=expat
PARSER_NAME=expat
PARSER_CFLAGS=
PARSER_LIBS=-lexpat
LIBS="$LIBS $expat_LIBS"
AM_CFLAGS="$AM_CFLAGS $expat_CFLAGS"
fi

AC_MSG_NOTICE([libstrophe will use the $with_parser XML parser])
AC_SEARCH_LIBS([socket], [socket])
LIBS="$LIBS $openssl_LIBS"
AM_CFLAGS="$AM_CFLAGS $openssl_CFLAGS -I. -Wall"

AC_LINK_IFELSE([AC_LANG_CALL([#include <resolv.h>], [res_query])], [],[LIBS="$LIBS -lresolv"])
AC_MSG_NOTICE([libcouplet will use the $PARSER_NAME XML parser])
AC_SEARCH_LIBS([socket], [socket])

AC_CHECK_HEADERS([arpa/nameser_compat.h])

AM_CONDITIONAL([PARSER_EXPAT], [test x$with_parser != xlibxml2])
AM_CONDITIONAL([PARSER_EXPAT], [test x$PARSER_NAME != xlibxml2])
AC_SUBST(PARSER_NAME)
AC_SUBST(PARSER_CFLAGS)
AC_SUBST(PARSER_LIBS)
AC_CONFIG_FILES([Makefile])
AC_SUBST(AM_CFLAGS)
AC_OUTPUT
Loading