Skip to content

Commit

Permalink
api: fix segfault in timeout handling
Browse files Browse the repository at this point in the history
A botched update of reactor timeouts in the API handle implementation
for czmq-v2 caused a segfault when a reactor timer expired.
  • Loading branch information
garlick authored and grondo committed Oct 31, 2014
1 parent 3c49164 commit 874a7be
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions src/modules/api/libapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
#include "src/common/libutil/zfd.h"


typedef struct timeout_struct *timeout_t;

#define CMB_CTX_MAGIC 0xf434aaab
typedef struct {
int magic;
Expand All @@ -56,18 +54,11 @@ typedef struct {
zlist_t *resp; /* deferred */
zlist_t *event; /* deferred */
flux_t h;
timeout_t timeout;
zloop_t *zloop;
bool reactor_stop;
int reactor_rc;
} cmb_t;

struct timeout_struct {
cmb_t *c;
unsigned long msec;
int id;
};

static void cmb_reactor_stop (void *impl, int rc);

#define ZLOOP_RETURN(c) \
Expand Down Expand Up @@ -280,14 +271,9 @@ static void cmb_reactor_zs_remove (void *impl, void *zs, short events)
zloop_poller_end (c->zloop, &item); /* FIXME: 'events' are ignored */
}

#if CZMQ_VERSION_MAJOR < 2
#error I broke timeouts for old czmq -jg
#endif

static int tmout_cb (zloop_t *zl, int timer_id, void *arg)
{
timeout_t t = arg;
cmb_t *c = t->c;
cmb_t *c = arg;

if (flux_handle_event_tmout (c->h, timer_id) < 0)
cmb_reactor_stop (c, -1);
Expand Down

0 comments on commit 874a7be

Please sign in to comment.