Small patch to handler_fire_stanza() from Matthew Wild <mwild1@gmail.com>. prev was not advanced along with item.

This commit is contained in:
Jack Moffitt
2008-08-26 04:44:19 +00:00
parent 2befeee9e5
commit ade38ae188
5 changed files with 31 additions and 20 deletions

View File

@@ -48,7 +48,7 @@ Sources = Split("""
util.c
thread.c
snprintf.c
tls_dummy.c
tls_gnutls.c
oocontext.cpp
oostanza.cpp
""")
@@ -98,7 +98,7 @@ Default(strophe)
exenv = env.Clone()
exenv.Append(CPPPATH=['.'])
exenv.Append(LIBS=["strophe", "expat"])
exenv.Append(LIBS=["strophe", "expat", "gnutls"])
exenv.Append(LIBPATH=["."])
if exenv["PLATFORM"] == "win32":
exenv.Append(LIBS=["ws2_32", "winmm"])

View File

@@ -89,12 +89,14 @@ void handler_fire_stanza(xmpp_conn_t * const conn,
while (item) {
/* skip newly added handlers */
if (!item->enabled) {
prev = item;
item = item->next;
continue;
}
/* don't call user handlers until authentication succeeds */
if (item->user_handler && !conn->authenticated) {
prev = item;
item = item->next;
continue;
}

View File

@@ -78,11 +78,6 @@ int tls_write(tls_t *tls, const void * const buff, const size_t len)
return -1;
}
int tls_clear_pending_write(tls_t *tls)
{
return -1;
}
int tls_is_recoverable(int error)
{
return 0;

View File

@@ -24,6 +24,7 @@
struct _tls {
xmpp_ctx_t *ctx; /* do we need this? */
int error;
sock_t sock;
gnutls_session_t session;
gnutls_certificate_credentials_t cred;
@@ -53,6 +54,7 @@ tls_t *tls_new(xmpp_ctx_t *ctx, sock_t sock)
if (tls) {
tls->ctx = ctx;
tls->error = 0;
tls->sock = sock;
gnutls_init(&tls->session, GNUTLS_CLIENT);
@@ -63,7 +65,7 @@ tls_t *tls_new(xmpp_ctx_t *ctx, sock_t sock)
/* fixme: this may require setting a callback on win32? */
gnutls_transport_set_ptr(tls->session,
(gnutls_transport_ptr_t)sock);
(gnutls_transport_ptr_t)sock);
}
return tls;
@@ -93,7 +95,14 @@ int tls_set_credentials(tls_t *tls, const char *cafilename)
int tls_start(tls_t *tls)
{
return gnutls_handshake(tls->session);
int ret;
xmpp_debug(tls->ctx, "TLS", "tls starting");
ret = gnutls_handshake(tls->session);
if (ret < 0) {
tls->error = ret;
return 0;
}
return 1;
}
int tls_stop(tls_t *tls)
@@ -101,17 +110,13 @@ int tls_stop(tls_t *tls)
return gnutls_bye(tls->session, GNUTLS_SHUT_RDWR);
}
int tls_error(tls_t *tls)
{
/* todo: some kind of error polling/dump */
return 0;
}
int tls_read(tls_t *tls, void * const buff, const size_t len)
{
int ret;
xmpp_debug(tls->ctx, "TLS", "tls_read called");
ret = gnutls_record_recv(tls->session, buff, len);
xmpp_debug(tls->ctx, "TLS", "tls_read returned %d", ret);
return ret;
}
@@ -125,3 +130,17 @@ int tls_write(tls_t *tls, const void * const buff, const size_t len)
return ret;
}
int tls_clear_pending_write(tls_t *tls)
{
return 0;
}
int tls_error(tls_t *tls)
{
return tls->error;
}
int tls_is_recoverable(int error)
{
return sock_is_recoverable(error);
}

View File

@@ -189,11 +189,6 @@ int tls_stop(tls_t *tls)
return 1;
}
int tls_error(tls_t *tls)
{
return tls->lasterror;
}
int tls_is_recoverable(int error)
{
return (error == SSL_ERROR_NONE || error == SSL_ERROR_WANT_READ