summaryrefslogtreecommitdiff
path: root/pflocal
diff options
context:
space:
mode:
authorJustus Winter <justus@gnupg.org>2017-06-19 21:20:57 +0200
committerJustus Winter <justus@gnupg.org>2017-08-05 18:42:22 +0200
commit835b293d35a209d38047126443d41fa7090daa4c (patch)
tree5bf956895e6030f91cd618fb191b2151f6d25423 /pflocal
parentdc0b5a43224999223a246870912b0f292b1980e9 (diff)
Use our own variant of 'assert' and 'assert_perror'.
Our variants print stack traces on failures. This will make locating errors much easier.
Diffstat (limited to 'pflocal')
-rw-r--r--pflocal/connq.c20
-rw-r--r--pflocal/io.c2
-rw-r--r--pflocal/sock.c8
-rw-r--r--pflocal/sock.h6
4 files changed, 18 insertions, 18 deletions
diff --git a/pflocal/connq.c b/pflocal/connq.c
index d86f9a24..b231da7f 100644
--- a/pflocal/connq.c
+++ b/pflocal/connq.c
@@ -19,7 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <pthread.h>
-#include <assert.h>
+#include <assert-backtrace.h>
#include <stdlib.h>
#include "connq.h"
@@ -66,7 +66,7 @@ connq_request_init (struct connq_request *req, struct sock *sock)
static void
connq_request_enqueue (struct connq *cq, struct connq_request *req)
{
- assert (pthread_mutex_trylock (&cq->lock));
+ assert_backtrace (pthread_mutex_trylock (&cq->lock));
req->next = NULL;
*cq->tail = req;
@@ -82,8 +82,8 @@ connq_request_dequeue (struct connq *cq)
{
struct connq_request *req;
- assert (pthread_mutex_trylock (&cq->lock));
- assert (cq->head);
+ assert_backtrace (pthread_mutex_trylock (&cq->lock));
+ assert_backtrace (cq->head);
req = cq->head;
cq->head = req->next;
@@ -132,8 +132,8 @@ connq_destroy (struct connq *cq)
{
/* Everybody in the queue should hold a reference to the socket
containing the queue. */
- assert (! cq->head);
- assert (cq->count == 0);
+ assert_backtrace (! cq->head);
+ assert_backtrace (cq->count == 0);
free (cq);
}
@@ -171,7 +171,7 @@ connq_listen (struct connq *cq, struct timespec *tsp, struct sock **sock)
if (cq->count == 0)
/* The request queue is empty. */
{
- assert (! cq->head);
+ assert_backtrace (! cq->head);
if (cq->num_connectors > 0)
/* Someone is waiting for an acceptor. Signal that we can
@@ -190,7 +190,7 @@ connq_listen (struct connq *cq, struct timespec *tsp, struct sock **sock)
while (cq->count == 0);
}
- assert (cq->head);
+ assert_backtrace (cq->head);
if (sock)
/* Dequeue the next request, if desired. */
@@ -271,7 +271,7 @@ connq_connect_complete (struct connq *cq, struct sock *sock)
pthread_mutex_lock (&cq->lock);
- assert (cq->num_connectors > 0);
+ assert_backtrace (cq->num_connectors > 0);
cq->num_connectors --;
connq_request_enqueue (cq, req);
@@ -294,7 +294,7 @@ connq_connect_cancel (struct connq *cq)
{
pthread_mutex_lock (&cq->lock);
- assert (cq->num_connectors > 0);
+ assert_backtrace (cq->num_connectors > 0);
cq->num_connectors --;
if (cq->count + cq->num_connectors >= cq->max + cq->num_listeners)
diff --git a/pflocal/io.c b/pflocal/io.c
index c5622746..77e9df6e 100644
--- a/pflocal/io.c
+++ b/pflocal/io.c
@@ -442,7 +442,7 @@ S_io_reauthenticate (struct sock_user *user, mach_port_t rendezvous)
auth_server = getauth ();
err = mach_port_insert_right (mach_task_self (), new_user_port,
new_user_port, MACH_MSG_TYPE_MAKE_SEND);
- assert_perror (err);
+ assert_perror_backtrace (err);
do
err =
auth_server_authenticate (auth_server,
diff --git a/pflocal/sock.c b/pflocal/sock.c
index ef70d2c8..be64a3da 100644
--- a/pflocal/sock.c
+++ b/pflocal/sock.c
@@ -147,7 +147,7 @@ _sock_norefs (struct sock *sock)
{
/* A sock should never have an address when it has 0 refs, as the
address should hold a reference to the sock! */
- assert (sock->addr == NULL);
+ assert_backtrace (sock->addr == NULL);
pthread_mutex_unlock (&sock->lock); /* Unlock so sock_free can do stuff. */
sock_free (sock);
}
@@ -249,7 +249,7 @@ addr_clean (void *vaddr)
/* ADDR should never have a socket bound to it at this point, as it should
have been removed by addr_unbind dropping the socket's weak reference
it. */
- assert (addr->sock == NULL);
+ assert_backtrace (addr->sock == NULL);
}
/* Return a new address, not connected to any socket yet, ADDR. */
@@ -307,7 +307,7 @@ sock_bind (struct sock *sock, struct addr *addr)
zero because whoever's calling us should be holding a ref. */
sock->refs--;
ports_port_deref_weak (old_addr);
- assert (sock->refs > 0); /* But make sure... */
+ assert_backtrace (sock->refs > 0); /* But make sure... */
}
}
@@ -394,7 +394,7 @@ sock_connect (struct sock *sock1, struct sock *sock2)
|| (rd->flags & PFLOCAL_SOCK_SHUTDOWN_READ)))
{
struct pipe *pipe = rd->read_pipe;
- assert (pipe); /* Since PFLOCAL_SOCK_SHUTDOWN_READ isn't set. */
+ assert_backtrace (pipe); /* Since PFLOCAL_SOCK_SHUTDOWN_READ isn't set. */
pipe_add_writer (pipe);
wr->write_pipe = pipe;
}
diff --git a/pflocal/sock.h b/pflocal/sock.h
index 29f0f1f7..011b91a3 100644
--- a/pflocal/sock.h
+++ b/pflocal/sock.h
@@ -21,7 +21,7 @@
#ifndef __SOCK_H__
#define __SOCK_H__
-#include <assert.h>
+#include <assert-backtrace.h>
#include <pthread.h> /* For mutexes */
#include <sys/mman.h>
#include <sys/types.h>
@@ -139,12 +139,12 @@ sock_deref (struct sock *sock)
/* Unbind */
err = sock_bind (sock, NULL);
- assert (!err);
+ assert_backtrace (!err);
/* And release the ref, and thus kill SOCK. */
pthread_mutex_lock (&sock->lock);
sock->refs--;
- assert(sock->refs == 0);
+ assert_backtrace (sock->refs == 0);
_sock_norefs (sock);
}
else