Commit 0633c24c authored by Tommy Olofsson's avatar Tommy Olofsson
Browse files

Prepared for auto. handling of encoder registrations.

parent 689c4b2a
......@@ -345,8 +345,8 @@ void firefly_channel_unrestrict(struct firefly_channel *chan);
typedef void (*labcomm_handler_function)(void *value, void *context);
typedef int (*labcomm_decoder_register_function)(struct labcomm_decoder *d,
labcomm_handler_function f,
void *context);
labcomm_handler_function f,
void *context);
typedef int (*labcomm_encoder_register_function)(struct labcomm_encoder *e);
......@@ -389,7 +389,7 @@ void firefly_channel_types_add_encoder_type(
* Used to open with automatic restriction after type registration.
*/
void firefly_channel_open_auto_restrict(struct firefly_connection *conn,
struct firefly_channel_types types);
struct firefly_channel_types types);
/**
* Used in accept channel with automatic restriction after type registration.
......
......@@ -148,7 +148,7 @@ void firefly_channel_open(struct firefly_connection *conn)
firefly_error(FIREFLY_ERROR_ALLOC, 1, "Could not add event.");
}
static int firefly_channel_open_auto_restrict_event(void *event_arg)
int firefly_channel_open_auto_restrict_event(void *event_arg)
{
struct firefly_event_chan_open_auto_restrict *arg;
struct firefly_channel_types types;
......@@ -888,4 +888,5 @@ void firefly_channel_set_types(struct firefly_channel *chan,
types.decoder_types = f->next;
FIREFLY_FREE(f);
}
chan->enc_types = types.encoder_types;
}
......@@ -55,6 +55,7 @@ struct firefly_channel *firefly_channel_new(struct firefly_connection *conn)
chan->conn = conn;
chan->restricted_local = false;
chan->restricted_remote = false;
chan->enc_types = NULL;
return chan;
}
......@@ -76,6 +77,13 @@ void firefly_channel_free(struct firefly_channel *chan)
FIREFLY_FREE(tmp->event_arg);
FIREFLY_FREE(tmp);
}
while (chan->enc_types) {
struct firefly_channel_encoder_type *tmp;
tmp = chan->enc_types;
chan->enc_types = tmp->next;
FIREFLY_FREE(tmp);
}
FIREFLY_FREE(chan);
}
......
......@@ -308,6 +308,7 @@ struct firefly_channel {
bool restricted_local; /**< Neg. initiated locally. */
bool restricted_remote; /**< Neg. initiated remotely. */
bool auto_restrict;
struct firefly_channel_encoder_type *enc_types;
};
/**
......@@ -826,10 +827,23 @@ struct labcomm_memory *firefly_labcomm_memory_new(
void firefly_labcomm_memory_free(struct labcomm_memory *mem);
/* TODO: Public */
/**
* @brief The event argument of firefly_channel_open_auto_restrict_event.
*/
struct firefly_event_chan_open_auto_restrict {
struct firefly_connection *connection;
struct firefly_channel_types types;
};
/**
* @brief The event performing the opening of a channel on the
* connection, with automatic restrict for race-free type registration.
*
* @param event_arg A firefly_event_chan_open.
* @return Integer idicating the resutlt of the event.
* @retval Negative integer upon error.
* @see #firefly_channel_open_auto_restrict
*/
int firefly_channel_open_auto_restrict_event(void *event_arg);
#endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment