Commit 3bb04699 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(isc_insert): Handle struct isc_scb_internal.

(isc_findsession): Handle struct isc_scb_internal.
(isc_remove): Handle struct isc_scb_internal.
parent d9c920ac
......@@ -61,7 +61,7 @@
*/
int
isc_insert(struct isc_mcb *mcb,
struct isc_scb *scb)
struct isc_scb_internal *scb)
{
struct isc_scb_entry *isl;
......@@ -85,7 +85,7 @@ isc_insert(struct isc_mcb *mcb,
mcb->sessions = isl;
return ++scb->nlinks;
return ++((struct isc_scb_internal*)scb)->nlinks;
}
......@@ -95,7 +95,7 @@ isc_insert(struct isc_mcb *mcb,
*/
static struct isc_scb_entry *
isc_findsession(struct isc_mcb *mcb,
struct isc_scb *scb)
struct isc_scb_internal *scb)
{
struct isc_scb_entry *isl;
......@@ -119,7 +119,7 @@ isc_findsession(struct isc_mcb *mcb,
*/
int
isc_remove(struct isc_mcb *mcb,
struct isc_scb *scb)
struct isc_scb_internal *scb)
{
struct isc_scb_entry *isl;
......@@ -155,25 +155,25 @@ isc_remove(struct isc_mcb *mcb,
isc_free(isl);
return --scb->nlinks;
return --((struct isc_scb_internal*)scb)->nlinks;
}
/*
** Create a new session structure.
*/
struct isc_scb *
struct isc_scb_internal *
isc_create(struct isc_mcb *mcb,
struct isc_session_cfg *cfg,
enum isc_session_state initial_state)
{
struct isc_scb * scb;
struct isc_scb_internal * scb;
ISC_XNEW(scb);
scb->nlinks = 0;
scb->fd = -1;
scb->pub.fd = -1;
scb->state = initial_state;
scb->wr_msg_q = NULL;
scb->accept_cb= NULL;
......@@ -183,7 +183,7 @@ isc_create(struct isc_mcb *mcb,
scb->data_available_user = NULL;
scb->cfg = cfg;
scb->master = mcb;
scb->pub.master = mcb;
/* Fill in the session structure */
scb->wr_msg_q = isc_newqueue();
......@@ -193,11 +193,13 @@ isc_create(struct isc_mcb *mcb,
}
void
isc_set_read_callback(struct isc_scb *session,
isc_set_read_callback(struct isc_scb *scb,
oop_call_fd *data_available_callback,
isc_write_error_cb *write_error_cb,
void *user)
{
struct isc_scb_internal *session = (struct isc_scb_internal*)scb;
if (session->data_available_registered)
isc_cancel_read_callback(session);
session->data_available_callback = data_available_callback;
......@@ -207,9 +209,9 @@ isc_set_read_callback(struct isc_scb *session,
}
void
isc_check_read_callback(struct isc_scb *session)
isc_check_read_callback(struct isc_scb_internal *session)
{
oop_source *source = session->master->event_source;
oop_source *source = session->pub.master->event_source;
int wanted = 1;
......@@ -226,7 +228,7 @@ isc_check_read_callback(struct isc_scb *session)
else if (!session->data_available_registered
&& session->data_available_callback != NULL)
{
source->on_fd(source, session->fd, OOP_READ,
source->on_fd(source, session->pub.fd, OOP_READ,
session->data_available_callback,
session->data_available_user);
session->data_available_registered = 1;
......@@ -234,25 +236,25 @@ isc_check_read_callback(struct isc_scb *session)
}
void
isc_cancel_read_callback(struct isc_scb *session)
isc_cancel_read_callback(struct isc_scb_internal *session)
{
oop_source *source = session->master->event_source;
oop_source *source = session->pub.master->event_source;
if (session->data_available_registered)
{
source->cancel_fd(source, session->fd, OOP_READ);
source->cancel_fd(source, session->pub.fd, OOP_READ);
session->data_available_registered = 0;
}
}
void
isc_cancel_write_callback(struct isc_scb *session)
isc_cancel_write_callback(struct isc_scb_internal *session)
{
oop_source *source = session->master->event_source;
oop_source *source = session->pub.master->event_source;
if (session->write_cb_registered)
{
source->cancel_fd(source, session->fd, OOP_WRITE);
source->cancel_fd(source, session->pub.fd, OOP_WRITE);
session->write_cb_registered = 0;
}
}
......@@ -267,30 +269,31 @@ int
isc_destroy(struct isc_mcb *mcb,
struct isc_scb *scb)
{
struct isc_scb_internal *sci = (struct isc_scb_internal*)scb;
int code = 0;
isc_cancel_read_callback(scb);
isc_cancel_write_callback(scb);
isc_cancel_read_callback(sci);
isc_cancel_write_callback(sci);
if (mcb)
{
code = isc_remove(mcb, scb);
code = isc_remove(mcb, sci);
if (code < 0)
return code;
if (scb->accept_cb != NULL)
if (sci->accept_cb != NULL)
{
mcb->event_source->cancel_fd(mcb->event_source, scb->fd, OOP_READ);
scb->accept_cb = NULL;
sci->accept_cb = NULL;
}
}
assert(scb->accept_cb == NULL);
assert(sci->accept_cb == NULL);
/*
** Only close and deallocate storage if last reference has been
** removed.
*/
if (scb->nlinks <= 0)
if (sci->nlinks <= 0)
{
if (scb->raddr)
{
......@@ -310,8 +313,8 @@ isc_destroy(struct isc_mcb *mcb,
scb->fd = -1;
}
if (scb->wr_msg_q)
isc_killqueue(scb->wr_msg_q);
if (sci->wr_msg_q)
isc_killqueue(sci->wr_msg_q);
isc_free(scb);
}
......@@ -321,11 +324,13 @@ isc_destroy(struct isc_mcb *mcb,
int isc_disable(struct isc_scb *scb)
{
if (scb->state != ISC_STATE_RUNNING)
struct isc_scb_internal *sci = (struct isc_scb_internal*)scb;
if (sci->state != ISC_STATE_RUNNING)
return -1;
scb->state = ISC_STATE_DISABLED;
isc_check_read_callback(scb);
sci->state = ISC_STATE_DISABLED;
isc_check_read_callback(sci);
return 0;
}
......@@ -333,10 +338,18 @@ int isc_disable(struct isc_scb *scb)
int isc_enable(struct isc_scb *scb)
{
if (scb->state != ISC_STATE_DISABLED)
struct isc_scb_internal *sci = (struct isc_scb_internal*)scb;
if (sci->state != ISC_STATE_DISABLED)
return -1;
scb->state = ISC_STATE_RUNNING;
isc_check_read_callback(scb);
sci->state = ISC_STATE_RUNNING;
isc_check_read_callback(sci);
return 0;
}
oop_source *
isc_getoopsource(struct isc_scb *scb)
{
return scb->master->event_source;
}
Markdown is supported
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